Changeset 120 in josm for src/org/openstreetmap/josm/gui/dialogs/AnnotationPreset.java
- Timestamp:
- 2006-07-21T13:49:09+02:00 (19 years ago)
- File:
-
- 1 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)
Note:
See TracChangeset
for help on using the changeset viewer.