-
diff --git a/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java b/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
index 9d20e99..f857d65 100644
|
a
|
b
|
public class AddImageryLayerAction extends JosmAction implements AdaptableAction
|
| 168 | 168 | setEnabled(false); |
| 169 | 169 | } else if (type == ImageryType.TMS || type == ImageryType.BING || type == ImageryType.SCANEX) { |
| 170 | 170 | setEnabled(true); |
| 171 | | } else if (Main.isDisplayingMapView() && !Main.map.mapView.getAllLayers().isEmpty()) { |
| 172 | | setEnabled(true); |
| 173 | 171 | } else { |
| 174 | | setEnabled(false); |
| | 172 | setEnabled(!Main.getLayerManager().getLayers().isEmpty()); |
| 175 | 173 | } |
| 176 | 174 | } |
| 177 | 175 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/AutoScaleAction.java b/src/org/openstreetmap/josm/actions/AutoScaleAction.java
index 30798cb..ba02d71 100644
|
a
|
b
|
public class AutoScaleAction extends JosmAction {
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | private static BoundingXYVisitor modeData(BoundingXYVisitor v) { |
| 263 | | for (Layer l : Main.map.mapView.getAllLayers()) { |
| | 263 | for (Layer l : Main.getLayerManager().getLayers()) { |
| 264 | 264 | l.visitBoundingBox(v); |
| 265 | 265 | } |
| 266 | 266 | return v; |
| … |
… |
public class AutoScaleAction extends JosmAction {
|
| 363 | 363 | setEnabled(Main.isDisplayingMapView() && Main.map.mapView.hasZoomRedoEntries()); |
| 364 | 364 | break; |
| 365 | 365 | default: |
| 366 | | setEnabled(Main.isDisplayingMapView() && Main.map.mapView.hasLayers()); |
| | 366 | setEnabled(!Main.getLayerManager().getLayers().isEmpty()); |
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | |
-
diff --git a/src/org/openstreetmap/josm/actions/DeleteLayerAction.java b/src/org/openstreetmap/josm/actions/DeleteLayerAction.java
index 893449f..23bcdd8 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.actions; |
| 3 | 3 | |
| 4 | | import static org.openstreetmap.josm.tools.I18n.tr; |
| 5 | 4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht; |
| | 5 | import static org.openstreetmap.josm.tools.I18n.tr; |
| 6 | 6 | |
| 7 | 7 | import java.awt.event.ActionEvent; |
| 8 | 8 | import java.awt.event.KeyEvent; |
| 9 | 9 | import java.util.Collections; |
| 10 | 10 | |
| 11 | 11 | import org.openstreetmap.josm.Main; |
| 12 | | import org.openstreetmap.josm.tools.Shortcut; |
| 13 | 12 | import org.openstreetmap.josm.gui.layer.Layer; |
| | 13 | import org.openstreetmap.josm.tools.Shortcut; |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Deletes the active layer. |
| … |
… |
public final class DeleteLayerAction extends JosmAction {
|
| 41 | 41 | |
| 42 | 42 | @Override |
| 43 | 43 | protected void updateEnabledState() { |
| 44 | | setEnabled(Main.isDisplayingMapView() && Main.map.mapView.getActiveLayer() != null); |
| | 44 | setEnabled(Main.getLayerManager().getActiveLayer() != null); |
| 45 | 45 | } |
| 46 | 46 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/DownloadNotesInViewAction.java b/src/org/openstreetmap/josm/actions/DownloadNotesInViewAction.java
index 97a3a10..65c9e3b 100644
|
a
|
b
|
public final class DownloadNotesInViewAction extends JosmAction {
|
| 42 | 42 | |
| 43 | 43 | @Override |
| 44 | 44 | protected void updateEnabledState() { |
| 45 | | setEnabled(Main.isDisplayingMapView() |
| 46 | | && Main.map.mapView.getActiveLayer() != null |
| | 45 | setEnabled(Main.getLayerManager().getActiveLayer() != null |
| 47 | 46 | && !Main.isOffline(OnlineResource.OSM_API)); |
| 48 | 47 | } |
| 49 | 48 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/GpxExportAction.java b/src/org/openstreetmap/josm/actions/GpxExportAction.java
index 50a16d5..0fd1650 100644
|
a
|
b
|
public class GpxExportAction extends DiskAccessAction {
|
| 42 | 42 | * @return The layer to export, either a {@link GpxLayer} or {@link OsmDataLayer}. |
| 43 | 43 | */ |
| 44 | 44 | protected Layer getLayer() { |
| 45 | | if (!Main.isDisplayingMapView()) |
| 46 | | return null; |
| 47 | | Layer layer = Main.map.mapView.getActiveLayer(); |
| | 45 | Layer layer = Main.getLayerManager().getActiveLayer(); |
| 48 | 46 | return (layer instanceof GpxLayer || layer instanceof OsmDataLayer) ? layer : null; |
| 49 | 47 | } |
| 50 | 48 | |
-
diff --git a/src/org/openstreetmap/josm/actions/MapRectifierWMSmenuAction.java b/src/org/openstreetmap/josm/actions/MapRectifierWMSmenuAction.java
index e15a6ca..a57e538 100644
|
a
|
b
|
public class MapRectifierWMSmenuAction extends JosmAction {
|
| 238 | 238 | |
| 239 | 239 | @Override |
| 240 | 240 | protected void updateEnabledState() { |
| 241 | | setEnabled(Main.isDisplayingMapView() && !Main.map.mapView.getAllLayers().isEmpty()); |
| | 241 | setEnabled(!Main.getLayerManager().getLayers().isEmpty()); |
| 242 | 242 | } |
| 243 | 243 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/MergeLayerAction.java b/src/org/openstreetmap/josm/actions/MergeLayerAction.java
index 7e2e380..683285f 100644
|
a
|
b
|
public class MergeLayerAction extends AbstractMergeAction {
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | if (layerMerged) { |
| 66 | | Main.map.mapView.setActiveLayer(targetLayer); |
| | 66 | Main.getLayerManager().setActiveLayer(targetLayer); |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | }); |
-
diff --git a/src/org/openstreetmap/josm/actions/SaveActionBase.java b/src/org/openstreetmap/josm/actions/SaveActionBase.java
index e468f07..c812e1c 100644
|
a
|
b
|
public abstract class SaveActionBase extends DiskAccessAction {
|
| 51 | 51 | * @return {@code true} if the save operation succeeds |
| 52 | 52 | */ |
| 53 | 53 | public boolean doSave() { |
| 54 | | if (Main.isDisplayingMapView()) { |
| 55 | | Layer layer = Main.map.mapView.getActiveLayer(); |
| 56 | | if (layer != null && layer.isSavable()) { |
| 57 | | return doSave(layer); |
| 58 | | } |
| | 54 | Layer layer = Main.getLayerManager().getActiveLayer(); |
| | 55 | if (layer != null && layer.isSavable()) { |
| | 56 | return doSave(layer); |
| 59 | 57 | } |
| 60 | 58 | return false; |
| 61 | 59 | } |
| … |
… |
public abstract class SaveActionBase extends DiskAccessAction {
|
| 133 | 131 | */ |
| 134 | 132 | @Override |
| 135 | 133 | protected void updateEnabledState() { |
| 136 | | boolean check = Main.isDisplayingMapView() |
| 137 | | && Main.map.mapView.getActiveLayer() != null; |
| 138 | | if (!check) { |
| 139 | | setEnabled(false); |
| 140 | | return; |
| 141 | | } |
| 142 | | Layer layer = Main.map.mapView.getActiveLayer(); |
| 143 | | setEnabled(layer != null && layer.isSavable()); |
| | 134 | Layer activeLayer = Main.getLayerManager().getActiveLayer(); |
| | 135 | setEnabled(activeLayer != null && activeLayer.isSavable()); |
| 144 | 136 | } |
| 145 | 137 | |
| 146 | 138 | /** |
-
diff --git a/src/org/openstreetmap/josm/actions/SessionLoadAction.java b/src/org/openstreetmap/josm/actions/SessionLoadAction.java
index 260ca4b..cd390f2 100644
|
a
|
b
|
public class SessionLoadAction extends DiskAccessAction {
|
| 135 | 135 | Main.main.addLayer(l, (ViewportData) null); |
| 136 | 136 | } |
| 137 | 137 | if (active != null) { |
| 138 | | Main.map.mapView.setActiveLayer(active); |
| | 138 | Main.getLayerManager().setActiveLayer(active); |
| 139 | 139 | } |
| 140 | 140 | if (noMap) { |
| 141 | 141 | Main.map.setVisible(true); |
-
diff --git a/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java b/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java
index 3990ce88..5e16b54 100644
|
a
|
b
|
public class SessionSaveAsAction extends DiskAccessAction implements MapFrameLis
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | int active = -1; |
| 163 | | Layer activeLayer = Main.map.mapView.getActiveLayer(); |
| | 163 | Layer activeLayer = Main.getLayerManager().getActiveLayer(); |
| 164 | 164 | if (activeLayer != null) { |
| 165 | 165 | active = layersOut.indexOf(activeLayer); |
| 166 | 166 | } |
| … |
… |
public class SessionSaveAsAction extends DiskAccessAction implements MapFrameLis
|
| 203 | 203 | * Initializes action. |
| 204 | 204 | */ |
| 205 | 205 | public final void initialize() { |
| 206 | | layers = new ArrayList<>(Main.map.mapView.getAllLayersAsList()); |
| | 206 | layers = new ArrayList<>(Main.getLayerManager().getLayers()); |
| 207 | 207 | exporters = new HashMap<>(); |
| 208 | 208 | dependencies = new MultiMap<>(); |
| 209 | 209 | |
-
diff --git a/src/org/openstreetmap/josm/actions/UploadNotesAction.java b/src/org/openstreetmap/josm/actions/UploadNotesAction.java
index b30f061..3a2f6d9 100644
|
a
|
b
|
public class UploadNotesAction extends JosmAction {
|
| 30 | 30 | |
| 31 | 31 | @Override |
| 32 | 32 | public void actionPerformed(ActionEvent e) { |
| 33 | | List<NoteLayer> noteLayers = null; |
| 34 | | if (Main.map != null) { |
| 35 | | noteLayers = Main.map.mapView.getLayersOfType(NoteLayer.class); |
| 36 | | } |
| | 33 | List<NoteLayer> noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class); |
| 37 | 34 | NoteLayer layer; |
| 38 | | if (noteLayers != null && !noteLayers.isEmpty()) { |
| | 35 | if (!noteLayers.isEmpty()) { |
| 39 | 36 | layer = noteLayers.get(0); |
| 40 | 37 | } else { |
| 41 | 38 | Main.error("No note layer found"); |
| 42 | 39 | return; |
| 43 | 40 | } |
| 44 | | if (Main.isDebugEnabled()) { |
| 45 | | Main.debug("uploading note changes"); |
| 46 | | } |
| | 41 | Main.debug("uploading note changes"); |
| 47 | 42 | NoteData noteData = layer.getNoteData(); |
| 48 | 43 | |
| 49 | 44 | if (noteData == null || !noteData.isModified()) { |
| 50 | | if (Main.isDebugEnabled()) { |
| 51 | | Main.debug("No changed notes to upload"); |
| 52 | | } |
| | 45 | Main.debug("No changed notes to upload"); |
| 53 | 46 | return; |
| 54 | 47 | } |
| 55 | 48 | new UploadNotesTask().uploadNotes(noteData, new PleaseWaitProgressMonitor(tr("Uploading notes to server"))); |
-
diff --git a/src/org/openstreetmap/josm/actions/ZoomInAction.java b/src/org/openstreetmap/josm/actions/ZoomInAction.java
index 20853e9..d690678 100644
|
a
|
b
|
public final class ZoomInAction extends JosmAction {
|
| 51 | 51 | |
| 52 | 52 | @Override |
| 53 | 53 | protected void updateEnabledState() { |
| 54 | | setEnabled( |
| 55 | | Main.isDisplayingMapView() |
| 56 | | && Main.map.mapView.hasLayers() |
| 57 | | ); |
| | 54 | setEnabled(!Main.getLayerManager().getLayers().isEmpty()); |
| 58 | 55 | } |
| 59 | 56 | |
| 60 | 57 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/ZoomOutAction.java b/src/org/openstreetmap/josm/actions/ZoomOutAction.java
index 98bb1c2..1eb440d 100644
|
a
|
b
|
public final class ZoomOutAction extends JosmAction {
|
| 37 | 37 | |
| 38 | 38 | @Override |
| 39 | 39 | protected void updateEnabledState() { |
| 40 | | setEnabled( |
| 41 | | Main.isDisplayingMapView() |
| 42 | | && Main.map.mapView.hasLayers() |
| 43 | | ); |
| | 40 | setEnabled(!Main.getLayerManager().getLayers().isEmpty()); |
| 44 | 41 | } |
| 45 | 42 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java b/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
index b1e1324..024b189 100644
|
a
|
b
|
public class DownloadGpsTask extends AbstractDownloadTask<GpxData> {
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | private GpxLayer findGpxMergeLayer() { |
| 157 | | if (!Main.isDisplayingMapView()) |
| 158 | | return null; |
| 159 | 157 | boolean merge = Main.pref.getBoolean("download.gps.mergeWithLocal", false); |
| 160 | | Layer active = Main.map.mapView.getActiveLayer(); |
| | 158 | Layer active = Main.getLayerManager().getActiveLayer(); |
| 161 | 159 | if (active instanceof GpxLayer && (merge || ((GpxLayer) active).data.fromServer)) |
| 162 | 160 | return (GpxLayer) active; |
| 163 | | for (GpxLayer l : Main.map.mapView.getLayersOfType(GpxLayer.class)) { |
| | 161 | for (GpxLayer l : Main.getLayerManager().getLayersOfType(GpxLayer.class)) { |
| 164 | 162 | if (merge || l.data.fromServer) |
| 165 | 163 | return l; |
| 166 | 164 | } |
| … |
… |
public class DownloadGpsTask extends AbstractDownloadTask<GpxData> {
|
| 168 | 166 | } |
| 169 | 167 | |
| 170 | 168 | private MarkerLayer findMarkerMergeLayer(GpxLayer fromLayer) { |
| 171 | | if (!Main.isDisplayingMapView()) |
| 172 | | return null; |
| 173 | | for (MarkerLayer l : Main.map.mapView.getLayersOfType(MarkerLayer.class)) { |
| | 169 | for (MarkerLayer l : Main.getLayerManager().getLayersOfType(MarkerLayer.class)) { |
| 174 | 170 | if (fromLayer != null && l.fromLayer == fromLayer) |
| 175 | 171 | return l; |
| 176 | 172 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java b/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java
index 7f99e86..bdc48a4 100644
|
a
|
b
|
public class DownloadNotesTask extends AbstractDownloadTask<NoteData> {
|
| 112 | 112 | Main.debug("Notes downloaded: " + notesData.size()); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | | List<NoteLayer> noteLayers = null; |
| 116 | | if (Main.map != null) { |
| 117 | | noteLayers = Main.map.mapView.getLayersOfType(NoteLayer.class); |
| 118 | | } |
| 119 | | if (noteLayers != null && !noteLayers.isEmpty()) { |
| | 115 | List<NoteLayer> noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class); |
| | 116 | if (!noteLayers.isEmpty()) { |
| 120 | 117 | noteLayers.get(0).getNoteData().addNotes(notesData); |
| 121 | 118 | } else { |
| 122 | 119 | Main.main.addLayer(new NoteLayer(notesData, tr("Notes"))); |
-
diff --git a/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java b/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
index 6499870..2fbbd13 100644
|
a
|
b
|
import org.openstreetmap.josm.data.coor.LatLon;
|
| 19 | 19 | import org.openstreetmap.josm.data.osm.DataSet; |
| 20 | 20 | import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; |
| 21 | 21 | import org.openstreetmap.josm.gui.PleaseWaitRunnable; |
| 22 | | import org.openstreetmap.josm.gui.layer.Layer; |
| 23 | 22 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 24 | 23 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor; |
| 25 | 24 | import org.openstreetmap.josm.gui.progress.ProgressMonitor; |
| … |
… |
public class DownloadOsmTask extends AbstractDownloadTask<DataSet> {
|
| 216 | 215 | } |
| 217 | 216 | |
| 218 | 217 | protected int getNumDataLayers() { |
| 219 | | if (!Main.isDisplayingMapView()) return 0; |
| 220 | | return Utils.filteredCollection(Main.map.mapView.getAllLayers(), OsmDataLayer.class).size(); |
| | 218 | return Main.getLayerManager().getLayersOfType(OsmDataLayer.class).size(); |
| 221 | 219 | } |
| 222 | 220 | |
| 223 | 221 | protected OsmDataLayer getFirstDataLayer() { |
| 224 | | if (!Main.isDisplayingMapView()) return null; |
| 225 | | Collection<Layer> layers = Main.map.mapView.getAllLayersAsList(); |
| 226 | | for (Layer layer : layers) { |
| 227 | | if (layer instanceof OsmDataLayer) |
| 228 | | return (OsmDataLayer) layer; |
| 229 | | } |
| 230 | | return null; |
| | 222 | return Utils.find(Main.getLayerManager().getLayers(), OsmDataLayer.class); |
| 231 | 223 | } |
| 232 | 224 | |
| 233 | 225 | protected OsmDataLayer createNewLayer(String layerName) { |
-
diff --git a/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java b/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java
index 4bcb3c9..42a7fd1 100644
|
a
|
b
|
public class DownloadTaskList {
|
| 72 | 72 | if (newLayer) { |
| 73 | 73 | Layer l = new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null); |
| 74 | 74 | Main.main.addLayer(l); |
| 75 | | Main.map.mapView.setActiveLayer(l); |
| | 75 | Main.getLayerManager().setActiveLayer(l); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | int n = (osmData && gpxData ? 2 : 1)*rects.size(); |