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); } }
public void commandAction(Command c, Item it) { System.out.println("Command " + c + " Item " + it); Hashtable tags = osmway.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 == EXIT_CMD) { if (d == this) { parent.show(); } else { show(); } } if (c == ADD_CMD) { this.addTag = true; TextField tf = new TextField("key", "", 100, TextField.ANY); tf.addCommand(OK_CMD); tf.setItemCommandListener(this); this.append(tf); Display.getDisplay(GpsMid.getInstance()).setCurrentItem(tf); tf = new TextField("value", "", 100, TextField.ANY); tf.addCommand(OK_CMD); tf.setItemCommandListener(this); this.append(tf); } if (c == UPLOAD_CMD) { parent.show(); eway.uploadXML(this); } if (c == REVERSE_CMD) { osmway.reverseWay(); } if (c == PRESET_CMD) { presets = new List("Tagging Presets", List.IMPLICIT); presets.append("maxspeed=20 mph", null); presets.append("maxspeed=30 mph", null); presets.append("oneway=yes", null); presets.append("name=", null); presets.append("ref=", null); presets.append("lcn_ref=", null); presets.append("foot=yes", null); presets.append("bicycle=yes", null); presets.append("motorcar=yes", null); presets.append("access=private", null); presets.append("maxweight=7.5", null); presets.append("maxlength=18", null); presets.append("maxwidth=3", null); presets.append("maxheigt=4", null); presets.addCommand(OK_CMD); presets.addCommand(EXIT_CMD); presets.setCommandListener(this); presets.setSelectCommand(OK_CMD); GpsMid.getInstance().show(presets); } if (c == OK_CMD) { String addPreset = presets.getString(presets.getSelectedIndex()); int split = addPreset.indexOf("="); osmway .getTags() .put(addPreset.substring(0, split), addPreset.substring(split + 1, addPreset.length())); presets = null; setupScreen(); show(); } }