- Timestamp:
- 2016-06-20T00:06:54+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r10421 r10432 62 62 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 63 63 import org.openstreetmap.josm.actions.mapmode.DrawAction; 64 import org.openstreetmap.josm.actions.mapmode.MapMode;65 64 import org.openstreetmap.josm.actions.search.SearchAction; 66 65 import org.openstreetmap.josm.data.Bounds; … … 80 79 import org.openstreetmap.josm.gui.GettingStarted; 81 80 import org.openstreetmap.josm.gui.MainApplication.Option; 81 import org.openstreetmap.josm.gui.MainFrame; 82 82 import org.openstreetmap.josm.gui.MainMenu; 83 import org.openstreetmap.josm.gui.MainPanel; 83 84 import org.openstreetmap.josm.gui.MapFrame; 84 85 import org.openstreetmap.josm.gui.MapFrameListener; 85 import org.openstreetmap.josm.gui.MapView;86 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;87 86 import org.openstreetmap.josm.gui.help.HelpUtil; 88 87 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 89 88 import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer; 90 89 import org.openstreetmap.josm.gui.layer.Layer; 91 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;92 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;93 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;94 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;95 90 import org.openstreetmap.josm.gui.layer.MainLayerManager; 96 91 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 195 190 * <p> 196 191 * There should be no need to access this to access any map data. Use {@link #layerManager} instead. 192 * 193 * @see MainPanel 197 194 */ 198 195 public static MapFrame map; … … 236 233 /** 237 234 * The MOTD Layer. 238 * /239 public final GettingStarted gettingStarted = new GettingStarted();240 241 p rivate static final Collection<MapFrameListener> mapFrameListeners = new ArrayList<>();235 * @deprecated Do not access this. It will be removed soon. You should not need to access the GettingStarted panel. 236 */ 237 @Deprecated 238 public final GettingStarted gettingStarted = mainPanel.getGettingStarted(); 242 239 243 240 protected static final Map<String, Throwable> NETWORK_ERRORS = new HashMap<>(); … … 253 250 */ 254 251 public static int logLevel = 3; 252 253 /** 254 * The real main panel. This field may be removed any time and made private to {@link MainFrame} 255 * @see #panel 256 */ 257 protected static final MainPanel mainPanel = new MainPanel(getLayerManager()); 255 258 256 259 private static void rememberWarnErrorMsg(String msg) { … … 548 551 /** 549 552 * Set or clear (if passed <code>null</code>) the map. 553 * <p> 554 * To be removed any time 550 555 * @param map The map to set {@link Main#map} to. Can be null. 551 */ 556 * @deprecated This is done automatically by {@link MainPanel} 557 */ 558 @Deprecated 552 559 public final void setMapFrame(final MapFrame map) { 553 MapFrame old = Main.map; 554 panel.setVisible(false); 555 panel.removeAll(); 556 if (map != null) { 557 map.fillPanel(panel); 558 } else { 559 old.destroy(); 560 panel.add(gettingStarted, BorderLayout.CENTER); 561 } 562 panel.setVisible(true); 563 redoUndoListener.commandChanged(0, 0); 564 565 Main.map = map; 566 567 // Notify map frame listeners, mostly plugins. 568 if ((map == null) == (old == null)) { 569 Main.warn("Replacing the map frame. This is not expected by some plugins and should not happen."); 570 } 571 for (MapFrameListener listener : mapFrameListeners) { 572 MapView.fireDeprecatedListenerOnAdd = true; 573 listener.mapFrameInitialized(old, map); 574 MapView.fireDeprecatedListenerOnAdd = false; 575 } 576 if (map == null && currentProgressMonitor != null) { 577 currentProgressMonitor.showForegroundDialog(); 578 } 560 Main.warn("setMapFrame call was ignored."); 579 561 } 580 562 … … 582 564 * Remove the specified layer from the map. If it is the last layer, 583 565 * remove the map as well. 566 * <p> 567 * To be removed end of 2016 584 568 * @param layer The layer to remove 585 */ 569 * @deprecated You can remove the layer using {@link #getLayerManager()} 570 */ 571 @Deprecated 586 572 public final synchronized void removeLayer(final Layer layer) { 587 573 if (map != null) { 588 574 getLayerManager().removeLayer(layer); 589 if (isDisplayingMapView() && getLayerManager().getLayers().isEmpty()) {590 setMapFrame(null);591 }592 575 } 593 576 } … … 613 596 public Main() { 614 597 main = this; 615 getLayerManager().addLayerChangeListener(new LayerChangeListener() {598 mainPanel.addAndFireMapFrameListener(new MapFrameListener() { 616 599 @Override 617 public void layerAdded(LayerAddEvent e) { 618 Layer layer = e.getAddedLayer(); 619 if (map == null) { 620 Main.main.createMapFrame(layer, null); 621 Main.map.setVisible(true); 622 } 623 ProjectionBounds viewProjectionBounds = layer.getViewProjectionBounds(); 624 if (viewProjectionBounds != null) { 625 Main.map.mapView.scheduleZoomTo(new ViewportData(viewProjectionBounds)); 626 } 627 } 628 629 @Override 630 public void layerRemoving(LayerRemoveEvent e) { 631 // empty 632 } 633 634 @Override 635 public void layerOrderChanged(LayerOrderChangeEvent e) { 636 //empty 637 } 638 600 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 601 redoUndoListener.commandChanged(0, 0); 602 } 639 603 }); 640 604 } … … 836 800 * 837 801 * If no map exists, create one. 802 * <p> 803 * To be removed end of 2016 838 804 * 839 805 * @param layer the layer … … 841 807 * @see #addLayer(Layer, ProjectionBounds) 842 808 * @see #addLayer(Layer, ViewportData) 843 */ 809 * @deprecated You can add the layer to the layer manager: {@link #getLayerManager()} 810 */ 811 @Deprecated 844 812 public final void addLayer(final Layer layer) { 845 addLayer(layer, layer.getViewProjectionBounds());813 addLayer(layer, (ViewportData) null); 846 814 } 847 815 … … 869 837 public final void addLayer(Layer layer, ViewportData viewport) { 870 838 getLayerManager().addLayer(layer); 871 if (viewport != null) { 839 if (viewport != null && Main.map.mapView != null) { 840 // MapView may be null in headless mode here. 872 841 Main.map.mapView.scheduleZoomTo(viewport); 873 842 } … … 876 845 /** 877 846 * Creates the map frame. Call only in EDT Thread. 847 * <p> 848 * To be removed any time 878 849 * @param firstLayer The first layer that was added. 879 850 * @param viewportData The initial viewport. Can be <code>null</code> to be automatically computed. 880 */ 851 * @deprecated Not supported. MainPanel does this automatically. 852 */ 853 @Deprecated 881 854 public synchronized void createMapFrame(Layer firstLayer, ViewportData viewportData) { 882 855 GuiHelper.assertCallFromEdt(); 883 MapFrame mapFrame = new MapFrame(contentPanePrivate, viewportData); 884 setMapFrame(mapFrame); 885 if (firstLayer != null) { 886 mapFrame.selectMapMode((MapMode) mapFrame.getDefaultButtonAction(), firstLayer); 887 } 888 mapFrame.initializeDialogsPane(); 889 // bootstrapping problem: make sure the layer list dialog is going to 890 // listen to change events of the very first layer 891 // 892 if (firstLayer != null) { 893 firstLayer.addPropertyChangeListener(LayerListDialog.getInstance().getModel()); 894 } 856 Main.error("createMapFrame() not supported any more."); 895 857 } 896 858 897 859 /** 898 860 * Replies <code>true</code> if there is an edit layer 861 * <p> 862 * To be removed end of 2016 899 863 * 900 864 * @return <code>true</code> if there is an edit layer 901 */ 865 * @deprecated You can get the edit layer using the layer manager and then check if it is not null: {@link #getLayerManager()} 866 */ 867 @Deprecated 902 868 public boolean hasEditLayer() { 903 869 if (getEditLayer() == null) return false; … … 907 873 /** 908 874 * Replies the current edit layer 875 * <p> 876 * To be removed end of 2016 909 877 * 910 878 * @return the current edit layer. <code>null</code>, if no current edit layer exists 911 */ 879 * @deprecated You can get the edit layer using the layer manager: {@link #getLayerManager()} 880 */ 881 @Deprecated 912 882 public OsmDataLayer getEditLayer() { 913 if (!isDisplayingMapView()) return null;914 883 return getLayerManager().getEditLayer(); 915 884 } … … 917 886 /** 918 887 * Replies the current data set. 888 * <p> 889 * To be removed end of 2016 919 890 * 920 891 * @return the current data set. <code>null</code>, if no current data set exists 921 */ 892 * @deprecated You can get the data set using the layer manager: {@link #getLayerManager()} 893 */ 894 @Deprecated 922 895 public DataSet getCurrentDataSet() { 923 if (!hasEditLayer()) return null; 924 return getEditLayer().data; 896 return getLayerManager().getEditDataSet(); 925 897 } 926 898 … … 946 918 /** 947 919 * Returns the currently active layer 920 * <p> 921 * To be removed end of 2016 948 922 * 949 923 * @return the currently active layer. <code>null</code>, if currently no active layer exists 950 */ 924 * @deprecated You can get the layer using the layer manager: {@link #getLayerManager()} 925 */ 926 @Deprecated 951 927 public Layer getActiveLayer() { 952 if (!isDisplayingMapView()) return null;953 928 return getLayerManager().getActiveLayer(); 954 929 } … … 1015 990 * Global panel. 1016 991 */ 1017 public static final JPanel panel = new JPanel(new BorderLayout());992 public static final JPanel panel = mainPanel; 1018 993 1019 994 private final CommandQueueListener redoUndoListener = new CommandQueueListener() { … … 1201 1176 } 1202 1177 // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask) 1203 if (Main.isDisplayingMapView()) { 1204 Collection<Layer> layers = new ArrayList<>(getLayerManager().getLayers()); 1205 for (Layer l: layers) { 1206 Main.main.removeLayer(l); 1207 } 1208 } 1178 getLayerManager().resetState(); 1209 1179 try { 1210 1180 pref.saveDefaults(); … … 1692 1662 */ 1693 1663 public static boolean addMapFrameListener(MapFrameListener listener, boolean fireWhenMapViewPresent) { 1694 boolean changed = listener != null && mapFrameListeners.add(listener);1695 if (fireWhenMapViewPresent && changed && map != null) {1696 listener.mapFrameInitialized(null, map);1697 }1698 return changed;1664 if (fireWhenMapViewPresent) { 1665 return mainPanel.addAndFireMapFrameListener(listener); 1666 } else { 1667 return mainPanel.addMapFrameListener(listener); 1668 } 1699 1669 } 1700 1670 … … 1706 1676 */ 1707 1677 public static boolean addMapFrameListener(MapFrameListener listener) { 1708 return addMapFrameListener(listener, false);1678 return mainPanel.addMapFrameListener(listener); 1709 1679 } 1710 1680 … … 1716 1686 */ 1717 1687 public static boolean removeMapFrameListener(MapFrameListener listener) { 1718 return listener != null && mapFrameListeners.remove(listener);1688 return mainPanel.removeMapFrameListener(listener); 1719 1689 } 1720 1690 -
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r10318 r10432 125 125 private void addLayers() { 126 126 if (layers != null && !layers.isEmpty()) { 127 Layer firstLayer = layers.get(0);128 127 boolean noMap = Main.map == null; 129 if (noMap) {130 Main.main.createMapFrame(firstLayer, viewport);131 }132 128 for (Layer l : layers) { 133 129 if (canceled) 134 130 return; 135 Main. main.addLayer(l, (ViewportData) null);131 Main.getLayerManager().addLayer(l); 136 132 } 137 133 if (active != null) { … … 139 135 } 140 136 if (noMap) { 141 Main.map. setVisible(true);137 Main.map.mapView.scheduleZoomTo(viewport); 142 138 } 143 139 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r10318 r10432 13 13 import org.openstreetmap.josm.data.Bounds; 14 14 import org.openstreetmap.josm.data.Bounds.ParseMethod; 15 import org.openstreetmap.josm.data.ViewportData; 15 16 import org.openstreetmap.josm.data.gpx.GpxData; 16 17 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 141 142 if (layer == null) return null; 142 143 if (newLayer || mergeLayer == null) { 143 if (Main.main != null) { 144 Main.main.addLayer(layer); 145 } 144 Main.getLayerManager().addLayer(layer); 146 145 return layer; 147 146 } else { 148 147 mergeLayer.mergeFrom(layer); 148 mergeLayer.invalidate(); 149 149 if (Main.map != null) { 150 Main.map. repaint();150 Main.map.mapView.scheduleZoomTo(new ViewportData(layer.getViewProjectionBounds())); 151 151 } 152 152 return mergeLayer; -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r10378 r10432 317 317 initApplicationPreferences(); 318 318 319 // Can only be called after preferences are initialized. 320 // We can move this to MainPanel constructor as soon as noone depends on Main#panel any more. 321 GuiHelper.runInEDTAndWait(new Runnable() { 322 @Override 323 public void run() { 324 mainPanel.updateContent(); 325 } 326 }); 327 319 328 Policy.setPolicy(new Policy() { 320 329 // Permissions for plug-ins loaded when josm is started via webstart … … 399 408 args.containsKey(Option.GEOMETRY) ? args.get(Option.GEOMETRY).iterator().next() : null, 400 409 !args.containsKey(Option.NO_MAXIMIZE) && Main.pref.getBoolean("gui.maximized", false)); 401 final MainFrame mainFrame = new MainFrame(contentPanePrivate, geometry);410 final MainFrame mainFrame = new MainFrame(contentPanePrivate, mainPanel, geometry); 402 411 Main.parent = mainFrame; 403 412 -
trunk/src/org/openstreetmap/josm/gui/MainFrame.java
r10345 r10432 40 40 */ 41 41 public class MainFrame extends JFrame { 42 protected transient WindowGeometry geometry;43 protected int windowState = JFrame.NORMAL;44 private MainMenu menu;45 46 42 private final transient LayerStateChangeListener updateTitleOnLayerStateChange = new LayerStateChangeListener() { 47 43 @Override … … 52 48 53 49 private final transient PropertyChangeListener updateTitleOnSaveChange = new PropertyChangeListener() { 54 55 50 @Override 56 51 public void propertyChange(PropertyChangeEvent evt) { … … 63 58 }; 64 59 60 protected transient WindowGeometry geometry; 61 protected int windowState = JFrame.NORMAL; 62 private MainMenu menu; 63 65 64 /** 66 65 * Create a new main window. 67 66 */ 68 67 public MainFrame() { 69 this(new JPanel(), new WindowGeometry(new Rectangle(10, 10, 500, 500)));70 } 71 72 /** 73 * Create a new main window. 68 this(new JPanel(), new MainPanel(Main.getLayerManager()), new WindowGeometry(new Rectangle(10, 10, 500, 500))); 69 } 70 71 /** 72 * Create a new main window. The parameters will be removed in the future. 74 73 * @param contentPanePrivate The content 74 * @param mainPanel The main panel. 75 75 * @param geometry The inital geometry to use. 76 76 */ 77 public MainFrame(Container contentPanePrivate, WindowGeometry geometry) {77 public MainFrame(Container contentPanePrivate, MainPanel mainPanel, WindowGeometry geometry) { 78 78 super(); 79 79 this.geometry = geometry; … … 120 120 121 121 getContentPane().add(Main.panel, BorderLayout.CENTER); 122 Main.panel.add(Main.main.gettingStarted, BorderLayout.CENTER);123 122 menu.initialize(); 124 123 } -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r10395 r10432 188 188 /** 189 189 * Constructs a new {@code MapFrame}. 190 * @param contentPane The content pane used to register shortcuts in its 191 * {@link javax.swing.InputMap} and {@link javax.swing.ActionMap} 190 * @param contentPane Ignored. Main content pane is used. 192 191 * @param viewportData the initial viewport of the map. Can be null, then 193 192 * the viewport is derived from the layer data. -
trunk/src/org/openstreetmap/josm/gui/MapMover.java
r10217 r10432 11 11 import java.awt.event.MouseEvent; 12 12 import java.awt.event.MouseWheelEvent; 13 import java.util.ArrayList; 13 14 14 15 import javax.swing.AbstractAction; 15 import javax.swing.ActionMap;16 import javax.swing.InputMap;17 import javax.swing.JComponent;18 16 import javax.swing.JPanel; 19 import javax.swing.KeyStroke;20 17 21 18 import org.openstreetmap.gui.jmapviewer.JMapViewer; … … 27 24 import org.openstreetmap.josm.data.preferences.BooleanProperty; 28 25 import org.openstreetmap.josm.tools.Destroyable; 26 import org.openstreetmap.josm.tools.Pair; 29 27 import org.openstreetmap.josm.tools.Shortcut; 30 28 … … 64 62 65 63 ZoomerAction(String action) { 64 this(action, "MapMover.Zoomer." + action); 65 } 66 67 /** 68 * Constructs a new {@code ZoomerAction}. 69 * @param action action 70 * @param name name 71 * @since 10432 72 */ 73 public ZoomerAction(String action, String name) { 66 74 this.action = action; 75 putValue(NAME, name); 67 76 } 68 77 … … 107 116 */ 108 117 private final NavigatableComponent nc; 109 private final JPanel contentPane;110 118 111 119 private boolean movementInPlace; 120 121 private final ArrayList<Pair<ZoomerAction, Shortcut>> registeredShortcuts = new ArrayList<>(); 112 122 113 123 /** 114 124 * Constructs a new {@code MapMover}. 115 125 * @param navComp the navigatable component 116 * @param contentPane the content pane126 * @param contentPane Ignored. The main action map is used. 117 127 */ 118 128 public MapMover(NavigatableComponent navComp, JPanel contentPane) { 119 129 this.nc = navComp; 120 this.contentPane = contentPane;121 130 nc.addMouseListener(this); 122 131 nc.addMouseMotionListener(this); 123 132 nc.addMouseWheelListener(this); 124 133 125 if (contentPane != null) { 126 // CHECKSTYLE.OFF: LineLength 127 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 128 Shortcut.registerShortcut("system:movefocusright", tr("Map: {0}", tr("Move right")), KeyEvent.VK_RIGHT, Shortcut.CTRL).getKeyStroke(), 129 "MapMover.Zoomer.right"); 130 contentPane.getActionMap().put("MapMover.Zoomer.right", new ZoomerAction("right")); 131 132 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 133 Shortcut.registerShortcut("system:movefocusleft", tr("Map: {0}", tr("Move left")), KeyEvent.VK_LEFT, Shortcut.CTRL).getKeyStroke(), 134 "MapMover.Zoomer.left"); 135 contentPane.getActionMap().put("MapMover.Zoomer.left", new ZoomerAction("left")); 136 137 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 138 Shortcut.registerShortcut("system:movefocusup", tr("Map: {0}", tr("Move up")), KeyEvent.VK_UP, Shortcut.CTRL).getKeyStroke(), 139 "MapMover.Zoomer.up"); 140 contentPane.getActionMap().put("MapMover.Zoomer.up", new ZoomerAction("up")); 141 142 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 143 Shortcut.registerShortcut("system:movefocusdown", tr("Map: {0}", tr("Move down")), KeyEvent.VK_DOWN, Shortcut.CTRL).getKeyStroke(), 144 "MapMover.Zoomer.down"); 145 contentPane.getActionMap().put("MapMover.Zoomer.down", new ZoomerAction("down")); 146 // CHECKSTYLE.ON: LineLength 147 148 // see #10592 - Disable these alternate shortcuts on OS X because of conflict with system shortcut 149 if (!Main.isPlatformOsx()) { 150 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 151 Shortcut.registerShortcut("view:zoominalternate", 152 tr("Map: {0}", tr("Zoom in")), KeyEvent.VK_COMMA, Shortcut.CTRL).getKeyStroke(), 153 "MapMover.Zoomer.in"); 154 contentPane.getActionMap().put("MapMover.Zoomer.in", new ZoomerAction(",")); 155 156 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 157 Shortcut.registerShortcut("view:zoomoutalternate", 158 tr("Map: {0}", tr("Zoom out")), KeyEvent.VK_PERIOD, Shortcut.CTRL).getKeyStroke(), 159 "MapMover.Zoomer.out"); 160 contentPane.getActionMap().put("MapMover.Zoomer.out", new ZoomerAction(".")); 161 } 162 } 134 registerActionShortcut(new ZoomerAction("right"), 135 Shortcut.registerShortcut("system:movefocusright", tr("Map: {0}", tr("Move right")), KeyEvent.VK_RIGHT, Shortcut.CTRL)); 136 137 registerActionShortcut(new ZoomerAction("left"), 138 Shortcut.registerShortcut("system:movefocusleft", tr("Map: {0}", tr("Move left")), KeyEvent.VK_LEFT, Shortcut.CTRL)); 139 140 registerActionShortcut(new ZoomerAction("up"), 141 Shortcut.registerShortcut("system:movefocusup", tr("Map: {0}", tr("Move up")), KeyEvent.VK_UP, Shortcut.CTRL)); 142 registerActionShortcut(new ZoomerAction("down"), 143 Shortcut.registerShortcut("system:movefocusdown", tr("Map: {0}", tr("Move down")), KeyEvent.VK_DOWN, Shortcut.CTRL)); 144 145 // see #10592 - Disable these alternate shortcuts on OS X because of conflict with system shortcut 146 if (!Main.isPlatformOsx()) { 147 registerActionShortcut(new ZoomerAction(",", "MapMover.Zoomer.in"), 148 Shortcut.registerShortcut("view:zoominalternate", tr("Map: {0}", tr("Zoom in")), KeyEvent.VK_COMMA, Shortcut.CTRL)); 149 150 registerActionShortcut(new ZoomerAction(".", "MapMover.Zoomer.out"), 151 Shortcut.registerShortcut("view:zoomoutalternate", tr("Map: {0}", tr("Zoom out")), KeyEvent.VK_PERIOD, Shortcut.CTRL)); 152 } 153 } 154 155 private void registerActionShortcut(ZoomerAction action, Shortcut shortcut) { 156 Main.registerActionShortcut(action, shortcut); 157 registeredShortcuts.add(new Pair<>(action, shortcut)); 163 158 } 164 159 … … 270 265 @Override 271 266 public void destroy() { 272 if (this.contentPane != null) { 273 InputMap inputMap = contentPane.getInputMap(); 274 KeyStroke[] inputKeys = inputMap.keys(); 275 if (inputKeys != null) { 276 for (KeyStroke key : inputKeys) { 277 Object binding = inputMap.get(key); 278 if (binding instanceof String && ((String) binding).startsWith("MapMover.")) { 279 inputMap.remove(key); 280 } 281 } 282 } 283 ActionMap actionMap = contentPane.getActionMap(); 284 Object[] actionsKeys = actionMap.keys(); 285 if (actionsKeys != null) { 286 for (Object key : actionsKeys) { 287 if (key instanceof String && ((String) key).startsWith("MapMover.")) { 288 actionMap.remove(key); 289 } 290 } 291 } 267 for (Pair<ZoomerAction, Shortcut> shortcut : registeredShortcuts) { 268 Main.unregisterActionShortcut(shortcut.a, shortcut.b); 292 269 } 293 270 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r10412 r10432 32 32 33 33 import javax.swing.AbstractButton; 34 import javax.swing.ActionMap;35 import javax.swing.InputMap;36 34 import javax.swing.JComponent; 37 35 import javax.swing.JPanel; … … 42 40 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 43 41 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 42 import org.openstreetmap.josm.data.ProjectionBounds; 44 43 import org.openstreetmap.josm.data.SelectionChangedListener; 45 44 import org.openstreetmap.josm.data.ViewportData; … … 495 494 * Constructs a new {@code MapView}. 496 495 * @param layerManager The layers to display. 497 * @param contentPane The content pane used to register shortcuts in its 498 * {@link InputMap} and {@link ActionMap} 496 * @param contentPane Ignored. Main content pane is used. 499 497 * @param viewportData the initial viewport of the map. Can be null, then 500 498 * the viewport is derived from the layer data. … … 598 596 if (layer instanceof MarkerLayer && playHeadMarker == null) { 599 597 playHeadMarker = PlayHeadMarker.create(); 598 } 599 600 ProjectionBounds viewProjectionBounds = layer.getViewProjectionBounds(); 601 if (viewProjectionBounds != null) { 602 scheduleZoomTo(new ViewportData(viewProjectionBounds)); 600 603 } 601 604 -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r10345 r10432 331 331 public void showNotify() { 332 332 layerManager.addActiveLayerChangeListener(activateLayerAction); 333 layerManager.addLayerChangeListener(model );333 layerManager.addLayerChangeListener(model, true); 334 334 layerManager.addAndFireActiveLayerChangeListener(model); 335 335 model.populate(); … … 338 338 @Override 339 339 public void hideNotify() { 340 layerManager.removeLayerChangeListener(model );340 layerManager.removeLayerChangeListener(model, true); 341 341 layerManager.removeActiveLayerChangeListener(model); 342 342 layerManager.removeActiveLayerChangeListener(activateLayerAction); -
trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java
r10391 r10432 90 90 public static class LayerRemoveEvent extends LayerManagerEvent { 91 91 private final Layer removedLayer; 92 private final boolean lastLayer; 92 93 93 94 LayerRemoveEvent(LayerManager source, Layer removedLayer) { 94 95 super(source); 95 96 this.removedLayer = removedLayer; 97 this.lastLayer = source.getLayers().size() == 1; 96 98 } 97 99 … … 102 104 public Layer getRemovedLayer() { 103 105 return removedLayer; 106 } 107 108 /** 109 * Check if the layer that was removed is the last layer in the list. 110 * @return <code>true</code> if this was the last layer. 111 * @since 10432 112 */ 113 public boolean isLastLayer() { 114 return lastLayer; 104 115 } 105 116 } … … 347 358 } 348 359 } 360 361 /** 362 * Reset all layer manager state. This includes removing all layers and then unregistering all listeners 363 * @since 10432 364 */ 365 public void resetState() { 366 // some layer remove listeners remove other layers. 367 while (!getLayers().isEmpty()) { 368 removeLayer(getLayers().get(0)); 369 } 370 371 layerChangeListeners.clear(); 372 } 349 373 } -
trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java
r10332 r10432 313 313 return ret; 314 314 } 315 316 @Override 317 public void resetState() { 318 // active and edit layer are unset automatically 319 super.resetState(); 320 321 activeLayerChangeListeners.clear(); 322 } 315 323 } -
trunk/src/org/openstreetmap/josm/io/NoteImporter.java
r10364 r10432 14 14 import org.openstreetmap.josm.gui.layer.NoteLayer; 15 15 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 16 import org.openstreetmap.josm.gui.util.GuiHelper;17 16 import org.xml.sax.SAXException; 18 17 … … 38 37 try (InputStream is = Compression.getUncompressedFileInputStream(file)) { 39 38 final NoteLayer layer = loadLayer(is, file, file.getName(), progressMonitor); 40 if (Main.map == null || !Main.getLayerManager().containsLayer(layer)) { 41 GuiHelper.runInEDT(new Runnable() { 42 @Override 43 public void run() { 44 Main.main.addLayer(layer); 45 } 46 }); 39 if (!Main.getLayerManager().containsLayer(layer)) { 40 Main.getLayerManager().addLayer(layer); 47 41 } 48 42 } catch (SAXException e) {
Note:
See TracChangeset
for help on using the changeset viewer.