Ignore:
Timestamp:
2012-03-14T12:16:08+01:00 (12 years ago)
Author:
simon04
Message:

make toolbar popup menu more intuitive (also show popup menu on empty space)

File:
1 edited

Legend:

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

    r4968 r5079  
    369369    private static class ToolbarPopupMenu extends JPopupMenu {
    370370        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             });
     371
     372            if(action != null) {
     373                add(tr("Remove from toolbar",action.getDisplayName()))
     374                        .addActionListener(new ActionListener() {
     375                            public void actionPerformed(ActionEvent e) {
     376                                Collection<String> t = new LinkedList<String>(getToolString());
     377                                ActionParser parser = new ActionParser(null);
     378                                // get text definition of current action
     379                                String res = parser.saveAction(action);
     380                                // remove the button from toolbar preferences
     381                                t.remove( res );
     382                                Main.pref.putCollection("toolbar", t);
     383                                Main.toolbar.refreshToolbarControl();
     384                            }
     385                });
     386            }
    385387           
    386388            add(tr("Configure toolbar")).addActionListener(new ActionListener() {
     
    801803    public ToolbarPreferences() {
    802804        control.setFloatable(false);
     805        control.addMouseListener(new PopupMenuLauncher(new ToolbarPopupMenu(null)));
    803806    }
    804807
Note: See TracChangeset for help on using the changeset viewer.