-
diff --git a/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java b/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java
index fcd933e..707537d 100644
a
|
b
|
public class ExtensionFileFilter extends FileFilter implements java.io.FileFilte
|
107 | 107 | try { |
108 | 108 | FileExporter exporter = exporterClass.getConstructor().newInstance(); |
109 | 109 | exporters.add(exporter); |
110 | | MapView.addLayerChangeListener(exporter); |
| 110 | Main.getLayerManager().addAndFireActiveLayerChangeListener(exporter); |
111 | 111 | } catch (ReflectiveOperationException e) { |
112 | 112 | if (Main.isDebugEnabled()) { |
113 | 113 | Main.debug(e.getMessage()); |
-
diff --git a/src/org/openstreetmap/josm/actions/JosmAction.java b/src/org/openstreetmap/josm/actions/JosmAction.java
index 5e450aa..76686c9 100644
a
|
b
|
import org.openstreetmap.josm.Main;
|
15 | 15 | import org.openstreetmap.josm.data.SelectionChangedListener; |
16 | 16 | import org.openstreetmap.josm.data.osm.DataSet; |
17 | 17 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
18 | | import org.openstreetmap.josm.gui.MapView; |
19 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
20 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 18 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 19 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 20 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
21 | 21 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
22 | 22 | import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; |
23 | | import org.openstreetmap.josm.gui.util.GuiHelper; |
24 | 23 | import org.openstreetmap.josm.tools.Destroyable; |
25 | 24 | import org.openstreetmap.josm.tools.ImageProvider; |
26 | 25 | import org.openstreetmap.josm.tools.Shortcut; |
… |
… |
public abstract class JosmAction extends AbstractAction implements Destroyable {
|
183 | 182 | if (sc != null) { |
184 | 183 | Main.unregisterActionShortcut(this); |
185 | 184 | } |
186 | | MapView.removeLayerChangeListener(layerChangeAdapter); |
| 185 | if (layerChangeAdapter != null) { |
| 186 | Main.getLayerManager().removeActiveLayerChangeListener(layerChangeAdapter); |
| 187 | } |
187 | 188 | DataSet.removeSelectionListener(selectionChangeAdapter); |
188 | 189 | } |
189 | 190 | |
… |
… |
public abstract class JosmAction extends AbstractAction implements Destroyable {
|
225 | 226 | |
226 | 227 | protected void installAdapters() { |
227 | 228 | // make this action listen to layer change and selection change events |
228 | | // |
229 | 229 | layerChangeAdapter = new LayerChangeAdapter(); |
230 | 230 | selectionChangeAdapter = new SelectionChangeAdapter(); |
231 | | MapView.addLayerChangeListener(layerChangeAdapter); |
| 231 | Main.getLayerManager().addActiveLayerChangeListener(layerChangeAdapter); |
232 | 232 | DataSet.addSelectionListener(selectionChangeAdapter); |
233 | 233 | initEnabledState(); |
234 | 234 | } |
… |
… |
public abstract class JosmAction extends AbstractAction implements Destroyable {
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | | * Adapter for layer change events |
294 | | * |
| 293 | * Adapter for layer change events. Runs updateEnabledState() whenever the active layer changed. |
295 | 294 | */ |
296 | | protected class LayerChangeAdapter implements MapView.LayerChangeListener { |
297 | | private void updateEnabledStateInEDT() { |
298 | | GuiHelper.runInEDT(new Runnable() { |
299 | | @Override public void run() { |
300 | | updateEnabledState(); |
301 | | } |
302 | | }); |
303 | | } |
304 | | |
| 295 | protected class LayerChangeAdapter implements ActiveLayerChangeListener { |
305 | 296 | @Override |
306 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
307 | | updateEnabledStateInEDT(); |
| 297 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
| 298 | updateEnabledState(); |
308 | 299 | } |
309 | 300 | |
310 | 301 | @Override |
311 | | public void layerAdded(Layer newLayer) { |
312 | | updateEnabledStateInEDT(); |
313 | | } |
314 | | |
315 | | @Override |
316 | | public void layerRemoved(Layer oldLayer) { |
317 | | updateEnabledStateInEDT(); |
| 302 | public String toString() { |
| 303 | return "LayerChangeAdapter [" + JosmAction.this.toString() + "]"; |
318 | 304 | } |
319 | 305 | } |
320 | 306 | |
321 | 307 | /** |
322 | | * Adapter for selection change events |
| 308 | * Adapter for selection change events. Runs updateEnabledState() whenever the selection changed. |
323 | 309 | */ |
324 | 310 | protected class SelectionChangeAdapter implements SelectionChangedListener { |
325 | 311 | @Override |
326 | 312 | public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { |
327 | 313 | updateEnabledState(newSelection); |
328 | 314 | } |
| 315 | |
| 316 | @Override |
| 317 | public String toString() { |
| 318 | return "SelectionChangeAdapter [" + JosmAction.this.toString() + "]"; |
| 319 | } |
329 | 320 | } |
330 | 321 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java b/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java
index 6c79832..f6e1fcb 100644
a
|
b
|
import javax.swing.plaf.basic.BasicArrowButton;
|
20 | 20 | import org.openstreetmap.josm.Main; |
21 | 21 | import org.openstreetmap.josm.data.osm.Relation; |
22 | 22 | import org.openstreetmap.josm.gui.DefaultNameFormatter; |
23 | | import org.openstreetmap.josm.gui.MapView; |
24 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
25 | 23 | import org.openstreetmap.josm.gui.SideButton; |
26 | 24 | 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; |
27 | 31 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
28 | 32 | import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; |
29 | 33 | import org.openstreetmap.josm.tools.ImageProvider; |
… |
… |
import org.openstreetmap.josm.tools.Shortcut;
|
32 | 36 | /** |
33 | 37 | * Action for accessing recent relations. |
34 | 38 | */ |
35 | | public class RecentRelationsAction implements ActionListener, CommandQueueListener, LayerChangeListener { |
| 39 | public class RecentRelationsAction implements ActionListener, CommandQueueListener, LayerChangeListener, ActiveLayerChangeListener { |
36 | 40 | |
37 | 41 | private final SideButton editButton; |
38 | 42 | private final BasicArrowButton arrow; |
… |
… |
public class RecentRelationsAction implements ActionListener, CommandQueueListen
|
47 | 51 | arrow = editButton.createArrow(this); |
48 | 52 | arrow.setToolTipText(tr("List of recent relations")); |
49 | 53 | Main.main.undoRedo.addCommandQueueListener(this); |
50 | | MapView.addLayerChangeListener(this); |
| 54 | Main.getLayerManager().addLayerChangeListener(this); |
| 55 | Main.getLayerManager().addActiveLayerChangeListener(this); |
51 | 56 | enableArrow(); |
52 | 57 | shortcut = Shortcut.registerShortcut( |
53 | 58 | "relationeditor:editrecentrelation", |
… |
… |
public class RecentRelationsAction implements ActionListener, CommandQueueListen
|
108 | 113 | } |
109 | 114 | |
110 | 115 | @Override |
111 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
| 116 | public void layerAdded(LayerAddEvent e) { |
112 | 117 | enableArrow(); |
113 | 118 | } |
114 | 119 | |
115 | 120 | @Override |
116 | | public void layerAdded(Layer newLayer) { |
| 121 | public void layerRemoving(LayerRemoveEvent e) { |
117 | 122 | enableArrow(); |
118 | 123 | } |
119 | 124 | |
120 | 125 | @Override |
121 | | public void layerRemoved(Layer oldLayer) { |
| 126 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 127 | enableArrow(); |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
122 | 132 | enableArrow(); |
123 | 133 | } |
124 | 134 | |
… |
… |
public class RecentRelationsAction implements ActionListener, CommandQueueListen
|
181 | 191 | EditRelationAction.launchEditor(relation); |
182 | 192 | } |
183 | 193 | } |
| 194 | |
184 | 195 | } |
-
diff --git a/src/org/openstreetmap/josm/data/UndoRedoHandler.java b/src/org/openstreetmap/josm/data/UndoRedoHandler.java
index bb07a61..c15ebfc 100644
a
|
b
|
import org.openstreetmap.josm.Main;
|
9 | 9 | import org.openstreetmap.josm.command.Command; |
10 | 10 | import org.openstreetmap.josm.data.osm.DataSet; |
11 | 11 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
12 | | import org.openstreetmap.josm.gui.MapView; |
13 | 12 | import org.openstreetmap.josm.gui.layer.Layer; |
| 13 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 14 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 15 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 16 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
14 | 17 | import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; |
15 | 18 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
16 | 19 | |
17 | | public class UndoRedoHandler implements MapView.LayerChangeListener { |
| 20 | public class UndoRedoHandler implements LayerChangeListener { |
18 | 21 | |
19 | 22 | /** |
20 | 23 | * All commands that were made on the dataset. Don't write from outside! |
… |
… |
public class UndoRedoHandler implements MapView.LayerChangeListener {
|
31 | 34 | * Constructs a new {@code UndoRedoHandler}. |
32 | 35 | */ |
33 | 36 | public UndoRedoHandler() { |
34 | | MapView.addLayerChangeListener(this); |
| 37 | Main.getLayerManager().addLayerChangeListener(this); |
35 | 38 | } |
36 | 39 | |
37 | 40 | /** |
… |
… |
public class UndoRedoHandler implements MapView.LayerChangeListener {
|
169 | 172 | } |
170 | 173 | |
171 | 174 | @Override |
172 | | public void layerRemoved(Layer oldLayer) { |
173 | | clean(oldLayer); |
| 175 | public void layerRemoving(LayerRemoveEvent e) { |
| 176 | clean(e.getRemovedLayer()); |
174 | 177 | } |
175 | 178 | |
176 | 179 | @Override |
177 | | public void layerAdded(Layer newLayer) { |
| 180 | public void layerAdded(LayerAddEvent e) { |
178 | 181 | // Do nothing |
179 | 182 | } |
180 | 183 | |
181 | 184 | @Override |
182 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
| 185 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
183 | 186 | // Do nothing |
184 | 187 | } |
185 | 188 | |
-
diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java
index d76fc027..16650ca 100644
a
|
b
|
import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
|
27 | 27 | import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.PolyData; |
28 | 28 | import org.openstreetmap.josm.data.projection.Projection; |
29 | 29 | import org.openstreetmap.josm.data.projection.ProjectionChangeListener; |
30 | | import org.openstreetmap.josm.gui.MapView; |
31 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
32 | 30 | import org.openstreetmap.josm.gui.NavigatableComponent; |
33 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 31 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 32 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 33 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 34 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
34 | 35 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
35 | 36 | |
36 | 37 | /** |
… |
… |
public final class MultipolygonCache implements DataSetListener, LayerChangeList
|
50 | 51 | this.selectedPolyData = new ArrayList<>(); |
51 | 52 | Main.addProjectionChangeListener(this); |
52 | 53 | DataSet.addSelectionListener(this); |
53 | | MapView.addLayerChangeListener(this); |
| 54 | Main.getLayerManager().addLayerChangeListener(this); |
54 | 55 | } |
55 | 56 | |
56 | 57 | /** |
… |
… |
public final class MultipolygonCache implements DataSetListener, LayerChangeList
|
285 | 286 | } |
286 | 287 | |
287 | 288 | @Override |
288 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
| 289 | public void layerAdded(LayerAddEvent e) { |
289 | 290 | // Do nothing |
290 | 291 | } |
291 | 292 | |
292 | 293 | @Override |
293 | | public void layerAdded(Layer newLayer) { |
| 294 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
294 | 295 | // Do nothing |
295 | 296 | } |
296 | 297 | |
297 | 298 | @Override |
298 | | public void layerRemoved(Layer oldLayer) { |
299 | | if (oldLayer instanceof OsmDataLayer) { |
300 | | clear(((OsmDataLayer) oldLayer).data); |
| 299 | public void layerRemoving(LayerRemoveEvent e) { |
| 300 | if (e.getRemovedLayer() instanceof OsmDataLayer) { |
| 301 | clear(((OsmDataLayer) e.getRemovedLayer()).data); |
301 | 302 | } |
302 | 303 | } |
303 | 304 | |
-
diff --git a/src/org/openstreetmap/josm/gui/ImageryMenu.java b/src/org/openstreetmap/josm/gui/ImageryMenu.java
index 45ee187..a6359bc 100644
a
|
b
|
import org.openstreetmap.josm.data.coor.LatLon;
|
32 | 32 | import org.openstreetmap.josm.data.imagery.ImageryInfo; |
33 | 33 | import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; |
34 | 34 | import org.openstreetmap.josm.data.imagery.Shape; |
35 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
36 | 35 | import org.openstreetmap.josm.gui.layer.ImageryLayer; |
37 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 36 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 37 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 38 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 39 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
38 | 40 | import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; |
39 | 41 | import org.openstreetmap.josm.tools.ImageProvider; |
40 | 42 | |
… |
… |
public class ImageryMenu extends JMenu implements LayerChangeListener {
|
110 | 112 | /* I18N: mnemonic: I */ |
111 | 113 | super(trc("menu", "Imagery")); |
112 | 114 | setupMenuScroller(); |
113 | | MapView.addLayerChangeListener(this); |
| 115 | Main.getLayerManager().addLayerChangeListener(this); |
114 | 116 | // build dynamically |
115 | 117 | addMenuListener(new MenuListener() { |
116 | 118 | @Override |
… |
… |
public class ImageryMenu extends JMenu implements LayerChangeListener {
|
209 | 211 | } |
210 | 212 | |
211 | 213 | private JMenuItem getNewOffsetMenu() { |
212 | | if (!Main.isDisplayingMapView()) { |
213 | | offsetAction.setEnabled(false); |
214 | | return singleOffset; |
215 | | } |
216 | | Collection<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class); |
| 214 | Collection<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class); |
217 | 215 | if (layers.isEmpty()) { |
218 | 216 | offsetAction.setEnabled(false); |
219 | 217 | return singleOffset; |
… |
… |
public class ImageryMenu extends JMenu implements LayerChangeListener {
|
238 | 236 | } |
239 | 237 | |
240 | 238 | @Override |
241 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
242 | | // Do nothing |
| 239 | public void layerAdded(LayerAddEvent e) { |
| 240 | if (e.getAddedLayer() instanceof ImageryLayer) { |
| 241 | refreshOffsetMenu(); |
| 242 | } |
243 | 243 | } |
244 | 244 | |
245 | 245 | @Override |
246 | | public void layerAdded(Layer newLayer) { |
247 | | if (newLayer instanceof ImageryLayer) { |
| 246 | public void layerRemoving(LayerRemoveEvent e) { |
| 247 | if (e.getRemovedLayer() instanceof ImageryLayer) { |
248 | 248 | refreshOffsetMenu(); |
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | 252 | @Override |
253 | | public void layerRemoved(Layer oldLayer) { |
254 | | if (oldLayer instanceof ImageryLayer) { |
255 | | refreshOffsetMenu(); |
256 | | } |
| 253 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 254 | refreshOffsetMenu(); |
257 | 255 | } |
258 | 256 | |
259 | 257 | /** |
-
diff --git a/src/org/openstreetmap/josm/gui/MainFrame.java b/src/org/openstreetmap/josm/gui/MainFrame.java
index 8fa96e5..75ac489 100644
a
|
b
|
public class MainFrame extends JFrame {
|
113 | 113 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
114 | 114 | refreshTitle(); |
115 | 115 | } |
116 | | }, false); |
| 116 | }); |
117 | 117 | Main.getLayerManager().addLayerChangeListener(new ManageLayerListeners(), true); |
118 | 118 | |
119 | 119 | refreshTitle(); |
-
diff --git a/src/org/openstreetmap/josm/gui/MainMenu.java b/src/org/openstreetmap/josm/gui/MainMenu.java
index 8ab7575..be35785 100644
a
|
b
|
import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
|
116 | 116 | import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; |
117 | 117 | import org.openstreetmap.josm.gui.dialogs.MenuItemSearchDialog; |
118 | 118 | import org.openstreetmap.josm.gui.io.RecentlyOpenedFilesMenu; |
119 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 119 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 120 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
120 | 121 | import org.openstreetmap.josm.gui.mappaint.MapPaintMenu; |
121 | 122 | import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; |
122 | 123 | import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; |
… |
… |
public class MainMenu extends JMenuBar {
|
821 | 822 | |
822 | 823 | windowMenu.addMenuListener(menuSeparatorHandler); |
823 | 824 | |
824 | | new PresetsMenuEnabler(presetsMenu).refreshEnabled(); |
| 825 | new PresetsMenuEnabler(presetsMenu); |
825 | 826 | } |
826 | 827 | |
827 | 828 | /** |
… |
… |
public class MainMenu extends JMenuBar {
|
885 | 886 | } |
886 | 887 | } |
887 | 888 | |
888 | | static class PresetsMenuEnabler implements MapView.LayerChangeListener { |
| 889 | static class PresetsMenuEnabler implements ActiveLayerChangeListener { |
889 | 890 | private final JMenu presetsMenu; |
890 | 891 | |
891 | 892 | PresetsMenuEnabler(JMenu presetsMenu) { |
892 | | MapView.addLayerChangeListener(this); |
893 | 893 | this.presetsMenu = presetsMenu; |
894 | | } |
895 | | |
896 | | /** |
897 | | * Refreshes the enabled state |
898 | | */ |
899 | | protected void refreshEnabled() { |
900 | | presetsMenu.setEnabled(Main.main.hasEditLayer()); |
901 | | } |
902 | | |
903 | | @Override |
904 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
905 | | refreshEnabled(); |
906 | | } |
907 | | |
908 | | @Override |
909 | | public void layerAdded(Layer newLayer) { |
910 | | refreshEnabled(); |
| 894 | Main.getLayerManager().addAndFireActiveLayerChangeListener(this); |
911 | 895 | } |
912 | 896 | |
913 | 897 | @Override |
914 | | public void layerRemoved(Layer oldLayer) { |
915 | | refreshEnabled(); |
| 898 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
| 899 | presetsMenu.setEnabled(e.getSource().getEditLayer() != null); |
916 | 900 | } |
917 | 901 | } |
918 | 902 | |
-
diff --git a/src/org/openstreetmap/josm/gui/MapFrame.java b/src/org/openstreetmap/josm/gui/MapFrame.java
index 6c0e557..62030d9 100644
a
|
b
|
import javax.swing.JPopupMenu;
|
37 | 37 | import javax.swing.JSplitPane; |
38 | 38 | import javax.swing.JToolBar; |
39 | 39 | import javax.swing.KeyStroke; |
40 | | import javax.swing.SwingUtilities; |
41 | 40 | import javax.swing.border.Border; |
42 | 41 | import javax.swing.event.PopupMenuEvent; |
43 | 42 | import javax.swing.event.PopupMenuListener; |
… |
… |
import org.openstreetmap.josm.data.Preferences;
|
58 | 57 | import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; |
59 | 58 | import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; |
60 | 59 | import org.openstreetmap.josm.data.ViewportData; |
61 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
62 | 60 | import org.openstreetmap.josm.gui.dialogs.ChangesetDialog; |
63 | 61 | import org.openstreetmap.josm.gui.dialogs.CommandStackDialog; |
64 | 62 | import org.openstreetmap.josm.gui.dialogs.ConflictDialog; |
… |
… |
import org.openstreetmap.josm.gui.dialogs.ValidatorDialog;
|
76 | 74 | import org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog; |
77 | 75 | import org.openstreetmap.josm.gui.layer.Layer; |
78 | 76 | import org.openstreetmap.josm.gui.layer.LayerManager; |
| 77 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 78 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 79 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 80 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
| 81 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 82 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
79 | 83 | import org.openstreetmap.josm.gui.util.AdvancedKeyPressDetector; |
80 | 84 | import org.openstreetmap.josm.tools.Destroyable; |
81 | 85 | import org.openstreetmap.josm.tools.GBC; |
… |
… |
import org.openstreetmap.josm.tools.Shortcut;
|
89 | 93 | * |
90 | 94 | * @author imi |
91 | 95 | */ |
92 | | public class MapFrame extends JPanel implements Destroyable, LayerChangeListener { |
| 96 | public class MapFrame extends JPanel implements Destroyable, ActiveLayerChangeListener, LayerChangeListener { |
93 | 97 | |
94 | 98 | /** |
95 | 99 | * The current mode, this frame operates. |
… |
… |
public class MapFrame extends JPanel implements Destroyable, LayerChangeListener
|
284 | 288 | |
285 | 289 | // status line below the map |
286 | 290 | statusLine = new MapStatus(this); |
287 | | MapView.addLayerChangeListener(this); |
| 291 | Main.getLayerManager().addLayerChangeListener(this); |
| 292 | Main.getLayerManager().addActiveLayerChangeListener(this); |
288 | 293 | |
289 | 294 | boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null; |
290 | 295 | if (unregisterTab) { |
… |
… |
public class MapFrame extends JPanel implements Destroyable, LayerChangeListener
|
328 | 333 | */ |
329 | 334 | @Override |
330 | 335 | public void destroy() { |
331 | | MapView.removeLayerChangeListener(this); |
| 336 | Main.getLayerManager().removeLayerChangeListener(this); |
| 337 | Main.getLayerManager().removeActiveLayerChangeListener(this); |
332 | 338 | dialogsPanel.destroy(); |
333 | 339 | Main.pref.removePreferenceChangeListener(sidetoolbarPreferencesChangedListener); |
334 | 340 | for (int i = 0; i < toolBarActions.getComponentCount(); ++i) { |
… |
… |
public class MapFrame extends JPanel implements Destroyable, LayerChangeListener
|
756 | 762 | } |
757 | 763 | |
758 | 764 | @Override |
759 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
| 765 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
760 | 766 | boolean modeChanged = false; |
| 767 | Layer newLayer = e.getSource().getActiveLayer(); |
761 | 768 | if (mapMode == null || !mapMode.layerIsSupported(newLayer)) { |
762 | 769 | MapMode newMapMode = getLastMapMode(newLayer); |
763 | 770 | modeChanged = newMapMode != mapMode; |
… |
… |
public class MapFrame extends JPanel implements Destroyable, LayerChangeListener
|
770 | 777 | } |
771 | 778 | } |
772 | 779 | // if this is really a change (and not the first active layer) |
773 | | if (oldLayer != null) { |
| 780 | if (e.getPreviousActiveLayer() != null) { |
774 | 781 | if (!modeChanged && mapMode != null) { |
775 | 782 | // Let mapmodes know about new active layer |
776 | 783 | mapMode.exitMode(); |
… |
… |
public class MapFrame extends JPanel implements Destroyable, LayerChangeListener
|
782 | 789 | |
783 | 790 | // After all listeners notice new layer, some buttons will be disabled/enabled |
784 | 791 | // and possibly need to be hidden/shown. |
785 | | SwingUtilities.invokeLater(new Runnable() { |
786 | | @Override public void run() { |
787 | | validateToolBarsVisibility(); |
788 | | } |
789 | | }); |
| 792 | validateToolBarsVisibility(); |
790 | 793 | } |
791 | 794 | |
792 | 795 | private MapMode getLastMapMode(Layer newLayer) { |
… |
… |
public class MapFrame extends JPanel implements Destroyable, LayerChangeListener
|
802 | 805 | } |
803 | 806 | |
804 | 807 | @Override |
805 | | public void layerAdded(Layer newLayer) { |
806 | | // Do nothing |
| 808 | public void layerAdded(LayerAddEvent e) { |
| 809 | // ignored |
| 810 | } |
| 811 | |
| 812 | @Override |
| 813 | public void layerRemoving(LayerRemoveEvent e) { |
| 814 | lastMapMode.remove(e.getRemovedLayer()); |
807 | 815 | } |
808 | 816 | |
809 | 817 | @Override |
810 | | public void layerRemoved(Layer oldLayer) { |
811 | | lastMapMode.remove(oldLayer); |
| 818 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 819 | // ignored |
812 | 820 | } |
| 821 | |
813 | 822 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
index 84ee5e8..f2ef962 100644
a
|
b
|
public class LayerListDialog extends ToggleDialog {
|
185 | 185 | // |
186 | 186 | DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); |
187 | 187 | selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
188 | | model = new LayerListModel(selectionModel); |
| 188 | model = new LayerListModel(layerManager, selectionModel); |
189 | 189 | |
190 | 190 | // create the list control |
191 | 191 | // |
192 | | layerList = new LayerList(model, layerManager); |
| 192 | layerList = new LayerList(model); |
193 | 193 | layerList.setSelectionModel(selectionModel); |
194 | 194 | layerList.addMouseListener(new PopupMenuHandler()); |
195 | 195 | layerList.setBackground(UIManager.getColor("Button.background")); |
… |
… |
public class LayerListDialog extends ToggleDialog {
|
329 | 329 | |
330 | 330 | @Override |
331 | 331 | public void showNotify() { |
332 | | MapView.addLayerChangeListener(activateLayerAction); |
| 332 | layerManager.addActiveLayerChangeListener(activateLayerAction); |
333 | 333 | layerManager.addLayerChangeListener(model); |
334 | 334 | layerManager.addAndFireActiveLayerChangeListener(model); |
335 | 335 | model.populate(); |
… |
… |
public class LayerListDialog extends ToggleDialog {
|
339 | 339 | public void hideNotify() { |
340 | 340 | layerManager.removeLayerChangeListener(model); |
341 | 341 | layerManager.removeActiveLayerChangeListener(model); |
342 | | MapView.removeLayerChangeListener(activateLayerAction); |
| 342 | layerManager.removeActiveLayerChangeListener(activateLayerAction); |
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
… |
… |
public class LayerListDialog extends ToggleDialog {
|
648 | 648 | private final DefaultListSelectionModel selectionModel; |
649 | 649 | private final CopyOnWriteArrayList<LayerListModelListener> listeners; |
650 | 650 | private LayerList layerList; |
| 651 | private final MainLayerManager layerManager; |
651 | 652 | |
652 | 653 | /** |
653 | 654 | * constructor |
654 | | * |
| 655 | * @param layerManager The layer manager to use for the list. |
655 | 656 | * @param selectionModel the list selection model |
656 | 657 | */ |
657 | | LayerListModel(DefaultListSelectionModel selectionModel) { |
| 658 | LayerListModel(MainLayerManager layerManager, DefaultListSelectionModel selectionModel) { |
| 659 | this.layerManager = layerManager; |
658 | 660 | this.selectionModel = selectionModel; |
659 | 661 | listeners = new CopyOnWriteArrayList<>(); |
660 | 662 | } |
… |
… |
public class LayerListDialog extends ToggleDialog {
|
663 | 665 | this.layerList = layerList; |
664 | 666 | } |
665 | 667 | |
666 | | private MainLayerManager getLayerManager() { |
667 | | // layerList should never be null. But if it is, we should not crash. |
668 | | if (layerList == null) { |
669 | | return new MainLayerManager(); |
670 | | } else { |
671 | | return layerList.getLayerManager(); |
672 | | } |
| 668 | /** |
| 669 | * The layer manager this model is for. |
| 670 | * @return The layer manager. |
| 671 | */ |
| 672 | public MainLayerManager getLayerManager() { |
| 673 | return layerManager; |
673 | 674 | } |
674 | 675 | |
675 | 676 | /** |
… |
… |
public class LayerListDialog extends ToggleDialog {
|
1124 | 1125 | * This component displays a list of layers and provides the methods needed by {@link LayerListModel}. |
1125 | 1126 | */ |
1126 | 1127 | static class LayerList extends JTable { |
1127 | | private final transient MainLayerManager layerManager; |
1128 | 1128 | |
1129 | | LayerList(LayerListModel dataModel, MainLayerManager layerManager) { |
| 1129 | LayerList(LayerListModel dataModel) { |
1130 | 1130 | super(dataModel); |
1131 | | this.layerManager = layerManager; |
1132 | 1131 | dataModel.setLayerList(this); |
1133 | 1132 | } |
1134 | 1133 | |
… |
… |
public class LayerListDialog extends ToggleDialog {
|
1141 | 1140 | rect.setLocation(rect.x - pt.x, rect.y - pt.y); |
1142 | 1141 | viewport.scrollRectToVisible(rect); |
1143 | 1142 | } |
1144 | | |
1145 | | /** |
1146 | | * Gets you the layer manager used for this list. |
1147 | | * @return The layer manager. |
1148 | | * @since 10288 |
1149 | | */ |
1150 | | public MainLayerManager getLayerManager() { |
1151 | | return layerManager; |
1152 | | } |
1153 | 1143 | } |
1154 | 1144 | |
1155 | 1145 | /** |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java b/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
index 7659768..56dde01 100644
a
|
b
|
import org.openstreetmap.josm.data.notes.Note;
|
38 | 38 | import org.openstreetmap.josm.data.notes.Note.State; |
39 | 39 | import org.openstreetmap.josm.data.notes.NoteComment; |
40 | 40 | import org.openstreetmap.josm.data.osm.NoteData; |
41 | | import org.openstreetmap.josm.gui.MapView; |
42 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
43 | 41 | import org.openstreetmap.josm.gui.NoteInputDialog; |
44 | 42 | import org.openstreetmap.josm.gui.NoteSortDialog; |
45 | 43 | import org.openstreetmap.josm.gui.SideButton; |
46 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 44 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 45 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 46 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 47 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
47 | 48 | import org.openstreetmap.josm.gui.layer.NoteLayer; |
48 | 49 | import org.openstreetmap.josm.tools.ImageProvider; |
49 | 50 | import org.openstreetmap.josm.tools.date.DateUtils; |
… |
… |
public class NotesDialog extends ToggleDialog implements LayerChangeListener {
|
98 | 99 | sortAction = new SortAction(); |
99 | 100 | uploadAction = new UploadNotesAction(); |
100 | 101 | buildDialog(); |
101 | | MapView.addLayerChangeListener(this); |
| 102 | Main.getLayerManager().addLayerChangeListener(this); |
102 | 103 | } |
103 | 104 | |
104 | 105 | private void buildDialog() { |
… |
… |
public class NotesDialog extends ToggleDialog implements LayerChangeListener {
|
168 | 169 | } |
169 | 170 | } |
170 | 171 | |
171 | | @Override |
172 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
173 | | // Do nothing |
174 | | } |
175 | 172 | |
176 | 173 | @Override |
177 | | public void layerAdded(Layer newLayer) { |
178 | | if (newLayer instanceof NoteLayer) { |
179 | | noteData = ((NoteLayer) newLayer).getNoteData(); |
| 174 | public void layerAdded(LayerAddEvent e) { |
| 175 | if (e.getAddedLayer() instanceof NoteLayer) { |
| 176 | noteData = ((NoteLayer) e.getAddedLayer()).getNoteData(); |
180 | 177 | model.setData(noteData.getNotes()); |
181 | 178 | setNotes(noteData.getSortedNotes()); |
182 | 179 | } |
183 | 180 | } |
184 | 181 | |
185 | 182 | @Override |
186 | | public void layerRemoved(Layer oldLayer) { |
187 | | if (oldLayer instanceof NoteLayer) { |
| 183 | public void layerRemoving(LayerRemoveEvent e) { |
| 184 | if (e.getRemovedLayer() instanceof NoteLayer) { |
188 | 185 | noteData = null; |
189 | 186 | model.clearData(); |
190 | 187 | if (Main.map.mapMode instanceof AddNoteAction) { |
… |
… |
public class NotesDialog extends ToggleDialog implements LayerChangeListener {
|
193 | 190 | } |
194 | 191 | } |
195 | 192 | |
| 193 | @Override |
| 194 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 195 | // ignored |
| 196 | } |
| 197 | |
196 | 198 | /** |
197 | 199 | * Sets the list of notes to be displayed in the dialog. |
198 | 200 | * The dialog should match the notes displayed in the note layer. |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
index 57ac553..e452b71 100644
a
|
b
|
import org.openstreetmap.josm.data.SelectionChangedListener;
|
34 | 34 | import org.openstreetmap.josm.data.osm.DataSet; |
35 | 35 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
36 | 36 | import org.openstreetmap.josm.data.osm.User; |
37 | | import org.openstreetmap.josm.gui.MapView; |
38 | 37 | import org.openstreetmap.josm.gui.SideButton; |
39 | 38 | import org.openstreetmap.josm.gui.layer.Layer; |
| 39 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 40 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
40 | 41 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
41 | 42 | import org.openstreetmap.josm.gui.util.GuiHelper; |
42 | 43 | import org.openstreetmap.josm.tools.ImageProvider; |
… |
… |
import org.openstreetmap.josm.tools.Utils;
|
49 | 50 | * selection area, along with the number of objects. |
50 | 51 | * |
51 | 52 | */ |
52 | | public class UserListDialog extends ToggleDialog implements SelectionChangedListener, MapView.LayerChangeListener { |
| 53 | public class UserListDialog extends ToggleDialog implements SelectionChangedListener, ActiveLayerChangeListener { |
53 | 54 | |
54 | 55 | /** |
55 | 56 | * The display list. |
… |
… |
public class UserListDialog extends ToggleDialog implements SelectionChangedList
|
71 | 72 | @Override |
72 | 73 | public void showNotify() { |
73 | 74 | DataSet.addSelectionListener(this); |
74 | | MapView.addLayerChangeListener(this); |
| 75 | Main.getLayerManager().addActiveLayerChangeListener(this); |
75 | 76 | } |
76 | 77 | |
77 | 78 | @Override |
78 | 79 | public void hideNotify() { |
79 | | MapView.removeLayerChangeListener(this); |
| 80 | Main.getLayerManager().removeActiveLayerChangeListener(this); |
80 | 81 | DataSet.removeSelectionListener(this); |
81 | 82 | } |
82 | 83 | |
… |
… |
public class UserListDialog extends ToggleDialog implements SelectionChangedList
|
112 | 113 | } |
113 | 114 | |
114 | 115 | @Override |
115 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
116 | | if (newLayer instanceof OsmDataLayer) { |
117 | | refresh(((OsmDataLayer) newLayer).data.getAllSelected()); |
| 116 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
| 117 | Layer activeLayer = e.getSource().getActiveLayer(); |
| 118 | if (activeLayer instanceof OsmDataLayer) { |
| 119 | refresh(((OsmDataLayer) activeLayer).data.getAllSelected()); |
118 | 120 | } else { |
119 | 121 | refresh(null); |
120 | 122 | } |
121 | 123 | } |
122 | 124 | |
123 | | @Override |
124 | | public void layerAdded(Layer newLayer) { |
125 | | // do nothing |
126 | | } |
127 | | |
128 | | @Override |
129 | | public void layerRemoved(Layer oldLayer) { |
130 | | // do nothing |
131 | | } |
132 | | |
133 | 125 | /** |
134 | 126 | * Refreshes user list from given collection of OSM primitives. |
135 | 127 | * @param fromPrimitives OSM primitives to fetch users from |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java b/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
index 93cd671..e49b466 100644
a
|
b
|
import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
|
41 | 41 | import org.openstreetmap.josm.data.validation.OsmValidator; |
42 | 42 | import org.openstreetmap.josm.data.validation.TestError; |
43 | 43 | import org.openstreetmap.josm.data.validation.ValidatorVisitor; |
44 | | import org.openstreetmap.josm.gui.MapView; |
45 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
46 | 44 | import org.openstreetmap.josm.gui.PleaseWaitRunnable; |
47 | 45 | import org.openstreetmap.josm.gui.PopupMenuHandler; |
48 | 46 | import org.openstreetmap.josm.gui.SideButton; |
49 | 47 | import org.openstreetmap.josm.gui.dialogs.validator.ValidatorTreePanel; |
50 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 48 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 49 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
51 | 50 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
52 | 51 | import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference; |
53 | 52 | import org.openstreetmap.josm.gui.progress.ProgressMonitor; |
… |
… |
import org.xml.sax.SAXException;
|
65 | 64 | * |
66 | 65 | * @author frsantos |
67 | 66 | */ |
68 | | public class ValidatorDialog extends ToggleDialog implements SelectionChangedListener, LayerChangeListener { |
| 67 | public class ValidatorDialog extends ToggleDialog implements SelectionChangedListener, ActiveLayerChangeListener { |
69 | 68 | |
70 | 69 | /** The display tree */ |
71 | 70 | public ValidatorTreePanel tree; |
… |
… |
public class ValidatorDialog extends ToggleDialog implements SelectionChangedLis
|
178 | 177 | if (ds != null) { |
179 | 178 | updateSelection(ds.getAllSelected()); |
180 | 179 | } |
181 | | MapView.addLayerChangeListener(this); |
182 | | Layer activeLayer = Main.map.mapView.getActiveLayer(); |
183 | | if (activeLayer != null) { |
184 | | activeLayerChange(null, activeLayer); |
185 | | } |
| 180 | Main.getLayerManager().addAndFireActiveLayerChangeListener(this); |
186 | 181 | } |
187 | 182 | |
188 | 183 | @Override |
189 | 184 | public void hideNotify() { |
190 | | MapView.removeLayerChangeListener(this); |
| 185 | Main.getLayerManager().removeActiveLayerChangeListener(this); |
191 | 186 | DataSet.removeSelectionListener(this); |
192 | 187 | } |
193 | 188 | |
… |
… |
public class ValidatorDialog extends ToggleDialog implements SelectionChangedLis
|
406 | 401 | } |
407 | 402 | |
408 | 403 | @Override |
409 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
410 | | if (newLayer instanceof OsmDataLayer) { |
411 | | linkedLayer = (OsmDataLayer) newLayer; |
412 | | tree.setErrorList(linkedLayer.validationErrors); |
413 | | } |
414 | | } |
415 | | |
416 | | @Override |
417 | | public void layerAdded(Layer newLayer) { |
418 | | // Do nothing |
419 | | } |
420 | | |
421 | | @Override |
422 | | public void layerRemoved(Layer oldLayer) { |
423 | | if (oldLayer == linkedLayer) { |
| 404 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
| 405 | OsmDataLayer editLayer = e.getSource().getEditLayer(); |
| 406 | if (editLayer == null) { |
424 | 407 | tree.setErrorList(new ArrayList<TestError>()); |
| 408 | } else { |
| 409 | tree.setErrorList(editLayer.validationErrors); |
425 | 410 | } |
426 | 411 | } |
427 | 412 | |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/layer/ActivateLayerAction.java b/src/org/openstreetmap/josm/gui/dialogs/layer/ActivateLayerAction.java
index ad661ea..ddb5173 100644
a
|
b
|
import java.util.List;
|
9 | 9 | |
10 | 10 | import javax.swing.AbstractAction; |
11 | 11 | |
12 | | import org.openstreetmap.josm.Main; |
13 | | import org.openstreetmap.josm.gui.MapView; |
14 | 12 | import org.openstreetmap.josm.gui.dialogs.LayerListDialog; |
15 | 13 | import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerListModel; |
16 | 14 | import org.openstreetmap.josm.gui.help.HelpUtil; |
17 | 15 | import org.openstreetmap.josm.gui.layer.Layer; |
| 16 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 17 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
18 | 18 | import org.openstreetmap.josm.gui.util.GuiHelper; |
19 | 19 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
20 | 20 | import org.openstreetmap.josm.tools.ImageProvider; |
… |
… |
import org.openstreetmap.josm.tools.Shortcut;
|
25 | 25 | * The action to activate the currently selected layer |
26 | 26 | */ |
27 | 27 | public final class ActivateLayerAction extends AbstractAction |
28 | | implements IEnabledStateUpdating, MapView.LayerChangeListener, MultikeyShortcutAction { |
| 28 | implements IEnabledStateUpdating, ActiveLayerChangeListener, MultikeyShortcutAction { |
29 | 29 | private transient Layer layer; |
30 | 30 | private transient Shortcut multikeyShortcut; |
31 | 31 | private final LayerListModel model; |
… |
… |
implements IEnabledStateUpdating, MapView.LayerChangeListener, MultikeyShortcutA
|
76 | 76 | |
77 | 77 | private void execute(Layer layer) { |
78 | 78 | // model is going to be updated via LayerChangeListener and PropertyChangeEvents |
79 | | Main.map.mapView.setActiveLayer(layer); |
| 79 | model.getLayerManager().setActiveLayer(layer); |
80 | 80 | layer.setVisible(true); |
81 | 81 | } |
82 | 82 | |
83 | | protected boolean isActiveLayer(Layer layer) { |
84 | | if (!Main.isDisplayingMapView()) |
85 | | return false; |
86 | | return Main.map.mapView.getActiveLayer() == layer; |
| 83 | boolean isActiveLayer(Layer layer) { |
| 84 | return model.getLayerManager().getActiveLayer() == layer; |
87 | 85 | } |
88 | 86 | |
89 | 87 | @Override |
… |
… |
implements IEnabledStateUpdating, MapView.LayerChangeListener, MultikeyShortcutA
|
105 | 103 | } |
106 | 104 | |
107 | 105 | @Override |
108 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
109 | | updateEnabledState(); |
110 | | } |
111 | | |
112 | | @Override |
113 | | public void layerAdded(Layer newLayer) { |
114 | | updateEnabledState(); |
115 | | } |
116 | | |
117 | | @Override |
118 | | public void layerRemoved(Layer oldLayer) { |
| 106 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
119 | 107 | updateEnabledState(); |
120 | 108 | } |
121 | 109 | |
… |
… |
implements IEnabledStateUpdating, MapView.LayerChangeListener, MultikeyShortcutA
|
136 | 124 | public MultikeyInfo getLastMultikeyAction() { |
137 | 125 | return null; // Repeating action doesn't make much sense for activating |
138 | 126 | } |
| 127 | |
139 | 128 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java b/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
index 527a72a..001d244 100644
a
|
b
|
implements SelectionChangedListener, ActiveLayerChangeListener, DataSetListenerA
|
617 | 617 | public void destroy() { |
618 | 618 | super.destroy(); |
619 | 619 | Main.pref.removePreferenceChangeListener(this); |
620 | | for (JosmAction action : josmActions) { |
621 | | action.destroy(); |
622 | | } |
623 | 620 | Container parent = pluginHook.getParent(); |
624 | 621 | if (parent != null) { |
625 | 622 | parent.remove(pluginHook); |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java b/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
index a2eb0a8..7f492f7 100644
a
|
b
|
import java.util.Map;
|
10 | 10 | import java.util.Map.Entry; |
11 | 11 | import java.util.Objects; |
12 | 12 | |
| 13 | import org.openstreetmap.josm.Main; |
13 | 14 | import org.openstreetmap.josm.data.osm.Relation; |
14 | | import org.openstreetmap.josm.gui.MapView; |
15 | 15 | import org.openstreetmap.josm.gui.layer.Layer; |
| 16 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 17 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 18 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 19 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
16 | 20 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
17 | 21 | |
18 | 22 | /** |
19 | 23 | * RelationDialogManager keeps track of the open relation editors. |
20 | 24 | * |
21 | 25 | */ |
22 | | public class RelationDialogManager extends WindowAdapter implements MapView.LayerChangeListener { |
| 26 | public class RelationDialogManager extends WindowAdapter implements LayerChangeListener { |
23 | 27 | |
24 | 28 | /** keeps track of open relation editors */ |
25 | 29 | private static RelationDialogManager relationDialogManager; |
… |
… |
public class RelationDialogManager extends WindowAdapter implements MapView.Laye
|
32 | 36 | public static RelationDialogManager getRelationDialogManager() { |
33 | 37 | if (RelationDialogManager.relationDialogManager == null) { |
34 | 38 | RelationDialogManager.relationDialogManager = new RelationDialogManager(); |
35 | | MapView.addLayerChangeListener(RelationDialogManager.relationDialogManager); |
| 39 | Main.getLayerManager().addLayerChangeListener(RelationDialogManager.relationDialogManager); |
36 | 40 | } |
37 | 41 | return RelationDialogManager.relationDialogManager; |
38 | 42 | } |
… |
… |
public class RelationDialogManager extends WindowAdapter implements MapView.Laye
|
166 | 170 | return openDialogs.get(context); |
167 | 171 | } |
168 | 172 | |
169 | | /** |
170 | | * called when a layer is removed |
171 | | * |
172 | | */ |
173 | 173 | @Override |
174 | | public void layerRemoved(Layer oldLayer) { |
| 174 | public void layerRemoving(LayerRemoveEvent e) { |
| 175 | Layer oldLayer = e.getRemovedLayer(); |
175 | 176 | if (!(oldLayer instanceof OsmDataLayer)) |
176 | 177 | return; |
177 | 178 | OsmDataLayer dataLayer = (OsmDataLayer) oldLayer; |
… |
… |
public class RelationDialogManager extends WindowAdapter implements MapView.Laye
|
189 | 190 | } |
190 | 191 | |
191 | 192 | @Override |
192 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
193 | | // do nothing |
| 193 | public void layerAdded(LayerAddEvent e) { |
| 194 | // ignore |
194 | 195 | } |
195 | 196 | |
196 | 197 | @Override |
197 | | public void layerAdded(Layer newLayer) { |
198 | | // do nothing |
| 198 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 199 | // ignore |
199 | 200 | } |
200 | 201 | |
201 | 202 | @Override |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableModel.java b/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableModel.java
index fe71e33..365e8ac 100644
a
|
b
|
import org.openstreetmap.josm.Main;
|
10 | 10 | import org.openstreetmap.josm.data.SelectionChangedListener; |
11 | 11 | import org.openstreetmap.josm.data.osm.DataSet; |
12 | 12 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
13 | | import org.openstreetmap.josm.gui.MapView; |
14 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 13 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 14 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 15 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 16 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
| 17 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 18 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
15 | 19 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
16 | 20 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
17 | 21 | |
18 | | public class SelectionTableModel extends AbstractTableModel implements SelectionChangedListener, MapView.LayerChangeListener { |
| 22 | public class SelectionTableModel extends AbstractTableModel implements SelectionChangedListener, ActiveLayerChangeListener, LayerChangeListener { |
19 | 23 | |
20 | 24 | /** this selection table model only displays selected primitives in this layer */ |
21 | 25 | private final transient OsmDataLayer layer; |
… |
… |
public class SelectionTableModel extends AbstractTableModel implements Selection
|
39 | 43 | */ |
40 | 44 | public void register() { |
41 | 45 | DataSet.addSelectionListener(this); |
42 | | MapView.addLayerChangeListener(this); |
| 46 | Main.getLayerManager().addActiveLayerChangeListener(this); |
43 | 47 | } |
44 | 48 | |
45 | 49 | /** |
… |
… |
public class SelectionTableModel extends AbstractTableModel implements Selection
|
47 | 51 | */ |
48 | 52 | public void unregister() { |
49 | 53 | DataSet.removeSelectionListener(this); |
50 | | MapView.removeLayerChangeListener(this); |
| 54 | Main.getLayerManager().removeActiveLayerChangeListener(this); |
51 | 55 | } |
52 | 56 | |
53 | 57 | @Override |
… |
… |
public class SelectionTableModel extends AbstractTableModel implements Selection
|
68 | 72 | } |
69 | 73 | |
70 | 74 | @Override |
71 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
72 | | if (oldLayer == layer) { |
| 75 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
| 76 | if (e.getPreviousActiveLayer() == layer) { |
73 | 77 | cache.clear(); |
74 | 78 | } |
75 | | if (newLayer == layer) { |
76 | | cache.addAll(((OsmDataLayer) newLayer).data.getAllSelected()); |
| 79 | if (e.getSource().getActiveLayer() == layer) { |
| 80 | cache.addAll(layer.data.getAllSelected()); |
77 | 81 | } |
78 | 82 | fireTableDataChanged(); |
79 | 83 | } |
80 | 84 | |
81 | 85 | @Override |
82 | | public void layerAdded(Layer newLayer) { |
| 86 | public void layerAdded(LayerAddEvent e) { |
83 | 87 | // do nothing |
84 | 88 | } |
85 | 89 | |
86 | 90 | @Override |
87 | | public void layerRemoved(Layer oldLayer) { |
88 | | if (oldLayer == layer) { |
| 91 | public void layerRemoving(LayerRemoveEvent e) { |
| 92 | if (e.getRemovedLayer() == layer) { |
89 | 93 | unregister(); |
90 | 94 | } |
91 | 95 | this.cache.clear(); |
… |
… |
public class SelectionTableModel extends AbstractTableModel implements Selection
|
93 | 97 | } |
94 | 98 | |
95 | 99 | @Override |
| 100 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 101 | // do nothing |
| 102 | } |
| 103 | |
| 104 | @Override |
96 | 105 | public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { |
97 | 106 | if (layer == Main.main.getEditLayer()) { |
98 | 107 | cache.clear(); |
… |
… |
public class SelectionTableModel extends AbstractTableModel implements Selection
|
127 | 136 | public OsmPrimitive getPrimitive(int row) { |
128 | 137 | return cache.get(row); |
129 | 138 | } |
| 139 | |
130 | 140 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java b/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
index 1aae5c4..73cdcfc 100644
a
|
b
|
import org.openstreetmap.josm.Main;
|
21 | 21 | import org.openstreetmap.josm.data.osm.PrimitiveId; |
22 | 22 | import org.openstreetmap.josm.data.osm.history.History; |
23 | 23 | import org.openstreetmap.josm.data.osm.history.HistoryDataSet; |
24 | | import org.openstreetmap.josm.gui.MapView; |
25 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 24 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 25 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 26 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 27 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
26 | 28 | import org.openstreetmap.josm.tools.Predicate; |
27 | 29 | import org.openstreetmap.josm.tools.Utils; |
28 | 30 | import org.openstreetmap.josm.tools.WindowGeometry; |
… |
… |
import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;
|
32 | 34 | * Manager allowing to show/hide history dialogs. |
33 | 35 | * @since 2019 |
34 | 36 | */ |
35 | | public final class HistoryBrowserDialogManager implements MapView.LayerChangeListener { |
| 37 | public final class HistoryBrowserDialogManager implements LayerChangeListener { |
36 | 38 | |
37 | 39 | private static final String WINDOW_GEOMETRY_PREF = HistoryBrowserDialogManager.class.getName() + ".geometry"; |
38 | 40 | |
… |
… |
public final class HistoryBrowserDialogManager implements MapView.LayerChangeLis
|
53 | 55 | |
54 | 56 | protected HistoryBrowserDialogManager() { |
55 | 57 | dialogs = new HashMap<>(); |
56 | | MapView.addLayerChangeListener(this); |
| 58 | Main.getLayerManager().addLayerChangeListener(this); |
57 | 59 | } |
58 | 60 | |
59 | 61 | /** |
… |
… |
public final class HistoryBrowserDialogManager implements MapView.LayerChangeLis
|
152 | 154 | /* LayerChangeListener */ |
153 | 155 | /* ----------------------------------------------------------------------------- */ |
154 | 156 | @Override |
155 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
| 157 | public void layerAdded(LayerAddEvent e) { |
156 | 158 | // Do nothing |
157 | 159 | } |
158 | 160 | |
159 | 161 | @Override |
160 | | public void layerAdded(Layer newLayer) { |
161 | | // Do nothing |
162 | | } |
163 | | |
164 | | @Override |
165 | | public void layerRemoved(Layer oldLayer) { |
| 162 | public void layerRemoving(LayerRemoveEvent e) { |
166 | 163 | // remove all history browsers if the number of layers drops to 0 |
167 | | if (Main.isDisplayingMapView() && Main.map.mapView.getNumLayers() == 0) { |
| 164 | if (e.getSource().getLayers().isEmpty()) { |
168 | 165 | hideAll(); |
169 | 166 | } |
170 | 167 | } |
171 | 168 | |
| 169 | @Override |
| 170 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 171 | // Do nothing |
| 172 | } |
| 173 | |
172 | 174 | /** |
173 | 175 | * Show history dialog(s) for the given primitive(s). |
174 | 176 | * @param primitives The primitive(s) for which history will be displayed |
-
diff --git a/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java b/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
index 2b25290..ba4d0bd 100644
a
|
b
|
import org.openstreetmap.josm.data.osm.history.HistoryRelation;
|
40 | 40 | import org.openstreetmap.josm.data.osm.history.HistoryWay; |
41 | 41 | import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; |
42 | 42 | import org.openstreetmap.josm.gui.JosmUserIdentityManager; |
43 | | import org.openstreetmap.josm.gui.MapView; |
44 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
45 | 43 | import org.openstreetmap.josm.gui.layer.Layer; |
| 44 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 45 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
46 | 46 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
47 | 47 | import org.openstreetmap.josm.gui.util.ChangeNotifier; |
48 | 48 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
… |
… |
import org.openstreetmap.josm.tools.date.DateUtils;
|
73 | 73 | * |
74 | 74 | * @see HistoryBrowser |
75 | 75 | */ |
76 | | public class HistoryBrowserModel extends ChangeNotifier implements LayerChangeListener, DataSetListener { |
| 76 | public class HistoryBrowserModel extends ChangeNotifier implements ActiveLayerChangeListener, DataSetListener { |
77 | 77 | /** the history of an OsmPrimitive */ |
78 | 78 | private History history; |
79 | 79 | private HistoryOsmPrimitive reference; |
… |
… |
public class HistoryBrowserModel extends ChangeNotifier implements LayerChangeLi
|
110 | 110 | editLayer.data.addDataSetListener(this); |
111 | 111 | } |
112 | 112 | } |
113 | | MapView.addLayerChangeListener(this); |
| 113 | Main.getLayerManager().addActiveLayerChangeListener(this); |
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
… |
… |
public class HistoryBrowserModel extends ChangeNotifier implements LayerChangeLi
|
669 | 669 | if (editLayer != null) { |
670 | 670 | editLayer.data.removeDataSetListener(this); |
671 | 671 | } |
672 | | MapView.removeLayerChangeListener(this); |
| 672 | Main.getLayerManager().removeActiveLayerChangeListener(this); |
673 | 673 | } |
674 | 674 | |
675 | 675 | /* ---------------------------------------------------------------------- */ |
… |
… |
public class HistoryBrowserModel extends ChangeNotifier implements LayerChangeLi
|
746 | 746 | } |
747 | 747 | |
748 | 748 | /* ---------------------------------------------------------------------- */ |
749 | | /* LayerChangeListener */ |
| 749 | /* ActiveLayerChangeListener */ |
750 | 750 | /* ---------------------------------------------------------------------- */ |
751 | 751 | @Override |
752 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
| 752 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
| 753 | Layer oldLayer = e.getPreviousActiveLayer(); |
753 | 754 | if (oldLayer instanceof OsmDataLayer) { |
754 | 755 | OsmDataLayer l = (OsmDataLayer) oldLayer; |
755 | 756 | l.data.removeDataSetListener(this); |
756 | 757 | } |
| 758 | Layer newLayer = e.getSource().getActiveLayer(); |
757 | 759 | if (!(newLayer instanceof OsmDataLayer)) { |
758 | 760 | latest = null; |
759 | 761 | fireModelChange(); |
… |
… |
public class HistoryBrowserModel extends ChangeNotifier implements LayerChangeLi
|
772 | 774 | fireModelChange(); |
773 | 775 | } |
774 | 776 | |
775 | | @Override |
776 | | public void layerAdded(Layer newLayer) { |
777 | | // Do nothing |
778 | | } |
779 | | |
780 | | @Override |
781 | | public void layerRemoved(Layer oldLayer) { |
782 | | // Do nothing |
783 | | } |
784 | | |
785 | 777 | /** |
786 | 778 | * Creates a {@link HistoryOsmPrimitive} from a {@link OsmPrimitive} |
787 | 779 | * |
… |
… |
public class HistoryBrowserModel extends ChangeNotifier implements LayerChangeLi
|
824 | 816 | return clone; |
825 | 817 | } |
826 | 818 | } |
| 819 | |
827 | 820 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java b/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
index 4b3a885..d475296 100644
a
|
b
|
import org.openstreetmap.josm.data.preferences.IntegerProperty;
|
77 | 77 | import org.openstreetmap.josm.gui.ExtendedDialog; |
78 | 78 | import org.openstreetmap.josm.gui.MapFrame; |
79 | 79 | import org.openstreetmap.josm.gui.MapView; |
80 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
81 | 80 | import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; |
82 | 81 | import org.openstreetmap.josm.gui.PleaseWaitRunnable; |
83 | 82 | import org.openstreetmap.josm.gui.dialogs.LayerListDialog; |
84 | 83 | import org.openstreetmap.josm.gui.dialogs.LayerListPopup; |
| 84 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 85 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 86 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 87 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
85 | 88 | import org.openstreetmap.josm.gui.progress.ProgressMonitor; |
86 | 89 | import org.openstreetmap.josm.gui.util.GuiHelper; |
87 | 90 | import org.openstreetmap.josm.io.WMSLayerImporter; |
… |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener {
|
163 | 166 | super(info); |
164 | 167 | setBackgroundLayer(true); |
165 | 168 | this.setVisible(true); |
166 | | MapView.addZoomChangeListener(this); |
167 | 169 | } |
168 | 170 | |
169 | 171 | protected abstract TileLoaderFactory getTileLoaderFactory(); |
… |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener {
|
625 | 627 | } |
626 | 628 | } |
627 | 629 | }; |
628 | | Main.map.mapView.addMouseListener(adapter); |
| 630 | Main.getLayerManager().addLayerChangeListener(new LayerChangeListener() { |
629 | 631 | |
630 | | MapView.addLayerChangeListener(new LayerChangeListener() { |
631 | 632 | @Override |
632 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
633 | | // |
| 633 | public void layerRemoving(LayerRemoveEvent e) { |
| 634 | if (e.getRemovedLayer() == AbstractTileSourceLayer.this) { |
| 635 | Main.map.mapView.removeMouseListener(adapter); |
| 636 | e.getSource().removeLayerChangeListener(this); |
| 637 | MapView.removeZoomChangeListener(AbstractTileSourceLayer.this); |
| 638 | } |
634 | 639 | } |
635 | 640 | |
636 | 641 | @Override |
637 | | public void layerAdded(Layer newLayer) { |
638 | | // |
| 642 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 643 | // ignored |
639 | 644 | } |
640 | 645 | |
641 | 646 | @Override |
642 | | public void layerRemoved(Layer oldLayer) { |
643 | | if (oldLayer == AbstractTileSourceLayer.this) { |
644 | | Main.map.mapView.removeMouseListener(adapter); |
645 | | MapView.removeLayerChangeListener(this); |
646 | | MapView.removeZoomChangeListener(AbstractTileSourceLayer.this); |
| 647 | public void layerAdded(LayerAddEvent e) { |
| 648 | if (e.getAddedLayer() == AbstractTileSourceLayer.this) { |
| 649 | Main.map.mapView.addMouseListener(adapter); |
| 650 | MapView.addZoomChangeListener(AbstractTileSourceLayer.this); |
647 | 651 | } |
648 | 652 | } |
649 | 653 | }); |
650 | | |
651 | 654 | // FIXME: why do we need this? Without this, if you add a WMS layer and do not move the mouse, sometimes, tiles do not |
652 | 655 | // start loading. |
653 | 656 | Main.map.repaint(500); |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java b/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
index 8a57ab9..f2a95b7 100644
a
|
b
|
import javax.swing.JPanel;
|
22 | 22 | import javax.swing.JToggleButton; |
23 | 23 | |
24 | 24 | import org.openstreetmap.josm.Main; |
25 | | import org.openstreetmap.josm.gui.MapView; |
26 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
27 | 25 | import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action; |
28 | 26 | import org.openstreetmap.josm.gui.dialogs.ToggleDialog; |
29 | 27 | import org.openstreetmap.josm.gui.layer.Layer; |
| 28 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; |
| 29 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; |
| 30 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; |
| 31 | import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; |
| 32 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 33 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
30 | 34 | import org.openstreetmap.josm.tools.ImageProvider; |
31 | 35 | import org.openstreetmap.josm.tools.Shortcut; |
32 | 36 | import org.openstreetmap.josm.tools.date.DateUtils; |
33 | 37 | |
34 | | public final class ImageViewerDialog extends ToggleDialog implements LayerChangeListener { |
| 38 | public final class ImageViewerDialog extends ToggleDialog implements LayerChangeListener, ActiveLayerChangeListener { |
35 | 39 | |
36 | 40 | private static final String COMMAND_ZOOM = "zoom"; |
37 | 41 | private static final String COMMAND_CENTERVIEW = "centre"; |
… |
… |
public final class ImageViewerDialog extends ToggleDialog implements LayerChange
|
75 | 79 | super(tr("Geotagged Images"), "geoimage", tr("Display geotagged images"), Shortcut.registerShortcut("tools:geotagged", |
76 | 80 | tr("Tool: {0}", tr("Display geotagged images")), KeyEvent.VK_Y, Shortcut.DIRECT), 200); |
77 | 81 | build(); |
78 | | MapView.addLayerChangeListener(this); |
| 82 | Main.getLayerManager().addActiveLayerChangeListener(this); |
| 83 | Main.getLayerManager().addLayerChangeListener(this); |
79 | 84 | } |
80 | 85 | |
81 | 86 | protected void build() { |
… |
… |
public final class ImageViewerDialog extends ToggleDialog implements LayerChange
|
195 | 200 | |
196 | 201 | @Override |
197 | 202 | public void destroy() { |
198 | | MapView.removeLayerChangeListener(this); |
| 203 | Main.getLayerManager().removeActiveLayerChangeListener(this); |
| 204 | Main.getLayerManager().removeLayerChangeListener(this); |
199 | 205 | super.destroy(); |
200 | 206 | } |
201 | 207 | |
… |
… |
public final class ImageViewerDialog extends ToggleDialog implements LayerChange
|
409 | 415 | } |
410 | 416 | |
411 | 417 | @Override |
412 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
413 | | if (currentLayer == null && newLayer instanceof GeoImageLayer) { |
414 | | ((GeoImageLayer) newLayer).showFirstPhoto(); |
415 | | } |
| 418 | public void layerAdded(LayerAddEvent e) { |
| 419 | showLayer(e.getAddedLayer()); |
416 | 420 | } |
417 | 421 | |
418 | 422 | @Override |
419 | | public void layerAdded(Layer newLayer) { |
420 | | if (currentLayer == null && newLayer instanceof GeoImageLayer) { |
421 | | ((GeoImageLayer) newLayer).showFirstPhoto(); |
422 | | } |
423 | | } |
424 | | |
425 | | @Override |
426 | | public void layerRemoved(Layer oldLayer) { |
| 423 | public void layerRemoving(LayerRemoveEvent e) { |
427 | 424 | // Clear current image and layer if current layer is deleted |
428 | | if (currentLayer != null && currentLayer.equals(oldLayer)) { |
| 425 | if (currentLayer != null && currentLayer.equals(e.getRemovedLayer())) { |
429 | 426 | showImage(null, null); |
430 | 427 | } |
431 | 428 | // Check buttons state in case of layer merging |
432 | | if (currentLayer != null && oldLayer instanceof GeoImageLayer) { |
| 429 | if (currentLayer != null && e.getRemovedLayer() instanceof GeoImageLayer) { |
433 | 430 | currentLayer.checkPreviousNextButtons(); |
434 | 431 | } |
435 | 432 | } |
| 433 | |
| 434 | @Override |
| 435 | public void layerOrderChanged(LayerOrderChangeEvent e) { |
| 436 | // ignored |
| 437 | } |
| 438 | |
| 439 | @Override |
| 440 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
| 441 | showLayer(e.getSource().getActiveLayer()); |
| 442 | } |
| 443 | |
| 444 | private void showLayer(Layer newLayer) { |
| 445 | if (currentLayer == null && newLayer instanceof GeoImageLayer) { |
| 446 | ((GeoImageLayer) newLayer).showFirstPhoto(); |
| 447 | } |
| 448 | } |
| 449 | |
436 | 450 | } |
-
diff --git a/src/org/openstreetmap/josm/io/FileExporter.java b/src/org/openstreetmap/josm/io/FileExporter.java
index 7191b92..fd8e09d 100644
a
|
b
|
import java.io.File;
|
7 | 7 | import java.io.IOException; |
8 | 8 | |
9 | 9 | import org.openstreetmap.josm.actions.ExtensionFileFilter; |
10 | | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
11 | 10 | import org.openstreetmap.josm.gui.layer.Layer; |
| 11 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
| 12 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; |
12 | 13 | |
13 | | public abstract class FileExporter implements LayerChangeListener { |
| 14 | public abstract class FileExporter implements ActiveLayerChangeListener { |
14 | 15 | |
15 | 16 | public final ExtensionFileFilter filter; |
16 | 17 | |
… |
… |
public abstract class FileExporter implements LayerChangeListener {
|
53 | 54 | } |
54 | 55 | |
55 | 56 | @Override |
56 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
| 57 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
57 | 58 | // To be overriden by subclasses if their enabled state depends of the active layer nature |
58 | 59 | } |
59 | 60 | |
60 | | @Override |
61 | | public void layerAdded(Layer newLayer) { |
62 | | // To be overriden by subclasses if needed |
63 | | } |
64 | | |
65 | | @Override |
66 | | public void layerRemoved(Layer oldLayer) { |
67 | | // To be overriden by subclasses if needed |
68 | | } |
69 | | |
70 | 61 | /** |
71 | 62 | * Determines if this exporter has been canceled during export. |
72 | 63 | * @return true if this {@code FileExporter} has been canceled |
-
diff --git a/src/org/openstreetmap/josm/io/WMSLayerExporter.java b/src/org/openstreetmap/josm/io/WMSLayerExporter.java
index 15e765a..ce0d46d 100644
a
|
b
|
import org.openstreetmap.josm.data.Preferences;
|
11 | 11 | import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry; |
12 | 12 | import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; |
13 | 13 | import org.openstreetmap.josm.gui.layer.Layer; |
| 14 | import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; |
14 | 15 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
15 | 16 | |
16 | 17 | /** |
… |
… |
public class WMSLayerExporter extends FileExporter {
|
46 | 47 | |
47 | 48 | } |
48 | 49 | |
| 50 | |
49 | 51 | @Override |
50 | | public void activeLayerChange(Layer oldLayer, Layer newLayer) { |
51 | | setEnabled(newLayer instanceof AbstractTileSourceLayer); |
| 52 | public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { |
| 53 | setEnabled(e.getSource().getActiveLayer() instanceof AbstractTileSourceLayer); |
52 | 54 | } |
53 | 55 | } |