Changeset 4586 in josm


Ignore:
Timestamp:
2011-11-07T13:09:42+01:00 (12 years ago)
Author:
stoecker
Message:

fix #6953 - patch by akks - Allow hiding tool buttons from the edit toolbar

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

Legend:

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

    r4248 r4586  
    100100    }
    101101
     102    void selectPreferencesTabByName(String name) {
     103        tpPreferences.selectTabByName(name);
     104    }
     105
    102106    class CancelAction extends AbstractAction {
    103107        public CancelAction() {
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r4512 r4586  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Component;
    67import java.awt.Font;
    78import java.awt.GridBagLayout;
     
    1112import java.util.ArrayList;
    1213import java.util.Collection;
     14import java.util.HashMap;
    1315import java.util.Iterator;
    1416import java.util.LinkedList;
    1517import java.util.List;
     18import java.util.Map;
    1619
    1720import javax.swing.BorderFactory;
     
    5255    }
    5356
     57    // all created tabs
     58    private final Map<String,Component> tabs = new HashMap<String,Component>();
    5459    private final static Collection<PreferenceSettingFactory> settingsFactory = new LinkedList<PreferenceSettingFactory>();
    5560    private final List<PreferenceSetting> settings = new ArrayList<PreferenceSetting>();
     
    115120            tab = sp;
    116121        }
     122        tabs.put(icon,tab);
    117123        addTab(null, ImageProvider.get("preferences", icon), tab);
    118124        setToolTipTextAt(getTabCount()-1, "<html>"+desc+"</html>");
    119125        return p;
     126    }
     127   
     128    public void selectTabByName(String name) {
     129        Component c = tabs.get(name);
     130        if (c!=null) setSelectedComponent(c);
    120131    }
    121132
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r4306 r4586  
    2727import java.util.Map;
    2828
    29 import javax.swing.AbstractAction;
    3029import javax.swing.Action;
    3130import javax.swing.DefaultListCellRenderer;
     
    6362import org.openstreetmap.josm.actions.ParameterizedActionDecorator;
    6463import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     64import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    6565import org.openstreetmap.josm.tools.GBC;
    6666import org.openstreetmap.josm.tools.ImageProvider;
     
    365365        }
    366366
     367    }
     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           
     386            add(tr("Configure toolbar")).addActionListener(new ActionListener() {
     387                public void actionPerformed(ActionEvent e) {
     388                    final PreferenceDialog p =new PreferenceDialog(Main.parent);
     389                    p.selectPreferencesTabByName("toolbar");
     390                    p.setVisible(true);
     391                }
     392            });
     393           
     394        }
    367395    }
    368396
     
    921949                if (i != null)
    922950                    b.setIcon(i);
     951                b.addMouseListener(new PopupMenuLauncher( new ToolbarPopupMenu(action)));
    923952            }
    924953        }
Note: See TracChangeset for help on using the changeset viewer.