Ticket #6953: toolbarContextMenu.patch
File toolbarContextMenu.patch, 2.5 KB (added by , 14 years ago) |
---|
-
src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
26 26 import java.util.List; 27 27 import java.util.Map; 28 28 29 import javax.swing.AbstractAction;30 29 import javax.swing.Action; 31 30 import javax.swing.DefaultListCellRenderer; 32 31 import javax.swing.DefaultListModel; … … 62 61 import org.openstreetmap.josm.actions.ParameterizedAction; 63 62 import org.openstreetmap.josm.actions.ParameterizedActionDecorator; 64 63 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 64 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 65 65 import org.openstreetmap.josm.tools.GBC; 66 66 import org.openstreetmap.josm.tools.ImageProvider; 67 67 … … 366 366 367 367 } 368 368 369 private static class ToolbarPopupMenu extends JPopupMenu { 370 public ToolbarPopupMenu(final ActionDefinition action) { 371 372 add(tr("Remove from toolbar",action.getDisplayName())) 373 .addActionListener(new ActionListener() { 374 public void actionPerformed(ActionEvent e) { 375 Collection<String> t = new LinkedList<String>(getToolString()); 376 ActionParser parser = new ActionParser(null); 377 // get text definition of current action 378 String res = parser.saveAction(action); 379 // remove the button from toolbar preferences 380 t.remove( res ); 381 Main.pref.putCollection("toolbar", t); 382 Main.toolbar.refreshToolbarControl(); 383 } 384 }); 385 // TODO: How to show specific tab of preferences - toolbar settings? 386 add(tr("Configure toolbar")).addActionListener(Main.main.menu.preferences); 387 388 } 389 } 390 369 391 /** 370 392 * Key: Registered name (property "toolbar" of action). 371 393 * Value: The action to execute. … … 920 942 Icon i = action.getDisplayIcon(); 921 943 if (i != null) 922 944 b.setIcon(i); 945 b.addMouseListener(new PopupMenuLauncher( new ToolbarPopupMenu(action))); 923 946 } 924 947 } 925 948 control.setVisible(control.getComponentCount() != 0);