Changeset 120 in josm for src/org/openstreetmap
- Timestamp:
- 2006-07-21T13:49:09+02:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/dialogs/AnnotationPreset.java
r117 r120 132 132 List<Item> current; 133 133 String currentName; 134 Class<?> currentType; 134 135 private static int unknownCounter = 1; 135 136 … … 142 143 if (currentName == null) 143 144 currentName = "Unnamed Preset #"+(unknownCounter++); 145 if (a.getValue("type") != null) { 146 String s = a.getValue("type"); 147 s = Character.toUpperCase(s.charAt(0))+s.substring(1); 148 try { 149 currentType = Class.forName("org.openstreetmap.josm.data.osm."+s); 150 } catch (ClassNotFoundException e) { 151 e.printStackTrace(); 152 throw new SAXException(tr("Unknown type at line {0}", getLineNumber())); 153 } 154 } 144 155 } else if (qname.equals("text")) 145 156 current.add(new Text(a.getValue("key"), a.getValue("text"), a.getValue("default"))); … … 160 171 throw new SAXException(tr("Unknown annotation object {0} at line {1} column {2}", qname, getLineNumber(), getColumnNumber())); 161 172 } 173 162 174 @Override public void endElement(String ns, String lname, String qname) { 163 175 if (qname.equals("item")) 164 data.add(new AnnotationPreset(current, currentName)); 176 data.add(new AnnotationPreset(current, currentName, currentType)); 165 177 } 166 178 } … … 168 180 private List<Item> data; 169 181 String name; 170 171 public AnnotationPreset(List<Item> data, String name) { 182 private Class<?> type; 183 184 public AnnotationPreset(List<Item> data, String name, Class<?> currentType) { 172 185 this.data = data; 173 186 this.name = name; 187 this.type = currentType; 174 188 } 175 189 … … 209 223 } 210 224 211 public Command createCommand(Collection<OsmPrimitive> sel) { 225 public Command createCommand(Collection<OsmPrimitive> participants) { 226 Collection<OsmPrimitive> sel = new LinkedList<OsmPrimitive>(); 227 for (OsmPrimitive osm : participants) 228 if (osm.getClass() == type) 229 sel.add(osm); 230 if (sel.isEmpty()) 231 return null; 232 212 233 List<Command> cmds = new LinkedList<Command>(); 213 234 for (Item i : data) -
src/org/openstreetmap/josm/gui/dialogs/AnnotationTester.java
r119 r120 46 46 JOptionPane.showMessageDialog(null, "Error parsing "+source+": "+e.getMessage()); 47 47 } 48 49 try { 50 if (in != null) 51 in.close(); 52 } catch (IOException e) { 53 } 48 54 } 49 55 annotationPresets.setModel(new DefaultComboBoxModel(allPresets)); -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r119 r120 43 43 import org.openstreetmap.josm.Main; 44 44 import org.openstreetmap.josm.command.ChangePropertyCommand; 45 import org.openstreetmap.josm.command.Command; 45 46 import org.openstreetmap.josm.data.SelectionChangedListener; 46 47 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 224 225 in = new FileInputStream(source); 225 226 allPresets.addAll(AnnotationPreset.readAll(in)); 227 in.close(); 226 228 } catch (IOException e) { 227 229 e.printStackTrace(); … … 250 252 answer = JOptionPane.showConfirmDialog(Main.parent, p, trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()), JOptionPane.OK_CANCEL_OPTION); 251 253 if (answer == JOptionPane.OK_OPTION) { 252 Main.main.editLayer().add(preset.createCommand(sel)); 253 selectionChanged(sel); // update whole table 254 Command cmd = preset.createCommand(sel); 255 if (cmd != null) { 256 Main.main.editLayer().add(cmd); 257 selectionChanged(sel); // update whole table 258 } 254 259 } 255 260 annotationPresets.setSelectedIndex(0);
Note:
See TracChangeset
for help on using the changeset viewer.