Changeset 208 in josm
- Timestamp:
- 2007-04-04T11:31:50+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r207 r208 136 136 if (map.mapView.editLayer != null) 137 137 map.mapView.editLayer.listenerCommands.add(redoUndoListener); 138 } 138 } else 139 old.destroy(); 139 140 redoUndoListener.commandChanged(0,0); 140 141 -
src/org/openstreetmap/josm/actions/JosmAction.java
r178 r208 7 7 8 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.tools.Destroyable; 9 10 import org.openstreetmap.josm.tools.ImageProvider; 10 11 import org.openstreetmap.josm.tools.ShortCutLabel; … … 12 13 /** 13 14 * Base class helper for all Actions in JOSM. Just to make the life easier. 15 * 16 * destroy() from interface Destroyable is called e.g. for MapModes, when the last layer has 17 * been removed and so the mapframe will be destroyed. For other JosmActions, destroy() may never 18 * be called (currently). 19 * 14 20 * @author imi 15 21 */ 16 abstract public class JosmAction extends AbstractAction { 22 abstract public class JosmAction extends AbstractAction implements Destroyable { 23 24 private KeyStroke shortCut; 17 25 18 26 public JosmAction(String name, String iconName, String tooltip, int shortCut, int modifier, boolean register) { … … 20 28 setHelpId(); 21 29 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+" <font size='-2'>"+ShortCutLabel.name(shortCut, modifier)+"</font> </html>"); 22 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(shortCut, modifier), name); 30 this.shortCut = KeyStroke.getKeyStroke(shortCut, modifier); 31 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(this.shortCut, name); 23 32 Main.contentPane.getActionMap().put(name, this); 24 33 putValue("toolbar", iconName); … … 27 36 } 28 37 38 public void destroy() { 39 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(shortCut); 40 Main.contentPane.getActionMap().remove(shortCut); 41 } 42 29 43 public JosmAction() { 30 44 setHelpId(); -
src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r198 r208 58 58 */ 59 59 public void actionPerformed(ActionEvent e) { 60 Main.map.selectMapMode(this); 60 if (Main.map != null) 61 Main.map.selectMapMode(this); 61 62 } 62 63 -
src/org/openstreetmap/josm/gui/MapFrame.java
r205 r208 33 33 import org.openstreetmap.josm.gui.dialogs.SelectionListDialog; 34 34 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 35 import org.openstreetmap.josm.tools.Destroyable; 35 36 36 37 /** … … 40 41 * @author imi 41 42 */ 42 public class MapFrame extends JPanel { 43 public class MapFrame extends JPanel implements Destroyable { 43 44 44 45 /** … … 135 136 } 136 137 138 /** 139 * Called as some kind of destructor when the last layer has been removed. 140 * Delegates the call to all Destroyables within this component (e.g. MapModes) 141 */ 142 public void destroy() { 143 for (int i = 0; i < toolBarActions.getComponentCount(); ++i) 144 if (toolBarActions.getComponent(i) instanceof Destroyable) 145 ((Destroyable)toolBarActions).destroy(); 146 } 147 137 148 public Action getDefaultButtonAction() { 138 149 return ((AbstractButton)toolBarActions.getComponent(0)).getAction(); -
src/org/openstreetmap/josm/gui/layer/Layer.java
r198 r208 9 9 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 10 10 import org.openstreetmap.josm.gui.MapView; 11 import org.openstreetmap.josm.tools.Destroyable; 11 12 12 13 /** … … 25 26 * @author imi 26 27 */ 27 abstract public class Layer { 28 abstract public class Layer implements Destroyable { 28 29 29 30 /** -
src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r178 r208 252 252 } 253 253 254 /** 255 * Parse the toolbar preference setting and construct the toolbar GUI control. 256 * 257 * Call this, if anything has changed in the toolbar settings and you want to refresh 258 * the toolbar content (e.g. after registering actions in a plugin) 259 */ 254 260 public void refreshToolbarControl() { 255 261 control.removeAll();
Note:
See TracChangeset
for help on using the changeset viewer.