- Timestamp:
- 2017-02-25T13:56:45+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java
r11348 r11610 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.actions.JosmAction; 21 22 import org.openstreetmap.josm.data.osm.Relation; 22 23 import org.openstreetmap.josm.gui.DefaultNameFormatter; 23 24 import org.openstreetmap.josm.gui.SideButton; 24 25 import 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;31 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 32 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; … … 36 31 /** 37 32 * Action for accessing recent relations. 33 * @since 9668 38 34 */ 39 public class RecentRelationsAction implements ActionListener, CommandQueueListener, LayerChangeListener, ActiveLayerChangeListener {35 public class RecentRelationsAction extends JosmAction implements ActionListener, CommandQueueListener { 40 36 41 37 private final SideButton editButton; 42 38 private final BasicArrowButton arrow; 43 39 private final Shortcut shortcut; 40 private final LaunchEditorAction launchAction; 44 41 45 42 /** … … 48 45 */ 49 46 public RecentRelationsAction(SideButton editButton) { 47 super(RecentRelationsAction.class.getName(), null, null, null, false, true); 50 48 this.editButton = editButton; 51 49 arrow = editButton.createArrow(this); 52 50 arrow.setToolTipText(tr("List of recent relations")); 53 51 Main.main.undoRedo.addCommandQueueListener(this); 54 Main.getLayerManager().addLayerChangeListener(this);55 Main.getLayerManager().addActiveLayerChangeListener(this);56 52 enableArrow(); 57 53 shortcut = Shortcut.registerShortcut( … … 61 57 Shortcut.SHIFT 62 58 ); 63 Main.registerActionShortcut(new LaunchEditorAction(), shortcut); 59 launchAction = new LaunchEditorAction(); 60 Main.registerActionShortcut(launchAction, shortcut); 64 61 } 65 62 … … 68 65 */ 69 66 public void enableArrow() { 70 arrow.setVisible(getLastRelation() != null); 67 if (arrow != null) { 68 arrow.setVisible(getLastRelation() != null); 69 } 71 70 } 72 71 … … 109 108 110 109 @Override 111 p ublic void layerAdded(LayerAddEvent e) {110 protected void updateEnabledState() { 112 111 enableArrow(); 113 112 } 114 113 115 114 @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(); 128 118 } 129 119 … … 143 133 } 144 134 145 protectedstatic class LaunchEditorAction extends AbstractAction {135 static class LaunchEditorAction extends AbstractAction { 146 136 @Override 147 137 public void actionPerformed(ActionEvent e) { … … 150 140 } 151 141 152 protectedstatic class RecentRelationsPopupMenu extends JPopupMenu {142 static class RecentRelationsPopupMenu extends JPopupMenu { 153 143 /** 154 144 * Constructs a new {@code RecentRelationsPopupMenu}. … … 156 146 * @param keystroke key stroke for the first menu item 157 147 */ 158 publicRecentRelationsPopupMenu(List<Relation> recentRelations, KeyStroke keystroke) {148 RecentRelationsPopupMenu(List<Relation> recentRelations, KeyStroke keystroke) { 159 149 boolean first = true; 160 150 for (Relation relation: recentRelations) { … … 171 161 } 172 162 173 protectedstatic void launch(Component parent, KeyStroke keystroke) {163 static void launch(Component parent, KeyStroke keystroke) { 174 164 Rectangle r = parent.getBounds(); 175 165 new RecentRelationsPopupMenu(getRecentRelationsOnActiveLayer(), keystroke).show(parent, r.x, r.y + r.height); … … 180 170 * A specialized {@link JMenuItem} for presenting one entry of the relation history 181 171 */ 182 protectedstatic class RecentRelationsMenuItem extends JMenuItem implements ActionListener {183 pr otectedfinal transient Relation relation;172 static class RecentRelationsMenuItem extends JMenuItem implements ActionListener { 173 private final transient Relation relation; 184 174 185 publicRecentRelationsMenuItem(Relation relation) {175 RecentRelationsMenuItem(Relation relation) { 186 176 super(relation.getDisplayName(DefaultNameFormatter.getInstance())); 187 177 this.relation = relation; … … 194 184 } 195 185 } 196 197 186 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r11386 r11610 189 189 @Override 190 190 public void destroy() { 191 recentRelationsAction.destroy(); 191 192 model.clear(); 192 193 super.destroy(); 193 194 } 194 195 196 /** 197 * Enable the "recent relations" dropdown menu next to edit button. 198 */ 195 199 public void enableRecentRelations() { 196 200 recentRelationsAction.enableArrow();
Note:
See TracChangeset
for help on using the changeset viewer.