Ticket #21730: 21730-2.patch
| File 21730-2.patch, 3.7 KB (added by , 4 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
575 575 * Key: Registered name (property "toolbar" of action). 576 576 * Value: The action to execute. 577 577 */ 578 private final Map<String, Action> actions = new ConcurrentHashMap<>();579 578 private final Map<String, Action> regactions = new ConcurrentHashMap<>(); 580 579 581 580 private final DefaultMutableTreeNode rootActionsNode = new DefaultMutableTreeNode(tr("Actions")); … … 1025 1024 TaggingPresets.addListener(this); 1026 1025 } 1027 1026 1028 private void loadAction(DefaultMutableTreeNode node, MenuElement menu ) {1027 private void loadAction(DefaultMutableTreeNode node, MenuElement menu, Map<String, Action> actionsInMenu) { 1029 1028 Object userObject = null; 1030 1029 MenuElement menuElement = menu; 1031 1030 if (menu.getSubElements().length > 0 && … … 1051 1050 continue; 1052 1051 } else { 1053 1052 String toolbar = (String) tb; 1054 Action r = actions .get(toolbar);1053 Action r = actionsInMenu.get(toolbar); 1055 1054 if (r != null && r != action && !toolbar.startsWith(IMAGERY_PREFIX)) { 1056 1055 Logging.info(tr("Toolbar action {0} overwritten: {1} gets {2}", 1057 1056 toolbar, r.getClass().getName(), action.getClass().getName())); 1058 1057 } 1059 actions .put(toolbar, action);1058 actionsInMenu.put(toolbar, action); 1060 1059 } 1061 1060 } else { 1062 1061 userObject = menuItem.getText(); … … 1064 1063 } 1065 1064 DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(userObject); 1066 1065 node.add(newNode); 1067 loadAction(newNode, item );1066 loadAction(newNode, item, actionsInMenu); 1068 1067 } 1069 1068 } 1070 1069 1071 private void loadActions( ) {1070 private void loadActions(Map<String, Action> actionsInMenu ) { 1072 1071 rootActionsNode.removeAllChildren(); 1073 loadAction(rootActionsNode, MainApplication.getMenu() );1072 loadAction(rootActionsNode, MainApplication.getMenu(), actionsInMenu); 1074 1073 for (Map.Entry<String, Action> a : regactions.entrySet()) { 1075 if (actions .get(a.getKey()) == null) {1074 if (actionsInMenu.get(a.getKey()) == null) { 1076 1075 rootActionsNode.add(new DefaultMutableTreeNode(a.getValue())); 1077 1076 } 1078 1077 } … … 1097 1096 } 1098 1097 1099 1098 private Collection<ActionDefinition> getDefinedActions() { 1100 loadActions();1099 Map<String, Action> actionsInMenu = new ConcurrentHashMap<>(); 1101 1100 1101 loadActions(actionsInMenu); 1102 1102 1103 Map<String, Action> allActions = new ConcurrentHashMap<>(regactions); 1103 allActions.putAll(actions );1104 allActions.putAll(actionsInMenu); 1104 1105 ActionParser actionParser = new ActionParser(allActions); 1105 1106 1106 1107 Collection<ActionDefinition> result = new ArrayList<>(); … … 1139 1140 } 1140 1141 } 1141 1142 if (toolbar != null) { 1142 actions.put(toolbar, action);1143 1143 regactions.put(toolbar, action); 1144 1144 } 1145 1145 return action; … … 1154 1154 public Action unregister(Action action) { 1155 1155 Object toolbar = action.getValue("toolbar"); 1156 1156 if (toolbar instanceof String) { 1157 actions.remove(toolbar);1158 1157 return regactions.remove(toolbar); 1159 1158 } 1160 1159 return null;
