- Timestamp:
- 2016-06-15T17:25:04+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java
r10345 r10386 17 17 18 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.gui.MapView;20 19 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 21 20 import org.openstreetmap.josm.io.AllFormatsImporter; … … 67 66 FileImporter importer = importerClass.getConstructor().newInstance(); 68 67 importers.add(importer); 69 MapView.addLayerChangeListener(importer);70 68 } catch (ReflectiveOperationException e) { 71 69 if (Main.isDebugEnabled()) { -
trunk/src/org/openstreetmap/josm/actions/ZoomToAction.java
r8443 r10386 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;15 14 import org.openstreetmap.josm.gui.conflict.pair.nodes.NodeListTable; 16 15 import org.openstreetmap.josm.gui.conflict.pair.relation.RelationMemberTable; 17 16 import org.openstreetmap.josm.gui.dialogs.relation.MemberTable; 18 import org.openstreetmap.josm.gui.layer.Layer; 17 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 18 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 19 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 20 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 21 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 22 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 19 23 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 20 24 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTable; 21 25 import org.openstreetmap.josm.tools.CheckParameterUtil; 22 26 23 public class ZoomToAction extends AbstractAction implements LayerChangeListener, ListSelectionListener {27 public class ZoomToAction extends AbstractAction implements LayerChangeListener, ActiveLayerChangeListener, ListSelectionListener { 24 28 25 29 private final OsmPrimitivesTable table; … … 98 102 99 103 @Override 100 public void active LayerChange(Layer oldLayer, Layer newLayer) {104 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 101 105 updateEnabledState(); 102 106 } 103 107 104 108 @Override 105 public void layerAdded(Layer newLayer) {109 public void layerAdded(LayerAddEvent e) { 106 110 updateEnabledState(); 107 111 } 108 112 109 113 @Override 110 public void layerRemov ed(Layer oldLayer) {114 public void layerRemoving(LayerRemoveEvent e) { 111 115 updateEnabledState(); 112 116 } 117 118 @Override 119 public void layerOrderChanged(LayerOrderChangeEvent e) { 120 // Do nothing 121 } 113 122 } -
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r10364 r10386 34 34 import org.openstreetmap.josm.data.preferences.BooleanProperty; 35 35 import org.openstreetmap.josm.data.preferences.IntegerProperty; 36 import org.openstreetmap.josm.gui.MapView;37 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;38 36 import org.openstreetmap.josm.gui.Notification; 39 import org.openstreetmap.josm.gui.layer.Layer; 37 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 38 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 39 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 40 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 40 41 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 41 42 import org.openstreetmap.josm.gui.util.GuiHelper; … … 59 60 * 60 61 * The deleted layers dir keeps at most PROP_DELETED_LAYERS files. 62 * 63 * @since 3378 (creation) 64 * @since 10386 (new LayerChangeListener interface) 61 65 */ 62 66 public class AutosaveTask extends TimerTask implements LayerChangeListener, Listener { … … 125 129 timer = new Timer(true); 126 130 timer.schedule(this, 1000L, PROP_INTERVAL.get() * 1000L); 127 Ma pView.addLayerChangeListener(this);131 Main.getLayerManager().addLayerChangeListener(this); 128 132 if (Main.isDisplayingMapView()) { 129 133 for (OsmDataLayer l: Main.getLayerManager().getLayersOfType(OsmDataLayer.class)) { … … 250 254 251 255 @Override 252 public void activeLayerChange(Layer oldLayer, Layer newLayer) {256 public void layerOrderChanged(LayerOrderChangeEvent e) { 253 257 // Do nothing 254 258 } … … 262 266 263 267 @Override 264 public void layerAdded(Layer newLayer) {265 if ( newLayerinstanceof OsmDataLayer) {266 registerNewlayer((OsmDataLayer) newLayer);268 public void layerAdded(LayerAddEvent e) { 269 if (e.getAddedLayer() instanceof OsmDataLayer) { 270 registerNewlayer((OsmDataLayer) e.getAddedLayer()); 267 271 } 268 272 } 269 273 270 274 @Override 271 public void layerRemov ed(Layer oldLayer) {272 if ( oldLayerinstanceof OsmDataLayer) {275 public void layerRemoving(LayerRemoveEvent e) { 276 if (e.getRemovedLayer() instanceof OsmDataLayer) { 273 277 synchronized (layersLock) { 274 OsmDataLayer osmLayer = (OsmDataLayer) oldLayer;278 OsmDataLayer osmLayer = (OsmDataLayer) e.getRemovedLayer(); 275 279 osmLayer.data.removeDataSetListener(datasetAdapter); 276 280 Iterator<AutosaveLayerInfo> it = layersInfo.iterator(); -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java
r10378 r10386 18 18 import org.openstreetmap.josm.data.osm.PrimitiveId; 19 19 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 20 import org.openstreetmap.josm.gui.MapView; 21 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 22 import org.openstreetmap.josm.gui.layer.Layer; 20 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 21 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 22 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 23 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 23 24 import org.openstreetmap.josm.tools.CheckParameterUtil; 24 25 … … 26 27 * A data set holding histories of OSM primitives. 27 28 * @since 1670 29 * @since 10386 (new LayerChangeListener interface) 28 30 */ 29 31 public class HistoryDataSet implements LayerChangeListener { … … 39 41 if (historyDataSet == null) { 40 42 historyDataSet = new HistoryDataSet(); 41 Ma pView.addLayerChangeListener(historyDataSet);43 Main.getLayerManager().addLayerChangeListener(historyDataSet); 42 44 } 43 45 return historyDataSet; … … 201 203 /* ------------------------------------------------------------------------------ */ 202 204 @Override 203 public void activeLayerChange(Layer oldLayer, Layer newLayer) {205 public void layerOrderChanged(LayerOrderChangeEvent e) { 204 206 /* irrelevant in this context */ 205 207 } 206 208 207 209 @Override 208 public void layerAdded(Layer newLayer) {210 public void layerAdded(LayerAddEvent e) { 209 211 /* irrelevant in this context */ 210 212 } 211 213 212 214 @Override 213 public void layerRemov ed(Layer oldLayer) {215 public void layerRemoving(LayerRemoveEvent e) { 214 216 if (!Main.isDisplayingMapView()) return; 215 if (Main. map.mapView.getNumLayers() == 0) {217 if (Main.getLayerManager().getLayers().isEmpty()) { 216 218 data.clear(); 217 219 fireCacheCleared(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r10378 r10386 62 62 import org.openstreetmap.josm.gui.DefaultNameFormatter; 63 63 import org.openstreetmap.josm.gui.MapView; 64 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;65 64 import org.openstreetmap.josm.gui.NavigatableComponent; 66 65 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; … … 69 68 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 70 69 import org.openstreetmap.josm.gui.layer.Layer; 70 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 71 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 72 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 73 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 74 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 75 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 71 76 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 72 77 import org.openstreetmap.josm.gui.util.GuiHelper; … … 83 88 84 89 /** 85 * A dialog showing all known relations, with buttons to add, edit, and 86 * delete them. 90 * A dialog showing all known relations, with buttons to add, edit, and delete them. 87 91 * 88 92 * We don't have such dialogs for nodes, segments, and ways, because those … … 220 224 @Override 221 225 public void showNotify() { 222 MapView.addLayerChangeListener(newAction); 226 Main.getLayerManager().addLayerChangeListener(newAction); 227 Main.getLayerManager().addActiveLayerChangeListener(newAction); 223 228 MapView.addZoomChangeListener(this); 224 229 newAction.updateEnabledState(); … … 232 237 @Override 233 238 public void hideNotify() { 234 MapView.removeLayerChangeListener(newAction); 239 Main.getLayerManager().removeActiveLayerChangeListener(newAction); 240 Main.getLayerManager().removeLayerChangeListener(newAction); 235 241 MapView.removeZoomChangeListener(this); 236 242 DatasetEventManager.getInstance().removeDatasetListener(this); … … 345 351 346 352 /** 347 * The action for creating a new relation 348 * 349 */ 350 static class NewAction extends AbstractAction implements LayerChangeListener { 353 * The action for creating a new relation. 354 */ 355 static class NewAction extends AbstractAction implements LayerChangeListener, ActiveLayerChangeListener { 351 356 NewAction() { 352 357 putValue(SHORT_DESCRIPTION, tr("Create a new relation")); … … 370 375 371 376 @Override 372 public void active LayerChange(Layer oldLayer, Layer newLayer) {377 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 373 378 updateEnabledState(); 374 379 } 375 380 376 381 @Override 377 public void layerAdded(Layer newLayer) {382 public void layerAdded(LayerAddEvent e) { 378 383 updateEnabledState(); 379 384 } 380 385 381 386 @Override 382 public void layerRemov ed(Layer oldLayer) {387 public void layerRemoving(LayerRemoveEvent e) { 383 388 updateEnabledState(); 389 } 390 391 @Override 392 public void layerOrderChanged(LayerOrderChangeEvent e) { 393 // Do nothing 384 394 } 385 395 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r10070 r10386 28 28 import org.openstreetmap.josm.data.osm.RelationMember; 29 29 import org.openstreetmap.josm.data.osm.Way; 30 import org.openstreetmap.josm.gui.MapView;31 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;32 30 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType; 33 31 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction; 34 import org.openstreetmap.josm.gui.layer.Layer; 32 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 33 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 34 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 35 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 36 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 37 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 35 38 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 36 39 import org.openstreetmap.josm.gui.util.HighlightHelper; … … 82 85 JPopupMenu menu = super.buildPopupMenu(); 83 86 zoomToGap = new ZoomToGapAction(); 84 MapView.addLayerChangeListener(zoomToGap); 87 Main.getLayerManager().addLayerChangeListener(zoomToGap); 88 Main.getLayerManager().addActiveLayerChangeListener(zoomToGap); 85 89 getSelectionModel().addListSelectionListener(zoomToGap); 86 90 menu.add(zoomToGap); … … 137 141 public void unlinkAsListener() { 138 142 super.unlinkAsListener(); 139 MapView.removeLayerChangeListener(zoomToGap); 143 Main.getLayerManager().removeLayerChangeListener(zoomToGap); 144 Main.getLayerManager().removeActiveLayerChangeListener(zoomToGap); 140 145 } 141 146 … … 189 194 } 190 195 191 private class ZoomToGapAction extends AbstractAction implements LayerChangeListener, ListSelectionListener {196 private class ZoomToGapAction extends AbstractAction implements LayerChangeListener, ActiveLayerChangeListener, ListSelectionListener { 192 197 193 198 /** … … 241 246 242 247 @Override 243 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 244 updateEnabledState(); 245 } 246 247 @Override 248 public void layerAdded(Layer newLayer) { 249 updateEnabledState(); 250 } 251 252 @Override 253 public void layerRemoved(Layer oldLayer) { 254 updateEnabledState(); 248 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 249 updateEnabledState(); 250 } 251 252 @Override 253 public void layerAdded(LayerAddEvent e) { 254 updateEnabledState(); 255 } 256 257 @Override 258 public void layerRemoving(LayerRemoveEvent e) { 259 updateEnabledState(); 260 } 261 262 @Override 263 public void layerOrderChanged(LayerOrderChangeEvent e) { 264 // Do nothing 255 265 } 256 266 } -
trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java
r10173 r10386 22 22 import org.openstreetmap.josm.data.validation.TestError; 23 23 import org.openstreetmap.josm.gui.MapView; 24 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;25 24 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 26 25 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 26 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 27 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 28 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 29 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 27 30 import org.openstreetmap.josm.tools.ImageProvider; 28 31 import org.openstreetmap.josm.tools.MultiMap; … … 32 35 * 33 36 * @author frsantos 37 * 38 * @since 3669 (creation) 39 * @since 10386 (new LayerChangeListener interface) 34 40 */ 35 41 public class ValidatorLayer extends Layer implements LayerChangeListener { … … 42 48 public ValidatorLayer() { 43 49 super(tr("Validation errors")); 44 Ma pView.addLayerChangeListener(this);50 Main.getLayerManager().addLayerChangeListener(this); 45 51 } 46 52 … … 143 149 144 150 @Override 145 public void activeLayerChange(Layer oldLayer, Layer newLayer) {151 public void layerOrderChanged(LayerOrderChangeEvent e) { 146 152 // Do nothing 147 153 } 148 154 149 155 @Override 150 public void layerAdded(Layer newLayer) {156 public void layerAdded(LayerAddEvent e) { 151 157 // Do nothing 152 158 } … … 156 162 */ 157 163 @Override 158 public void layerRemov ed(Layer oldLayer) {159 if ( oldLayerinstanceof OsmDataLayer && Main.isDisplayingMapView() && !Main.main.hasEditLayer()) {164 public void layerRemoving(LayerRemoveEvent e) { 165 if (e.getRemovedLayer() instanceof OsmDataLayer && Main.isDisplayingMapView() && !Main.main.hasEditLayer()) { 160 166 Main.main.removeLayer(this); 161 } else if ( oldLayer== this) {162 Ma pView.removeLayerChangeListener(this);167 } else if (e.getRemovedLayer() == this) { 168 Main.getLayerManager().removeLayerChangeListener(this); 163 169 OsmValidator.errorLayer = null; 164 170 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r10364 r10386 51 51 import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener; 52 52 import org.openstreetmap.josm.gui.MapView; 53 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;54 53 import org.openstreetmap.josm.gui.NavigatableComponent; 55 54 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 62 61 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToPreviousMarker; 63 62 import org.openstreetmap.josm.gui.layer.Layer; 63 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 64 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 65 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 66 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 67 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 68 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 64 69 import org.openstreetmap.josm.gui.util.GuiHelper; 65 70 import org.openstreetmap.josm.io.JpgImporter; … … 889 894 mapModeListener.mapModeChange(null, Main.map.mapMode); 890 895 891 Ma pView.addLayerChangeListener(newLayerChangeListener() {896 Main.getLayerManager().addActiveLayerChangeListener(new ActiveLayerChangeListener() { 892 897 @Override 893 public void active LayerChange(Layer oldLayer, Layer newLayer) {894 if ( newLayer== GeoImageLayer.this) {898 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 899 if (Main.getLayerManager().getActiveLayer() == GeoImageLayer.this) { 895 900 // only in select mode it is possible to click the images 896 901 Main.map.selectSelectTool(false); 897 902 } 898 903 } 899 904 }); 905 906 Main.getLayerManager().addLayerChangeListener(new LayerChangeListener() { 900 907 @Override 901 public void layerAdded(Layer newLayer) {908 public void layerAdded(LayerAddEvent e) { 902 909 // Do nothing 903 910 } 904 911 905 912 @Override 906 public void layerRemov ed(Layer oldLayer) {907 if ( oldLayer== GeoImageLayer.this) {913 public void layerRemoving(LayerRemoveEvent e) { 914 if (e.getRemovedLayer() == GeoImageLayer.this) { 908 915 stopLoadThumbs(); 909 916 Main.map.mapView.removeMouseListener(mouseAdapter); … … 915 922 data = null; 916 923 // stop listening to layer change events 917 MapView.removeLayerChangeListener(this); 918 } 924 Main.getLayerManager().removeLayerChangeListener(this); 925 } 926 } 927 928 @Override 929 public void layerOrderChanged(LayerOrderChangeEvent e) { 930 // Do nothing 919 931 } 920 932 }); -
trunk/src/org/openstreetmap/josm/gui/widgets/OsmPrimitivesTable.java
r9497 r10386 10 10 import javax.swing.table.TableColumnModel; 11 11 12 import org.openstreetmap.josm.Main; 12 13 import org.openstreetmap.josm.actions.ZoomToAction; 13 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.gui.MapView;15 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 16 … … 83 83 JPopupMenu menu = new JPopupMenu(); 84 84 zoomToAction = buildZoomToAction(); 85 MapView.addLayerChangeListener(zoomToAction); 85 Main.getLayerManager().addLayerChangeListener(zoomToAction); 86 Main.getLayerManager().addActiveLayerChangeListener(zoomToAction); 86 87 getSelectionModel().addListSelectionListener(zoomToAction); 87 88 menu.add(zoomToAction); … … 90 91 91 92 public void unlinkAsListener() { 92 MapView.removeLayerChangeListener(zoomToAction); 93 Main.getLayerManager().removeLayerChangeListener(zoomToAction); 94 Main.getLayerManager().removeActiveLayerChangeListener(zoomToAction); 93 95 } 94 96 -
trunk/src/org/openstreetmap/josm/io/FileImporter.java
r10212 r10386 13 13 import org.openstreetmap.josm.actions.ExtensionFileFilter; 14 14 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 15 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;16 15 import org.openstreetmap.josm.gui.Notification; 17 import org.openstreetmap.josm.gui.layer.Layer;18 16 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 19 17 import org.openstreetmap.josm.gui.util.GuiHelper; … … 22 20 * Abstract file importer. 23 21 * @since 1637 22 * @since 10386 (signature) 24 23 */ 25 public abstract class FileImporter implements Comparable<FileImporter> , LayerChangeListener{24 public abstract class FileImporter implements Comparable<FileImporter> { 26 25 27 26 /** … … 182 181 this.enabled = enabled; 183 182 } 184 185 @Override186 public void activeLayerChange(Layer oldLayer, Layer newLayer) {187 // To be overriden by subclasses if their enabled state depends of the active layer nature188 }189 190 @Override191 public void layerAdded(Layer newLayer) {192 // To be overriden by subclasses if needed193 }194 195 @Override196 public void layerRemoved(Layer oldLayer) {197 // To be overriden by subclasses if needed198 }199 183 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayerTest.java
r10364 r10386 44 44 try { 45 45 Main.main.addLayer(gpxLayer); 46 assertEquals(1, Main. map.mapView.getNumLayers());46 assertEquals(1, Main.getLayerManager().getLayers().size()); 47 47 new Loader( 48 48 Collections.singleton(new File(TestUtils.getRegressionDataFile(12255, "G0016941.JPG"))), 49 49 gpxLayer).run(); 50 assertEquals(2, Main. map.mapView.getNumLayers());50 assertEquals(2, Main.getLayerManager().getLayers().size()); 51 51 GeoImageLayer layer = Main.getLayerManager().getLayersOfType(GeoImageLayer.class).iterator().next(); 52 52 try {
Note:
See TracChangeset
for help on using the changeset viewer.