Changeset 6838 in josm
- Timestamp:
- 2014-02-11T14:27:58+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r6798 r6838 1054 1054 control.setFocusTraversalKeysEnabled(!unregisterTab); 1055 1055 control.setVisible(control.getComponentCount() != 0); 1056 control.repaint(); 1056 1057 } 1057 1058 -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r6835 r6838 24 24 import javax.swing.JLabel; 25 25 import javax.swing.JPanel; 26 import javax.swing.JToggleButton; 26 27 import javax.swing.SwingUtilities; 27 28 … … 42 43 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 43 44 import org.openstreetmap.josm.gui.layer.Layer; 45 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 44 46 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 45 47 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Link; … … 252 254 link.addToPanel(p, selected, presetInitiallyMatches); 253 255 } 254 256 257 // "Add toolbar button" 258 JToggleButton tb = new JToggleButton(new ToolbarButtonAction()); 259 tb.setFocusable(false); 260 p.add(tb, GBC.std(0,0).anchor(GBC.LINE_END)); 255 261 return p; 256 262 } … … 496 502 }); 497 503 } 504 505 /** 506 * Action that adds or removes the button on main toolbar 507 */ 508 public class ToolbarButtonAction extends AbstractAction { 509 private final int toolbarIndex; 510 public ToolbarButtonAction() { 511 super("", ImageProvider.get("styles\\standard\\waypoint","pin")); 512 putValue(SHORT_DESCRIPTION, tr("Add or remove toolbar button")); 513 LinkedList<String> t = new LinkedList<String>(ToolbarPreferences.getToolString()); 514 toolbarIndex = t.indexOf(getToolbarString()); 515 putValue(SELECTED_KEY, toolbarIndex >= 0); 516 } 517 518 @Override 519 public void actionPerformed(ActionEvent ae) { 520 String res = getToolbarString(); 521 LinkedList<String> t = new LinkedList<String>(ToolbarPreferences.getToolString()); 522 if (t.contains(res)) { 523 t.remove(res); 524 } else { 525 if (toolbarIndex>=0) { 526 t.add(toolbarIndex, res); // add to the old place 527 } else { 528 t.add(res); // add to the end 529 } 530 } 531 Main.pref.putCollection("toolbar", t); 532 Main.toolbar.refreshToolbarControl(); 533 } 534 } 535 536 public String getToolbarString() { 537 ToolbarPreferences.ActionDefinition aDef 538 = new ToolbarPreferences.ActionDefinition(this); 539 ToolbarPreferences.ActionParser actionParser = new ToolbarPreferences.ActionParser(null); 540 return actionParser.saveAction(aDef); 541 } 498 542 }
Note:
See TracChangeset
for help on using the changeset viewer.