Пример #1
0
 /**
  * Add help for an item using the item's Label and text from resource info.
  *
  * @param item
  * @param aKey
  * @return final
  * @author Irv Bunton
  */
 public final int appendItemHelpRsc(Item item, String aKey) {
   StringItem si = new StringItem(item.getLabel(), ResourceProviderME.get(aKey));
   // #ifdef DMIDP20
   si.setLayout(Item.LAYOUT_BOTTOM);
   // #endif
   return super.append(si);
 }
Пример #2
0
  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();
    }
  }
Пример #3
0
  private void setupScreen() {
    this.deleteAll();
    addTag = false;
    if (osmway == null) {
      this.append(new StringItem("No Data available", "..."));
      return;
    }
    this.append(new StringItem("Edited ", null));
    this.append(bearingArrow());
    this.append(new StringItem("    at:", osmway.getEditTime()));
    this.append(new StringItem("    by: ", osmway.getEditor()));

    Hashtable tags = osmway.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);
      this.append(i);
    }
  }
Пример #4
0
 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);
   }
 }