Changeset 878 in josm for trunk/src/org
- Timestamp:
- 2008-08-28T13:44:27+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r839 r878 138 138 { 139 139 JMenu submenu = new JMenu(p); 140 ((TaggingPresetMenu)p).menu = submenu; 140 141 submenus.put((TaggingPresetMenu)p, submenu); 141 142 m.add(submenu); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetMenu.java
r839 r878 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.event.ActionEvent; 7 import java.awt.Component; 8 6 9 import javax.swing.Action; 10 import javax.swing.JMenu; 11 import javax.swing.JMenuItem; 12 import javax.swing.JPopupMenu; 13 import javax.swing.JSeparator; 7 14 8 15 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 9 16 10 17 public class TaggingPresetMenu extends TaggingPreset { 18 public JMenu menu = null; // set by TaggingPresetPreferences 11 19 public void setDisplayName() { 12 20 String n = getName(); … … 18 26 super.setIcon(iconName); 19 27 } 28 public void actionPerformed(ActionEvent e) { 29 Object s = e.getSource(); 30 if(menu != null && s instanceof Component) 31 { 32 Component co = (Component)s; 33 JPopupMenu pm = new JPopupMenu(getName()); 34 for(Component c : menu.getMenuComponents()) 35 { 36 if(c instanceof JMenuItem) 37 { 38 JMenuItem j = new JMenuItem(((JMenuItem)c).getAction()); 39 j.setText(((JMenuItem)c).getText()); 40 pm.add(j); 41 } 42 else if(c instanceof JSeparator) 43 pm.addSeparator(); 44 } 45 pm.show(co, co.getWidth()/2, co.getHeight()/2); 46 } 47 } 20 48 }
Note:
See TracChangeset
for help on using the changeset viewer.