Beispiel #1
0
  public synchronized void commandAction(Command c, Displayable d) {
    if (c == OK_CMD) {

      description = descriptionTF.getString();
      tags = tagsTF.getString();
      boolean[] publicFlags = new boolean[1];
      publicCG.getSelectedFlags(publicFlags);
      publicFlag = publicFlags[0];
      proceed = true;
      logger.info("Uploading GPX: desc=" + description + " tags=" + tags + " public=" + publicFlag);
      GpsMid.getInstance().showPreviousDisplayable();
      notifyAll();
    }
    if (c == BACK_CMD) {
      proceed = false;
      GpsMid.getInstance().showPreviousDisplayable();
      notifyAll();
    }
  }
  public void commandAction(Command c, Item it) {
    // #debug info
    logger.info("Command " + c + " Item " + it);
    Hashtable tags = osmentity.getTags();
    if (c == REMOVE_CMD) {
      tags.remove(((StringItem) it).getLabel());
      setupScreen();
    }
    if (c == EDIT_CMD) {
      for (int i = 0; i < this.size(); i++) {
        if (this.get(i) == it) {
          StringItem si = (StringItem) it;
          this.delete(i);
          TextField tf = new TextField(it.getLabel(), si.getText(), 100, TextField.ANY);
          tf.addCommand(OK_CMD);
          tf.setItemCommandListener(this);
          this.insert(i, tf);
          Display.getDisplay(GpsMid.getInstance()).setCurrentItem(tf);
        }
      }
    }

    if (c == OK_CMD) {
      if (addTag) {
        tags.put(
            ((TextField) this.get(this.size() - 2)).getString(),
            ((TextField) this.get(this.size() - 1)).getString());
      } else {
        for (int i = 0; i < this.size(); i++) {
          if (this.get(i) == it) {
            TextField tf = (TextField) it;
            tags.put(it.getLabel(), tf.getString());
          }
        }
      }
      addTag = false;
      setupScreen();
    }
  }
  public void commandAction(Command c, Displayable d) {
    if (c == BACK_CMD) {
      if (d == this) {
        parent.show();
      } else {
        show();
      }
    }
    if (c == ADD_CMD) {
      this.addTag = true;
      TextField tf =
          new TextField(Locale.get("guiosmentitydisplay.key") /*key*/, "", 100, TextField.ANY);
      tf.addCommand(OK_CMD);
      tf.setItemCommandListener(this);
      this.append(tf);
      Display.getDisplay(GpsMid.getInstance()).setCurrentItem(tf);
      tf = new TextField(Locale.get("guiosmentitydisplay.value") /*value*/, "", 100, TextField.ANY);
      tf.addCommand(OK_CMD);
      tf.setItemCommandListener(this);
      this.append(tf);
    }

    if (c == CREATE_CHANGE_CMD) {
      changesetGui = new GuiOsmChangeset(this, this);
      changesetGui.show();
    }

    if (c == CLOSE_CHANGE_CMD) {
      if (changesetGui == null) {
        logger.error(
            Locale.get(
                "guiosmentitydisplay.NoChangesetIsCurrentlyOpen") /*No changeset is currently open*/);
      } else {
        changesetGui.closeChangeset();
        changesetGui = null;
      }
    }
  }
Beispiel #4
0
 public void show() {
   GpsMid.getInstance().show(this);
 }
 protected void setupScreen() {
   try {
     this.deleteAll();
     addTag = false;
     if (osmentity == null) {
       this.append(
           new StringItem(
               Locale.get("guiosmentitydisplay.NoDataAvailable") /*No Data available*/, "..."));
       return;
     }
     Hashtable tags = osmentity.getTags();
     if (tags == null) return;
     Enumeration keysEn = tags.keys();
     while (keysEn.hasMoreElements()) {
       String key = (String) keysEn.nextElement();
       Item i = new StringItem(key, (String) tags.get(key));
       i.addCommand(EDIT_CMD);
       i.addCommand(REMOVE_CMD);
       i.setItemCommandListener(this);
       // #style formItem
       this.append(i);
     }
     if (osmentity.getVersion() > 0) {
       // #style formItem
       this.append(new StringItem(Locale.get("guiosmentitydisplay.Edited") /*Edited */, null));
       // #style formItem
       this.append(
           new StringItem(
               Locale.get("guiosmentitydisplay.at") /*    at:*/, osmentity.getEditTime()));
       // #style formItem
       this.append(
           new StringItem(
               Locale.get("guiosmentitydisplay.by") /*    by:*/, osmentity.getEditor()));
       // #style formItem
       this.append(
           new StringItem(
               Locale.get("guiosmentitydisplay.ver") /*    ver:*/,
               Integer.toString(osmentity.getVersion())));
     }
     // #if polish.android
     ViewItem createButton =
         new SaveButton(
             Locale.get("guiosmentitydisplay.CreateChangeset") /*Create changeset*/,
             this,
             (Displayable) this,
             CREATE_CHANGE_CMD);
     ViewItem closeButton =
         new SaveButton(
             Locale.get("guiosmentitydisplay.CloseChangeset") /*Close changeset*/,
             this,
             (Displayable) this,
             CLOSE_CHANGE_CMD);
     this.append(createButton);
     this.append(closeButton);
     AndroidDisplay ad = AndroidDisplay.getDisplay(GpsMid.getInstance());
     ad.setOnKeyListener(
         new OnKeyListener() {
           public boolean onKey(View v, int keyCode, KeyEvent event) {
             if (event.getAction() == KeyEvent.ACTION_DOWN) {
               // check if the right key was pressed
               if (keyCode == KeyEvent.KEYCODE_BACK) {
                 backPressed();
                 return true;
               }
             }
             return false;
           }
         });
     // #endif
   } catch (Exception e) {
     logger.exception(
         Locale.get(
             "guiosmentitydisplay.InitialisingEntityTagScreenFailed") /*Initialising entity tag screen failed: */,
         e);
   }
 }
Beispiel #6
0
 public void show() {
   GpsMid.getInstance().show(list);
   // Display.getDisplay(GpsMid.getInstance()).setCurrent(list);
 }