Changeset 824 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2008-08-22T15:52:17+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r694 r824 29 29 import org.openstreetmap.josm.Main; 30 30 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 31 import org.openstreetmap.josm.gui.tagging.TaggingPresetMenu; 32 import org.openstreetmap.josm.gui.tagging.TaggingPresetSeperator; 31 33 import org.openstreetmap.josm.tools.GBC; 32 34 … … 127 129 else 128 130 { 129 HashMap< String,JMenu> submenus = new HashMap<String,JMenu>();131 HashMap<TaggingPresetMenu,JMenu> submenus = new HashMap<TaggingPresetMenu,JMenu>(); 130 132 for (final TaggingPreset p : taggingPresets) { 131 133 String name = (String) p.getValue(Action.NAME); 132 if (name.equals(" ")) { 133 Main.main.menu.presetsMenu.add(new JSeparator()); 134 if (p instanceof TaggingPresetSeperator) { 135 if(p.group != null) 136 submenus.get(p.group).add(new JSeparator()); 137 else 138 Main.main.menu.presetsMenu.add(new JSeparator()); 139 } 140 else if (p instanceof TaggingPresetMenu) 141 { 142 JMenu submenu = new JMenu(p); 143 submenus.put((TaggingPresetMenu)p, submenu); 144 Main.main.menu.presetsMenu.add(submenu); 134 145 } else { 135 String[] sp = name.split("/"); 136 if (sp.length <= 1) { 137 if(p.isEmpty()) 138 { 139 JMenu submenu = submenus.get(sp[0]); 140 if (submenu == null) { 141 submenu = new JMenu(p); 142 submenus.put(sp[0], submenu); 143 Main.main.menu.presetsMenu.add(submenu); 144 } 145 } 146 else 147 { 148 Main.main.menu.presetsMenu.add(new JMenuItem(p)); 149 } 150 } else { 151 p.setDisplayName(sp[1]); 152 JMenu submenu = submenus.get(sp[0]); 153 if (submenu == null) { 154 submenu = new JMenu(sp[0]); 155 submenus.put(sp[0], submenu); 156 Main.main.menu.presetsMenu.add(submenu); 157 } 158 if (sp[1].equals(" ")) 159 submenu.add(new JSeparator()); 160 else 161 submenu.add(p); 162 } 146 if(p.group != null) 147 submenus.get(p.group).add(p); 148 else 149 Main.main.menu.presetsMenu.add(new JMenuItem(p)); 163 150 } 164 } 151 } 165 152 } 166 153 } -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r796 r824 145 145 for (Action a : actions.values()) 146 146 { 147 String name = a.getValue(a.NAME).toString(); 148 if(!name.equals(" ")) 149 us.put(a.getValue(a.NAME).toString()+a.toString(), a); 147 us.put(a.getValue(a.NAME).toString()+a.toString(), a); 150 148 } 151 149 for (String a : us.keySet()) -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r715 r824 41 41 import org.openstreetmap.josm.data.osm.OsmUtils; 42 42 import org.openstreetmap.josm.gui.QuadStateCheckBox; 43 import org.openstreetmap.josm.gui.tagging.TaggingPresetMenu; 44 import org.openstreetmap.josm.gui.tagging.TaggingPresetSeperator; 43 45 import org.openstreetmap.josm.tools.GBC; 44 46 import org.openstreetmap.josm.tools.ImageProvider; … … 54 56 */ 55 57 public class TaggingPreset extends AbstractAction { 56 58 59 public TaggingPresetMenu group = null; 60 public String name; 61 57 62 public static abstract class Item { 58 63 public boolean focus = false; … … 331 336 public TaggingPreset() {} 332 337 333 334 public boolean isEmpty()335 {336 return (data.size() == 0);337 }338 /**339 * Called from the XML parser to set the name of the tagging preset340 */341 public void setName(String name) {342 setDisplayName(tr(name));343 putValue("toolbar", "tagging_"+name);344 }345 346 338 /** 347 339 * Change the display name without changing the toolbar value. 348 340 */ 349 public void setDisplayName(String name) { 350 putValue(Action.NAME, tr(name)); 351 String tooltip = tr("Use preset ''{0}''", tr(name)); 352 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+"</html>"); 341 public void setDisplayName() { 342 if(group == null) 343 { 344 putValue(Action.NAME, tr(name)); 345 String tooltip = tr("Use preset ''{0}''", tr(name)); 346 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+"</html>"); 347 putValue("toolbar", "tagging_" + name); 348 } 349 else 350 { 351 putValue(Action.NAME, tr(group.name) + "/" + tr(name)); 352 String tooltip = tr("Use preset ''{0}'' of group ''{1}''", tr(name), tr(group.name)); 353 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+"</html>"); 354 putValue("toolbar", "tagging_" + group.name + "/" + name); 355 } 353 356 } 354 357 … … 395 398 XmlObjectParser parser = new XmlObjectParser(); 396 399 parser.mapOnStart("item", TaggingPreset.class); 400 parser.mapOnStart("seperator", TaggingPresetSeperator.class); 401 parser.mapBoth("group", TaggingPresetMenu.class); 397 402 parser.map("text", Text.class); 398 403 parser.map("check", Check.class); … … 401 406 parser.map("key", Key.class); 402 407 LinkedList<TaggingPreset> all = new LinkedList<TaggingPreset>(); 408 TaggingPresetMenu lastmenu = null; 403 409 parser.start(in); 404 410 while(parser.hasNext()) { 405 411 Object o = parser.next(); 406 if (o instanceof TaggingPreset) { 407 all.add((TaggingPreset)o); 408 Main.toolbar.register((TaggingPreset)o); 412 if (o instanceof TaggingPresetMenu) { 413 TaggingPresetMenu tp = (TaggingPresetMenu) o; 414 if(tp == lastmenu) 415 lastmenu = null; 416 else 417 { 418 tp.setDisplayName(); 419 lastmenu = tp; 420 all.add(tp); 421 Main.toolbar.register(tp); 422 423 } 424 } else if (o instanceof TaggingPresetSeperator) { 425 TaggingPresetSeperator tp = (TaggingPresetSeperator) o; 426 tp.group = lastmenu; 427 all.add(tp); 428 } else if (o instanceof TaggingPreset) { 429 TaggingPreset tp = (TaggingPreset) o; 430 tp.group = lastmenu; 431 tp.setDisplayName(); 432 all.add(tp); 433 Main.toolbar.register(tp); 409 434 } else 410 435 all.getLast().data.add((Item)o); -
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r679 r824 67 67 if (mapping.get(qname).onStart) 68 68 report(); 69 if (mapping.get(qname).both) 70 { 71 try { 72 queue.put(current.peek()); 73 } catch (InterruptedException e) { 74 } 75 } 69 76 } 70 77 } … … 156 163 Class<?> klass; 157 164 boolean onStart; 158 public Entry(Class<?> klass, boolean onStart) { 165 boolean both; 166 public Entry(Class<?> klass, boolean onStart, boolean both) { 159 167 super(); 160 168 this.klass = klass; 161 169 this.onStart = onStart; 170 this.both = both; 162 171 } 163 172 } … … 209 218 210 219 public void map(String tagName, Class<?> klass) { 211 mapping.put(tagName, new Entry(klass,false)); 220 mapping.put(tagName, new Entry(klass,false,false)); 212 221 } 213 222 214 223 public void mapOnStart(String tagName, Class<?> klass) { 215 mapping.put(tagName, new Entry(klass,true)); 224 mapping.put(tagName, new Entry(klass,true,false)); 225 } 226 227 public void mapBoth(String tagName, Class<?> klass) { 228 mapping.put(tagName, new Entry(klass,false,true)); 216 229 } 217 230
Note:
See TracChangeset
for help on using the changeset viewer.