Changeset 4596 in josm for trunk/src/org


Ignore:
Timestamp:
2011-11-15T21:00:55+01:00 (13 years ago)
Author:
jttt
Message:

Fix #5515 Shortcuts for activating and showing/hiding layers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r4595 r4596  
    9191
    9292        MultikeyActionsHandler.getInstance().addAction(instance.new ShowHideLayerAction(false));
     93        MultikeyActionsHandler.getInstance().addAction(instance.new ActivateLayerAction());
    9394    }
    9495
     
    238239        // -- activate action
    239240        activateLayerAction = new ActivateLayerAction();
     241        activateLayerAction.updateEnabledState();
    240242        adaptTo(activateLayerAction, selectionModel);
    241243
     
    618620     */
    619621
    620     public final class ActivateLayerAction extends AbstractAction implements IEnabledStateUpdating, MapView.LayerChangeListener{
     622    public final class ActivateLayerAction extends AbstractAction implements IEnabledStateUpdating, MapView.LayerChangeListener, MultikeyShortcutAction{
    621623        private  Layer layer;
    622624
     
    632634            putValue(SMALL_ICON, ImageProvider.get("dialogs", "activate"));
    633635            putValue(SHORT_DESCRIPTION, tr("Activate the selected layer"));
     636            putValue(ACCELERATOR_KEY, Shortcut.registerShortcut("core_multikey:activateLayer", "", 'A', Shortcut.GROUP_DIRECT, KeyEvent.SHIFT_DOWN_MASK + KeyEvent.ALT_DOWN_MASK).getKeyStroke());
    634637            putValue("help", HelpUtil.ht("/Dialog/LayerList#ActivateLayer"));
    635             updateEnabledState();
    636638        }
    637639
     
    644646                toActivate = model.getSelectedLayers().get(0);
    645647            }
     648            execute(toActivate);
     649        }
     650
     651        private void execute(Layer layer) {
    646652            // model is  going to be updated via LayerChangeListener
    647653            // and PropertyChangeEvents
    648             Main.map.mapView.setActiveLayer(toActivate);
    649             toActivate.setVisible(true);
     654            Main.map.mapView.setActiveLayer(layer);
     655            layer.setVisible(true);
    650656        }
    651657
     
    681687        public void layerRemoved(Layer oldLayer) {
    682688            updateEnabledState();
     689        }
     690
     691        @Override
     692        public void executeMultikeyAction(int index) {
     693            Layer l = LayerListDialog.getLayerForIndex(index);
     694            if (l != null) {
     695                execute(l);
     696            }
     697        }
     698
     699        @Override
     700        public void repeateLastMultikeyAction() {
     701            // Do nothing, repating not supported
     702        }
     703
     704        @Override
     705        public List<MultikeyInfo> getMultikeyCombinations() {
     706            return LayerListDialog.getLayerInfoByClass(Layer.class);
     707        }
     708
     709        @Override
     710        public MultikeyInfo getLastMultikeyAction() {
     711            return null; // Repeating action doesn't make much sense for activating
    683712        }
    684713    }
Note: See TracChangeset for help on using the changeset viewer.