Changeset 839 in josm


Ignore:
Timestamp:
Aug 22, 2008 6:47:34 PM (5 years ago)
Author:
stoecker
Message:

cleanup of tagging preset, add submenus

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java

    r828 r839  
    130130                { 
    131131                        HashMap<TaggingPresetMenu,JMenu> submenus = new HashMap<TaggingPresetMenu,JMenu>(); 
    132                         for (final TaggingPreset p : taggingPresets) { 
    133                                 String name = (String) p.getValue(Action.NAME); 
    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                                 } 
     132                        for (final TaggingPreset p : taggingPresets) 
     133                        { 
     134                                JMenu m = p.group != null ? submenus.get(p.group) : Main.main.menu.presetsMenu; 
     135                                if (p instanceof TaggingPresetSeperator) 
     136                                        m.add(new JSeparator()); 
    140137                                else if (p instanceof TaggingPresetMenu) 
    141138                                { 
    142139                                        JMenu submenu = new JMenu(p); 
    143140                                        submenus.put((TaggingPresetMenu)p, submenu); 
    144                                         Main.main.menu.presetsMenu.add(submenu); 
    145                                 } else { 
    146                                         if(p.group != null) 
    147                                         { 
    148                                                 JMenuItem m = new JMenuItem(p); 
    149                                                 m.setText(tr(p.name)); 
    150                                                 submenus.get(p.group).add(m); 
    151                                         } 
    152                                         else 
    153                                                 Main.main.menu.presetsMenu.add(new JMenuItem(p)); 
     141                                        m.add(submenu); 
     142                                } 
     143                                else 
     144                                { 
     145                                        JMenuItem mi = new JMenuItem(p); 
     146                                        mi.setText(tr(p.name)); 
     147                                        m.add(mi); 
    154148                                } 
    155149                        } 
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r824 r839  
    340340         */ 
    341341        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                 } 
    356         } 
    357  
     342                putValue(Action.NAME, getName()); 
     343                putValue("toolbar", "tagging_" + getRawName()); 
     344                putValue(SHORT_DESCRIPTION, "<html>"+ group != null ? 
     345                tr("Use preset ''{0}'' of group ''{1}''", tr(name), group.getName()) : 
     346                tr("Use preset ''{0}''", tr(name)) 
     347                +"</html>"); 
     348        } 
     349 
     350        public String getName() { 
     351                return group != null ? group.getName() + "/" + tr(name) : tr(name); 
     352        } 
     353        public String getRawName() { 
     354                return group != null ? group.getRawName() + "/" + name : name; 
     355        } 
    358356        /** 
    359357         * Called from the XML parser to set the icon 
     
    413411                                TaggingPresetMenu tp = (TaggingPresetMenu) o; 
    414412                                if(tp == lastmenu) 
    415                                         lastmenu = null; 
     413                                        lastmenu = tp.group; 
    416414                                else 
    417415                                { 
    418416                                        tp.setDisplayName(); 
     417                                        tp.group = lastmenu; 
    419418                                        lastmenu = tp; 
    420419                                        all.add(tp); 
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetMenu.java

    r824 r839  
    1010public class TaggingPresetMenu extends TaggingPreset { 
    1111        public void setDisplayName() { 
    12                 putValue(Action.NAME, tr(name)); 
    13                 String tooltip = tr("Preset group ''{0}''", tr(name)); 
    14                 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+"</html>"); 
    15                 putValue("toolbar", "tagginggroup_" + name); 
     12                String n = getName(); 
     13                putValue(Action.NAME, n); 
     14                putValue(SHORT_DESCRIPTION, "<html>"+tr("Preset group ''{0}''", n)+"</html>"); 
     15                putValue("toolbar", "tagginggroup_" + getRawName()); 
    1616        } 
    1717        public void setIcon(String iconName) { 
Note: See TracChangeset for help on using the changeset viewer.