Changeset 117 in josm for src/org/openstreetmap/josm/gui/dialogs
- Timestamp:
- 2006-07-20T01:29:55+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/dialogs/AnnotationPreset.java
r116 r117 14 14 15 15 import javax.swing.JCheckBox; 16 import javax.swing.JComboBox; 16 17 import javax.swing.JLabel; 17 18 import javax.swing.JPanel; … … 76 77 public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) { 77 78 cmds.add(new ChangePropertyCommand(sel, key, check.isSelected() ? "true" : null)); 79 } 80 } 81 82 public static class Combo implements Item { 83 String key; 84 String label; 85 JComboBox combo; 86 87 public void addToPanel(JPanel p) { 88 p.add(new JLabel(label), GBC.std().insets(0,0,10,0)); 89 p.add(combo, GBC.eol().fill(GBC.HORIZONTAL)); 90 } 91 public Combo(String key, String label, String def, String[] values, boolean editable) { 92 this.key = key; 93 this.label = label; 94 combo = new JComboBox(values); 95 combo.setEditable(editable); 96 combo.setSelectedItem(def); 97 } 98 public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) { 99 String str = combo.isEditable()?combo.getEditor().getItem().toString() : combo.getSelectedItem().toString(); 100 cmds.add(new ChangePropertyCommand(sel, key, str)); 78 101 } 79 102 } … … 120 143 currentName = "Unnamed Preset #"+(unknownCounter++); 121 144 } else if (qname.equals("text")) 122 current.add(new Text(a.getValue("key"), a.getValue(" label"), a.getValue("default")));145 current.add(new Text(a.getValue("key"), a.getValue("text"), a.getValue("default"))); 123 146 else if (qname.equals("check")) { 124 147 String s = a.getValue("default"); 125 boolean c heck= s == null || s.equals("0") || s.startsWith("off") || s.startsWith("false") || s.startsWith("no");126 current.add(new Check(a.getValue("key"), a.getValue(" label"), check));148 boolean clear = s == null || s.equals("0") || s.startsWith("off") || s.startsWith("false") || s.startsWith("no"); 149 current.add(new Check(a.getValue("key"), a.getValue("text"), !clear)); 127 150 } else if (qname.equals("label")) 128 current.add(new Label(a.getValue("label"))); 129 else if (qname.equals("key")) 151 current.add(new Label(a.getValue("text"))); 152 else if (qname.equals("combo")) { 153 String[] values = a.getValue("values").split(","); 154 String s = a.getValue("readonly"); 155 boolean editable = s == null || s.equals("0") || s.startsWith("off") || s.startsWith("false") || s.startsWith("no"); 156 current.add(new Combo(a.getValue("key"), a.getValue("text"), a.getValue("default"), values, editable)); 157 } else if (qname.equals("key")) 130 158 current.add(new Key(a.getValue("key"), a.getValue("value"))); 131 159 else … … 176 204 return p; 177 205 } 178 206 179 207 @Override public String toString() { 180 208 return name; … … 191 219 else 192 220 return new SequenceCommand(tr("Change Properties"), cmds); 193 221 } 194 222 }
Note:
See TracChangeset
for help on using the changeset viewer.