Changeset 4999 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-02-19T18:49:37+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
r4982 r4999 337 337 EnableFilterAction() { 338 338 putValue(SHORT_DESCRIPTION, tr("Enable filter")); 339 ENABLE_FILTER_SHORTCUT.setAccelerator(this); 339 } 340 341 @Override 342 public Shortcut getMultikeyShortcut() { 343 return ENABLE_FILTER_SHORTCUT; 340 344 } 341 345 … … 356 360 public HidingFilterAction() { 357 361 putValue(SHORT_DESCRIPTION, tr("Hiding filter")); 358 HIDING_FILTER_SHORTCUT.setAccelerator(this); 362 } 363 364 @Override 365 public Shortcut getMultikeyShortcut() { 366 return HIDING_FILTER_SHORTCUT; 359 367 } 360 368 -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r4982 r4999 432 432 433 433 private WeakReference<Layer> lastLayer; 434 private Shortcut multikeyShortcut; 434 435 435 436 /** … … 442 443 putValue(SHORT_DESCRIPTION, tr("Toggle visible state of the selected layer.")); 443 444 putValue("help", HelpUtil.ht("/Dialog/LayerList#ShowHideLayer")); 444 Shortcut.registerShortcut("core_multikey:showHideLayer", tr("Multikey: {0}",445 tr("Show/hide layer")), KeyEvent.VK_S, Shortcut.SHIFT) .setAccelerator(this);445 multikeyShortcut = Shortcut.registerShortcut("core_multikey:showHideLayer", tr("Multikey: {0}", 446 tr("Show/hide layer")), KeyEvent.VK_S, Shortcut.SHIFT); 446 447 if (init) { 447 448 updateEnabledState(); … … 451 452 public ShowHideLayerAction() { 452 453 this(true); 454 } 455 456 @Override 457 public Shortcut getMultikeyShortcut() { 458 return multikeyShortcut; 453 459 } 454 460 … … 618 624 public final class ActivateLayerAction extends AbstractAction implements IEnabledStateUpdating, MapView.LayerChangeListener, MultikeyShortcutAction{ 619 625 private Layer layer; 626 private Shortcut multikeyShortcut; 620 627 621 628 public ActivateLayerAction(Layer layer) { … … 630 637 putValue(SMALL_ICON, ImageProvider.get("dialogs", "activate")); 631 638 putValue(SHORT_DESCRIPTION, tr("Activate the selected layer")); 632 Shortcut.registerShortcut("core_multikey:activateLayer", tr("Multikey: {0}",633 tr("Activate layer")), KeyEvent.VK_A, Shortcut.SHIFT) .setAccelerator(this);639 multikeyShortcut = Shortcut.registerShortcut("core_multikey:activateLayer", tr("Multikey: {0}", 640 tr("Activate layer")), KeyEvent.VK_A, Shortcut.SHIFT); 634 641 putValue("help", HelpUtil.ht("/Dialog/LayerList#ActivateLayer")); 642 } 643 644 @Override 645 public Shortcut getMultikeyShortcut() { 646 return multikeyShortcut; 635 647 } 636 648 -
trunk/src/org/openstreetmap/josm/gui/layer/JumpToMarkerActions.java
r4982 r4999 32 32 private final Layer layer; 33 33 private WeakReference<Layer> lastLayer; 34 private Shortcut multikeyShortcut; 34 35 35 36 public JumpToNextMarker(JumpToMarkerLayer layer) { 36 Shortcut.registerShortcut("core_multikey:nextMarker", tr("Multikey: {0}", tr("Next marker")),37 KeyEvent.VK_J, Shortcut.ALT_CTRL) .setAccelerator(this);37 multikeyShortcut = Shortcut.registerShortcut("core_multikey:nextMarker", tr("Multikey: {0}", tr("Next marker")), 38 KeyEvent.VK_J, Shortcut.ALT_CTRL); 38 39 putValue(SHORT_DESCRIPTION, tr("Jump to next marker")); 39 40 putValue(NAME, tr("Jump to next marker")); 40 41 41 42 this.layer = (Layer)layer; 43 } 44 45 @Override 46 public Shortcut getMultikeyShortcut() { 47 return multikeyShortcut; 42 48 } 43 49 … … 86 92 private WeakReference<Layer> lastLayer; 87 93 private final Layer layer; 94 private Shortcut multikeyShortcut; 88 95 89 96 public JumpToPreviousMarker(JumpToMarkerLayer layer) { … … 94 101 putValue(SHORT_DESCRIPTION, tr("Jump to previous marker")); 95 102 putValue(NAME, tr("Jump to previous marker")); 103 } 104 105 @Override 106 public Shortcut getMultikeyShortcut() { 107 return multikeyShortcut; 96 108 } 97 109 -
trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java
r4753 r4999 24 24 import org.openstreetmap.josm.Main; 25 25 import org.openstreetmap.josm.tools.MultikeyShortcutAction.MultikeyInfo; 26 import org.openstreetmap.josm.tools.Shortcut; 26 27 27 28 public class MultikeyActionsHandler { … … 40 41 int index = getIndex(e.getKeyCode()); 41 42 if (index >= 0) { 42 lastAction.action.executeMultikeyAction(index, e.getKeyCode() == lastAction.shortcut.getKey Code());43 lastAction.action.executeMultikeyAction(index, e.getKeyCode() == lastAction.shortcut.getKeyStroke().getKeyCode()); 43 44 } 44 45 lastAction = null; … … 64 65 65 66 final MultikeyShortcutAction action; 66 final KeyStrokeshortcut;67 final Shortcut shortcut; 67 68 68 69 MyAction(MultikeyShortcutAction action) { 69 70 this.action = action; 70 this.shortcut = (KeyStroke) action.getValue(ACCELERATOR_KEY);71 this.shortcut = action.getMultikeyShortcut(); 71 72 } 72 73 … … 102 103 } 103 104 } 104 105 105 } 106 106 … … 143 143 layers.add(pnTitle); 144 144 145 char repeatKey = (char) action.shortcut.getKey Code();145 char repeatKey = (char) action.shortcut.getKeyStroke().getKeyCode(); 146 146 boolean repeatKeyUsed = false; 147 147 … … 153 153 } 154 154 155 JMenuItem item = new JMenuItem(formatMenuText(action.shortcut , String.valueOf(info.getShortcut()), info.getDescription()));155 JMenuItem item = new JMenuItem(formatMenuText(action.shortcut.getKeyStroke(), String.valueOf(info.getShortcut()), info.getDescription())); 156 156 item.setMnemonic(info.getShortcut()); 157 157 item.addActionListener(new ActionListener() { … … 167 167 MultikeyInfo lastLayer = action.action.getLastMultikeyAction(); 168 168 if (lastLayer != null) { 169 JMenuItem repeateItem = new JMenuItem(formatMenuText(action.shortcut ,170 KeyEvent.getKeyText(action.shortcut.getKey Code()),169 JMenuItem repeateItem = new JMenuItem(formatMenuText(action.shortcut.getKeyStroke(), 170 KeyEvent.getKeyText(action.shortcut.getKeyStroke().getKeyCode()), 171 171 "Repeat " + lastLayer.getDescription())); 172 repeateItem.setMnemonic(action.shortcut.getKey Code());172 repeateItem.setMnemonic(action.shortcut.getKeyStroke().getKeyCode()); 173 173 repeateItem.addActionListener(new ActionListener() { 174 174 @Override … … 201 201 202 202 public void addAction(MultikeyShortcutAction action) { 203 if (!(action.getValue(Action.ACCELERATOR_KEY) instanceof KeyStroke)) 204 throw new IllegalArgumentException("Action must have shortcut set"); 205 MyAction myAction = new MyAction(action); 206 Main.registerActionShortcut(myAction, myAction.shortcut); 207 } 208 209 203 if(action.getMultikeyShortcut() != null) { 204 MyAction myAction = new MyAction(action); 205 Main.registerActionShortcut(myAction, myAction.shortcut); 206 } 207 } 210 208 } -
trunk/src/org/openstreetmap/josm/tools/MultikeyShortcutAction.java
r4604 r4999 35 35 } 36 36 37 public Shortcut getMultikeyShortcut(); 38 37 39 void executeMultikeyAction(int index, boolean repeatLastAction); 38 40 List<MultikeyInfo> getMultikeyCombinations();
Note:
See TracChangeset
for help on using the changeset viewer.