Changeset 6844 in josm for trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
- Timestamp:
- 2014-02-12T15:58:32+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r6838 r6844 469 469 * Value: The action to execute. 470 470 */ 471 private Map<String, Action> actions = new HashMap<String, Action>();472 private Map<String, Action> regactions = new HashMap<String, Action>();473 474 private DefaultMutableTreeNode rootActionsNode = new DefaultMutableTreeNode(tr("Actions"));471 private final Map<String, Action> actions = new HashMap<String, Action>(); 472 private final Map<String, Action> regactions = new HashMap<String, Action>(); 473 474 private final DefaultMutableTreeNode rootActionsNode = new DefaultMutableTreeNode(tr("Actions")); 475 475 476 476 public JToolBar control = new JToolBar(); 477 private Map<Object, ActionDefinition> buttonActions = new HashMap<Object, ActionDefinition>(30);477 private final Map<Object, ActionDefinition> buttonActions = new HashMap<Object, ActionDefinition>(30); 478 478 479 479 @Override … … 529 529 private class ActionTransferable implements Transferable { 530 530 531 private DataFlavor[] flavors = new DataFlavor[] { ACTION_FLAVOR };531 private final DataFlavor[] flavors = new DataFlavor[] { ACTION_FLAVOR }; 532 532 533 533 private final List<ActionDefinition> actions; … … 1056 1056 control.repaint(); 1057 1057 } 1058 1059 /** 1060 * The method to add custom button on toolbar like search or preset buttons 1061 * @param definitionText toolbar definition text to describe the new button, 1062 * must be carefully generated by using {@link ActionParser} 1063 * @param preferredIndex place to put the new button, give -1 for the end of toolbar 1064 * @param removeIfExists if true and the button already exists, remove it 1065 */ 1066 public void addCustomButton(String definitionText, int preferredIndex, boolean removeIfExists) { 1067 LinkedList<String> t = new LinkedList<String>(getToolString()); 1068 if (t.contains(definitionText)) { 1069 if (!removeIfExists) return; // do nothing 1070 t.remove(definitionText); 1071 } else { 1072 if (preferredIndex>=0 && preferredIndex < t.size()) { 1073 t.add(preferredIndex, definitionText); // add to specified place 1074 } else { 1075 t.add(definitionText); // add to the end 1076 } 1077 } 1078 Main.pref.putCollection("toolbar", t); 1079 Main.toolbar.refreshToolbarControl(); 1080 } 1058 1081 1059 1082 private JButton addButtonAndShortcut(ActionDefinition action) {
Note:
See TracChangeset
for help on using the changeset viewer.