Changeset 125 in josm
- Timestamp:
- 2006-07-24T20:45:40+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/dialogs/AnnotationPreset.java
r123 r125 136 136 List<Item> current; 137 137 String currentName; 138 C lass<?> currentType;138 Collection<Class<?>> currentTypes; 139 139 private static int unknownCounter = 1; 140 140 … … 149 149 if (a.getValue("type") != null) { 150 150 String s = a.getValue("type"); 151 s = Character.toUpperCase(s.charAt(0))+s.substring(1);152 151 try { 153 currentType = Class.forName("org.openstreetmap.josm.data.osm."+s); 152 for (String type : s.split(",")) { 153 type = Character.toUpperCase(type.charAt(0))+type.substring(1); 154 if (currentTypes == null) 155 currentTypes = new LinkedList<Class<?>>(); 156 currentTypes.add(Class.forName("org.openstreetmap.josm.data.osm."+type)); 157 } 154 158 } catch (ClassNotFoundException e) { 155 159 e.printStackTrace(); … … 188 192 189 193 @Override public void endElement(String ns, String lname, String qname) { 190 if (qname.equals("item")) 191 data.add(new AnnotationPreset(current, currentName, currentType)); 194 if (qname.equals("item")) { 195 data.add(new AnnotationPreset(current, currentName, currentTypes)); 196 current = null; 197 currentName = null; 198 currentTypes = null; 199 } 192 200 } 193 201 } 194 202 195 203 private List<Item> data; 196 String name;197 private C lass<?> type;198 199 public AnnotationPreset(List<Item> data, String name, C lass<?> currentType) {204 public final String name; 205 private Collection<Class<?>> types; 206 207 public AnnotationPreset(List<Item> data, String name, Collection<Class<?>> currentTypes) { 200 208 this.data = data; 201 209 this.name = name; 202 this.type = currentType;210 this.types = currentTypes; 203 211 } 204 212 … … 234 242 } 235 243 236 @Override public String toString() {237 return name;238 }239 240 244 public Command createCommand(Collection<OsmPrimitive> participants) { 241 245 Collection<OsmPrimitive> sel = new LinkedList<OsmPrimitive>(); 242 246 for (OsmPrimitive osm : participants) 243 if ( osm.getClass() == type)247 if (types == null || types.contains(osm.getClass())) 244 248 sel.add(osm); 245 249 if (sel.isEmpty())
Note:
See TracChangeset
for help on using the changeset viewer.