Ticket #21730: 21730.patch

File 21730.patch, 2.8 KB (added by GerdP, 4 years ago)
  • src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

     
    575575     * Key: Registered name (property "toolbar" of action).
    576576     * Value: The action to execute.
    577577     */
    578     private final Map<String, Action> actions = new ConcurrentHashMap<>();
     578    private final Map<String, Action> actionsInMenu = new ConcurrentHashMap<>();
    579579    private final Map<String, Action> regactions = new ConcurrentHashMap<>();
    580580
    581581    private final DefaultMutableTreeNode rootActionsNode = new DefaultMutableTreeNode(tr("Actions"));
     
    10511051                        continue;
    10521052                    } else {
    10531053                        String toolbar = (String) tb;
    1054                         Action r = actions.get(toolbar);
     1054                        Action r = actionsInMenu.get(toolbar);
    10551055                        if (r != null && r != action && !toolbar.startsWith(IMAGERY_PREFIX)) {
    10561056                            Logging.info(tr("Toolbar action {0} overwritten: {1} gets {2}",
    10571057                            toolbar, r.getClass().getName(), action.getClass().getName()));
    10581058                        }
    1059                         actions.put(toolbar, action);
     1059                        actionsInMenu.put(toolbar, action);
    10601060                    }
    10611061                } else {
    10621062                    userObject = menuItem.getText();
     
    10691069    }
    10701070
    10711071    private void loadActions() {
     1072        actionsInMenu.clear();
    10721073        rootActionsNode.removeAllChildren();
    10731074        loadAction(rootActionsNode, MainApplication.getMenu());
    10741075        for (Map.Entry<String, Action> a : regactions.entrySet()) {
    1075             if (actions.get(a.getKey()) == null) {
     1076            if (actionsInMenu.get(a.getKey()) == null) {
    10761077                rootActionsNode.add(new DefaultMutableTreeNode(a.getValue()));
    10771078            }
    10781079        }
     
    11001101        loadActions();
    11011102
    11021103        Map<String, Action> allActions = new ConcurrentHashMap<>(regactions);
    1103         allActions.putAll(actions);
     1104        allActions.putAll(actionsInMenu);
    11041105        ActionParser actionParser = new ActionParser(allActions);
    11051106
    11061107        Collection<ActionDefinition> result = new ArrayList<>();
     
    11391140            }
    11401141        }
    11411142        if (toolbar != null) {
    1142             actions.put(toolbar, action);
    11431143            regactions.put(toolbar, action);
    11441144        }
    11451145        return action;
     
    11541154    public Action unregister(Action action) {
    11551155        Object toolbar = action.getValue("toolbar");
    11561156        if (toolbar instanceof String) {
    1157             actions.remove(toolbar);
    11581157            return regactions.remove(toolbar);
    11591158        }
    11601159        return null;