Changeset 3583 in josm for trunk


Ignore:
Timestamp:
2010-10-03T14:39:11+02:00 (14 years ago)
Author:
stoecker
Message:

fix #4041 - toolbar preferences separator dragging broken

File:
1 edited

Legend:

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

    r3223 r3583  
    6969
    7070    public static class ActionDefinition {
    71 
    72         public static ActionDefinition SEPARATOR = new ActionDefinition(null);
    73 
    7471        private final Action action;
    7572        private final Map<String, Object> parameters = new HashMap<String, Object>();
     
    9491        }
    9592
     93        public boolean isSeparator() {
     94            return action == null;
     95        }
     96
     97        public static ActionDefinition getSeparator() {
     98            return new ActionDefinition(null);
     99        }
    96100    }
    97101
     
    207211    private static class ActionParametersTableModel extends AbstractTableModel {
    208212
    209         private ActionDefinition currentAction = ActionDefinition.SEPARATOR;
     213        private ActionDefinition currentAction = ActionDefinition.getSeparator();
    210214
    211215        public int getColumnCount() {
     
    214218
    215219        public int getRowCount() {
    216             if (currentAction == ActionDefinition.SEPARATOR || !(currentAction.getAction() instanceof ParameterizedAction))
     220            if (currentAction.isSeparator() || !(currentAction.getAction() instanceof ParameterizedAction))
    217221                return 0;
    218222            ParameterizedAction pa = (ParameterizedAction)currentAction.getAction();
     
    286290                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedAction.getLastPathComponent();
    287291                        if (node.getUserObject() == null) {
    288                             selected.add(leadItem++, ActionDefinition.SEPARATOR);
     292                            selected.add(leadItem++, ActionDefinition.getSeparator());
    289293                        } else if (node.getUserObject() instanceof Action) {
    290294                            selected.add(leadItem++, new ActionDefinition((Action)node.getUserObject()));
     
    410414                    String s;
    411415                    Icon i;
    412                     if (value != ActionDefinition.SEPARATOR) {
    413                         ActionDefinition action = (ActionDefinition)value;
     416                    ActionDefinition action = (ActionDefinition)value;
     417                    if (!action.isSeparator()) {
    414418                        s = (String) action.getAction().getValue(Action.NAME);
    415419                        i = (Icon) action.getAction().getValue(Action.SMALL_ICON);
     
    561565                        Object obj = node.getUserObject();
    562566                        if (obj == null) {
    563                             dragActions.add(ActionDefinition.SEPARATOR);
     567                            dragActions.add(ActionDefinition.getSeparator());
    564568                        }
    565569                        else if (obj instanceof Action) {
     
    642646            ActionParser parser = new ActionParser(null);
    643647            for (int i = 0; i < selected.size(); ++i) {
    644                 if (selected.get(i) == ActionDefinition.SEPARATOR) {
    645 
     648                ActionDefinition action = (ActionDefinition)selected.get(i);
     649                if (action.isSeparator()) {
    646650                    t.add("|");
    647 
    648651                } else {
    649                     t.add(parser.saveAction((ActionDefinition)(selected.get(i))));
     652                    t.add(parser.saveAction(action));
    650653                }
    651654            }
     
    731734        for (String s : getToolString()) {
    732735            if (s.equals("|")) {
    733                 result.add(ActionDefinition.SEPARATOR);
     736                result.add(ActionDefinition.getSeparator());
    734737            } else {
    735738                ActionDefinition a = actionParser.loadAction(s);
     
    761764
    762765        for (ActionDefinition action : getDefinedActions()) {
    763             if (action == ActionDefinition.SEPARATOR) {
     766            if (action.isSeparator()) {
    764767                control.addSeparator();
    765 
    766768            } else {
    767769                Action a = action.getParametrizedAction();
Note: See TracChangeset for help on using the changeset viewer.