Changeset 11610 in josm for trunk


Ignore:
Timestamp:
2017-02-25T13:56:45+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #13955 - Keystroke shift pressed ESCAPE is already assigned

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java

    r11348 r11610  
    1919
    2020import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.actions.JosmAction;
    2122import org.openstreetmap.josm.data.osm.Relation;
    2223import org.openstreetmap.josm.gui.DefaultNameFormatter;
    2324import org.openstreetmap.josm.gui.SideButton;
    2425import org.openstreetmap.josm.gui.layer.Layer;
    25 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    26 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
    27 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
    28 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    29 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    30 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    3126import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3227import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener;
     
    3631/**
    3732 * Action for accessing recent relations.
     33 * @since 9668
    3834 */
    39 public class RecentRelationsAction implements ActionListener, CommandQueueListener, LayerChangeListener, ActiveLayerChangeListener {
     35public class RecentRelationsAction extends JosmAction implements ActionListener, CommandQueueListener {
    4036
    4137    private final SideButton editButton;
    4238    private final BasicArrowButton arrow;
    4339    private final Shortcut shortcut;
     40    private final LaunchEditorAction launchAction;
    4441
    4542    /**
     
    4845     */
    4946    public RecentRelationsAction(SideButton editButton) {
     47        super(RecentRelationsAction.class.getName(), null, null, null, false, true);
    5048        this.editButton = editButton;
    5149        arrow = editButton.createArrow(this);
    5250        arrow.setToolTipText(tr("List of recent relations"));
    5351        Main.main.undoRedo.addCommandQueueListener(this);
    54         Main.getLayerManager().addLayerChangeListener(this);
    55         Main.getLayerManager().addActiveLayerChangeListener(this);
    5652        enableArrow();
    5753        shortcut = Shortcut.registerShortcut(
     
    6157            Shortcut.SHIFT
    6258        );
    63         Main.registerActionShortcut(new LaunchEditorAction(), shortcut);
     59        launchAction = new LaunchEditorAction();
     60        Main.registerActionShortcut(launchAction, shortcut);
    6461    }
    6562
     
    6865     */
    6966    public void enableArrow() {
    70         arrow.setVisible(getLastRelation() != null);
     67        if (arrow != null) {
     68            arrow.setVisible(getLastRelation() != null);
     69        }
    7170    }
    7271
     
    109108
    110109    @Override
    111     public void layerAdded(LayerAddEvent e) {
     110    protected void updateEnabledState() {
    112111        enableArrow();
    113112    }
    114113
    115114    @Override
    116     public void layerRemoving(LayerRemoveEvent e) {
    117         enableArrow();
    118     }
    119 
    120     @Override
    121     public void layerOrderChanged(LayerOrderChangeEvent e) {
    122         enableArrow();
    123     }
    124 
    125     @Override
    126     public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
    127         enableArrow();
     115    public void destroy() {
     116        Main.unregisterActionShortcut(launchAction, shortcut);
     117        super.destroy();
    128118    }
    129119
     
    143133    }
    144134
    145     protected static class LaunchEditorAction extends AbstractAction {
     135    static class LaunchEditorAction extends AbstractAction {
    146136        @Override
    147137        public void actionPerformed(ActionEvent e) {
     
    150140    }
    151141
    152     protected static class RecentRelationsPopupMenu extends JPopupMenu {
     142    static class RecentRelationsPopupMenu extends JPopupMenu {
    153143        /**
    154144         * Constructs a new {@code RecentRelationsPopupMenu}.
     
    156146         * @param keystroke key stroke for the first menu item
    157147         */
    158         public RecentRelationsPopupMenu(List<Relation> recentRelations, KeyStroke keystroke) {
     148        RecentRelationsPopupMenu(List<Relation> recentRelations, KeyStroke keystroke) {
    159149            boolean first = true;
    160150            for (Relation relation: recentRelations) {
     
    171161        }
    172162
    173         protected static void launch(Component parent, KeyStroke keystroke) {
     163        static void launch(Component parent, KeyStroke keystroke) {
    174164            Rectangle r = parent.getBounds();
    175165            new RecentRelationsPopupMenu(getRecentRelationsOnActiveLayer(), keystroke).show(parent, r.x, r.y + r.height);
     
    180170     * A specialized {@link JMenuItem} for presenting one entry of the relation history
    181171     */
    182     protected static class RecentRelationsMenuItem extends JMenuItem implements ActionListener {
    183         protected final transient Relation relation;
     172    static class RecentRelationsMenuItem extends JMenuItem implements ActionListener {
     173        private final transient Relation relation;
    184174
    185         public RecentRelationsMenuItem(Relation relation) {
     175        RecentRelationsMenuItem(Relation relation) {
    186176            super(relation.getDisplayName(DefaultNameFormatter.getInstance()));
    187177            this.relation = relation;
     
    194184        }
    195185    }
    196 
    197186}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r11386 r11610  
    189189    @Override
    190190    public void destroy() {
     191        recentRelationsAction.destroy();
    191192        model.clear();
    192193        super.destroy();
    193194    }
    194195
     196    /**
     197     * Enable the "recent relations" dropdown menu next to edit button.
     198     */
    195199    public void enableRecentRelations() {
    196200        recentRelationsAction.enableArrow();
Note: See TracChangeset for help on using the changeset viewer.