-
diff --git a/src/org/openstreetmap/josm/actions/AutoScaleAction.java b/src/org/openstreetmap/josm/actions/AutoScaleAction.java
index 7438bdd..fd8fcf8 100644
a
|
b
|
public class AutoScaleAction extends JosmAction {
|
73 | 73 | * |
74 | 74 | */ |
75 | 75 | public static void zoomToSelection() { |
76 | | if (Main.main == null || !Main.main.hasEditLayer()) |
| 76 | DataSet dataSet = Main.getLayerManager().getEditDataSet(); |
| 77 | if (dataSet == null) { |
77 | 78 | return; |
78 | | Collection<OsmPrimitive> sel = Main.getLayerManager().getEditLayer().data.getSelected(); |
| 79 | } |
| 80 | Collection<OsmPrimitive> sel = dataSet.getSelected(); |
79 | 81 | if (sel.isEmpty()) { |
80 | 82 | JOptionPane.showMessageDialog( |
81 | 83 | Main.parent, |
… |
… |
public class AutoScaleAction extends JosmAction {
|
278 | 280 | private BoundingXYVisitor modeSelectionOrConflict(BoundingXYVisitor v) { |
279 | 281 | Collection<OsmPrimitive> sel = new HashSet<>(); |
280 | 282 | if ("selection".equals(mode)) { |
281 | | sel = getLayerManager().getEditDataSet().getSelected(); |
| 283 | DataSet dataSet = getLayerManager().getEditDataSet(); |
| 284 | if (dataSet != null) { |
| 285 | sel = dataSet.getSelected(); |
| 286 | } |
282 | 287 | } else { |
283 | 288 | Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict(); |
284 | 289 | if (c != null) { |
-
diff --git a/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java b/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
index db225a0..1ff34ab 100644
a
|
b
|
public class CreateMultipolygonAction extends JosmAction {
|
134 | 134 | |
135 | 135 | @Override |
136 | 136 | public void actionPerformed(ActionEvent e) { |
137 | | if (!Main.main.hasEditLayer()) { |
| 137 | DataSet dataSet = Main.getLayerManager().getEditDataSet(); |
| 138 | if (dataSet == null) { |
138 | 139 | new Notification( |
139 | 140 | tr("No data loaded.")) |
140 | 141 | .setIcon(JOptionPane.WARNING_MESSAGE) |
… |
… |
public class CreateMultipolygonAction extends JosmAction {
|
143 | 144 | return; |
144 | 145 | } |
145 | 146 | |
146 | | final Collection<Way> selectedWays = Main.getLayerManager().getEditDataSet().getSelectedWays(); |
| 147 | final Collection<Way> selectedWays = dataSet.getSelectedWays(); |
147 | 148 | |
148 | 149 | if (selectedWays.isEmpty()) { |
149 | 150 | // Sometimes it make sense creating multipoly of only one way (so it will form outer way) |
… |
… |
public class CreateMultipolygonAction extends JosmAction {
|
156 | 157 | return; |
157 | 158 | } |
158 | 159 | |
159 | | final Collection<Relation> selectedRelations = Main.getLayerManager().getEditDataSet().getSelectedRelations(); |
| 160 | final Collection<Relation> selectedRelations = dataSet.getSelectedRelations(); |
160 | 161 | final Relation multipolygonRelation = update |
161 | 162 | ? getSelectedMultipolygonRelation(selectedWays, selectedRelations) |
162 | 163 | : null; |
-
diff --git a/src/org/openstreetmap/josm/actions/ViewportFollowToggleAction.java b/src/org/openstreetmap/josm/actions/ViewportFollowToggleAction.java
index 1c96710..13c232a 100644
a
|
b
|
public class ViewportFollowToggleAction extends ToggleAction {
|
41 | 41 | |
42 | 42 | @Override |
43 | 43 | protected void updateEnabledState() { |
44 | | setEnabled(Main.main.hasEditLayer()); |
| 44 | setEnabled(Main.getLayerManager().getEditDataSet() != null); |
45 | 45 | } |
46 | 46 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/WireframeToggleAction.java b/src/org/openstreetmap/josm/actions/WireframeToggleAction.java
index 474cb7e..95c7cb8 100644
a
|
b
|
public class WireframeToggleAction extends ToggleAction {
|
36 | 36 | |
37 | 37 | @Override |
38 | 38 | protected void updateEnabledState() { |
39 | | setEnabled(Main.main.hasEditLayer()); |
| 39 | setEnabled(Main.getLayerManager().getEditLayer() != null); |
40 | 40 | } |
41 | 41 | |
42 | 42 | @Override |
-
diff --git a/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java b/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java
index 530213b..fb49dfe 100644
a
|
b
|
import java.util.Collection;
|
9 | 9 | import org.openstreetmap.josm.Main; |
10 | 10 | import org.openstreetmap.josm.actions.mapmode.DeleteAction; |
11 | 11 | import org.openstreetmap.josm.data.osm.Relation; |
| 12 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
12 | 13 | import org.openstreetmap.josm.tools.ImageProvider; |
13 | 14 | |
14 | 15 | /** |
… |
… |
public class DeleteRelationsAction extends AbstractRelationAction {
|
27 | 28 | } |
28 | 29 | |
29 | 30 | protected void deleteRelation(Collection<Relation> toDelete) { |
30 | | if (toDelete == null) |
| 31 | OsmDataLayer layer = Main.getLayerManager().getEditLayer(); |
| 32 | if (toDelete == null || layer == null) |
31 | 33 | return; |
32 | | DeleteAction.deleteRelations(Main.getLayerManager().getEditLayer(), toDelete); |
| 34 | |
| 35 | DeleteAction.deleteRelations(layer, toDelete); |
33 | 36 | // clear selection after deletion |
34 | 37 | if (Main.map.relationListDialog != null) |
35 | 38 | Main.map.relationListDialog.selectRelations(null); |
… |
… |
public class DeleteRelationsAction extends AbstractRelationAction {
|
37 | 40 | |
38 | 41 | @Override |
39 | 42 | public void actionPerformed(ActionEvent e) { |
40 | | if (!isEnabled() || !Main.main.hasEditLayer()) |
| 43 | if (!isEnabled()) |
41 | 44 | return; |
42 | 45 | deleteRelation(relations); |
43 | 46 | } |
-
diff --git a/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java b/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
index 5fbef85..411a734 100644
a
|
b
|
import org.openstreetmap.josm.Main;
|
20 | 20 | import org.openstreetmap.josm.data.coor.EastNorth; |
21 | 21 | import org.openstreetmap.josm.data.coor.LatLon; |
22 | 22 | import org.openstreetmap.josm.data.osm.BBox; |
| 23 | import org.openstreetmap.josm.data.osm.DataSet; |
23 | 24 | import org.openstreetmap.josm.data.osm.Node; |
24 | 25 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
25 | 26 | import org.openstreetmap.josm.data.osm.QuadBuckets; |
… |
… |
public abstract class UnconnectedWays extends Test {
|
163 | 164 | othernodes = new HashSet<>(); |
164 | 165 | mindist = Main.pref.getDouble(PREFIX + ".node_way_distance", 10.0); |
165 | 166 | minmiddledist = Main.pref.getDouble(PREFIX + ".way_way_distance", 0.0); |
166 | | dsArea = Main.main == null || !Main.main.hasEditLayer() ? null : Main.getLayerManager().getEditDataSet().getDataSourceArea(); |
| 167 | DataSet dataSet = Main.getLayerManager().getEditDataSet(); |
| 168 | dsArea = dataSet == null ? null : dataSet.getDataSourceArea(); |
167 | 169 | } |
168 | 170 | |
169 | 171 | protected Map<Node, Way> getWayEndNodesNearOtherHighway() { |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java b/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
index 03b2cef..e882c95 100644
a
|
b
|
public class ChangesetDialog extends ToggleDialog {
|
315 | 315 | |
316 | 316 | @Override |
317 | 317 | public void actionPerformed(ActionEvent e) { |
318 | | if (!Main.main.hasEditLayer()) |
| 318 | if (Main.getLayerManager().getEditLayer() == null) |
319 | 319 | return; |
320 | 320 | ChangesetListModel model = getCurrentChangesetListModel(); |
321 | 321 | Set<Integer> sel = model.getSelectedChangesetIds(); |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java b/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
index 2059f50..d084a4f 100644
a
|
b
|
import org.openstreetmap.josm.Main;
|
38 | 38 | import org.openstreetmap.josm.actions.AutoScaleAction; |
39 | 39 | import org.openstreetmap.josm.command.Command; |
40 | 40 | import org.openstreetmap.josm.command.PseudoCommand; |
| 41 | import org.openstreetmap.josm.data.osm.DataSet; |
41 | 42 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
42 | 43 | import org.openstreetmap.josm.gui.SideButton; |
43 | 44 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
… |
… |
public class CommandStackDialog extends ToggleDialog implements CommandQueueList
|
388 | 389 | } else |
389 | 390 | throw new IllegalStateException(); |
390 | 391 | |
391 | | OsmDataLayer editLayer = Main.getLayerManager().getEditLayer(); |
392 | | if (editLayer == null) return; |
393 | | editLayer.data.setSelected(getAffectedPrimitives(path)); |
| 392 | DataSet dataSet = Main.getLayerManager().getEditDataSet(); |
| 393 | if (dataSet == null) return; |
| 394 | dataSet.setSelected(getAffectedPrimitives(path)); |
394 | 395 | } |
395 | 396 | |
396 | 397 | @Override |
… |
… |
public class CommandStackDialog extends ToggleDialog implements CommandQueueList
|
416 | 417 | @Override |
417 | 418 | public void actionPerformed(ActionEvent e) { |
418 | 419 | super.actionPerformed(e); |
419 | | if (!Main.main.hasEditLayer()) return; |
420 | 420 | AutoScaleAction.autoScale("selection"); |
421 | 421 | } |
422 | 422 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
index fdaedd2..59e0cae 100644
a
|
b
|
public class RelationListDialog extends ToggleDialog
|
370 | 370 | } |
371 | 371 | |
372 | 372 | protected void updateEnabledState() { |
373 | | setEnabled(Main.main != null && Main.main.hasEditLayer()); |
| 373 | setEnabled(Main.getLayerManager().getEditLayer() != null); |
374 | 374 | } |
375 | 375 | |
376 | 376 | @Override |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
index a192b92..3f56870 100644
a
|
b
|
public class SelectionListDialog extends ToggleDialog {
|
309 | 309 | } |
310 | 310 | |
311 | 311 | protected void updateEnabledState() { |
312 | | setEnabled(Main.main != null && Main.main.hasEditLayer()); |
| 312 | setEnabled(Main.getLayerManager().getEditLayer() != null); |
313 | 313 | } |
314 | 314 | |
315 | 315 | @Override |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java b/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java
index fe959a9..ca0b830 100644
a
|
b
|
public class ChangesetContentPanel extends JPanel implements PropertyChangeListe
|
332 | 332 | abstract class SelectionBasedAction extends AbstractAction implements ListSelectionListener, ActiveLayerChangeListener { |
333 | 333 | |
334 | 334 | protected Set<OsmPrimitive> getTarget() { |
335 | | if (!isEnabled() || Main.main == null || !Main.main.hasEditLayer()) { |
| 335 | if (!isEnabled()) { |
336 | 336 | return null; |
337 | 337 | } |
338 | 338 | OsmDataLayer layer = Main.getLayerManager().getEditLayer(); |
| 339 | if (layer == null) { |
| 340 | return null; |
| 341 | } |
339 | 342 | Set<OsmPrimitive> target = new HashSet<>(); |
340 | 343 | for (HistoryOsmPrimitive p : model.getSelectedPrimitives()) { |
341 | 344 | OsmPrimitive op = layer.data.getPrimitiveById(p.getPrimitiveId()); |
… |
… |
public class ChangesetContentPanel extends JPanel implements PropertyChangeListe
|
347 | 350 | } |
348 | 351 | |
349 | 352 | public final void updateEnabledState() { |
350 | | if (Main.main == null || !Main.main.hasEditLayer()) { |
351 | | setEnabled(false); |
352 | | return; |
353 | | } |
354 | | setEnabled(model.hasSelectedPrimitives()); |
| 353 | setEnabled(Main.getLayerManager().getEditLayer() != null && model.hasSelectedPrimitives()); |
355 | 354 | } |
356 | 355 | |
357 | 356 | @Override |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java b/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java
index 51272fc..c875d2d 100644
a
|
b
|
public class ChangesetDetailPanel extends JPanel implements PropertyChangeListen
|
346 | 346 | public void actionPerformed(ActionEvent arg0) { |
347 | 347 | if (!isEnabled()) |
348 | 348 | return; |
349 | | if (Main.main == null || !Main.main.hasEditLayer()) return; |
350 | 349 | OsmDataLayer layer = Main.getLayerManager().getEditLayer(); |
| 350 | if (layer == null) { |
| 351 | return; |
| 352 | } |
351 | 353 | Set<OsmPrimitive> target = new HashSet<>(); |
352 | 354 | for (OsmPrimitive p: layer.data.allPrimitives()) { |
353 | 355 | if (p.isUsable() && p.getChangesetId() == currentChangeset.getId()) { |
… |
… |
public class ChangesetDetailPanel extends JPanel implements PropertyChangeListen
|
362 | 364 | } |
363 | 365 | |
364 | 366 | public void updateEnabledState() { |
365 | | if (Main.main == null || !Main.main.hasEditLayer()) { |
366 | | setEnabled(false); |
367 | | return; |
368 | | } |
369 | | setEnabled(currentChangeset != null); |
| 367 | setEnabled(Main.getLayerManager().getEditLayer() != null && currentChangeset != null); |
370 | 368 | } |
371 | 369 | |
372 | 370 | @Override |
… |
… |
public class ChangesetDetailPanel extends JPanel implements PropertyChangeListen
|
407 | 405 | public void actionPerformed(ActionEvent arg0) { |
408 | 406 | if (!isEnabled()) |
409 | 407 | return; |
410 | | if (Main.main == null || !Main.main.hasEditLayer()) return; |
411 | 408 | OsmDataLayer layer = Main.getLayerManager().getEditLayer(); |
| 409 | if (layer == null) { |
| 410 | return; |
| 411 | } |
412 | 412 | Set<OsmPrimitive> target = new HashSet<>(); |
413 | 413 | for (OsmPrimitive p: layer.data.allPrimitives()) { |
414 | 414 | if (p.isUsable() && p.getChangesetId() == currentChangeset.getId()) { |
… |
… |
public class ChangesetDetailPanel extends JPanel implements PropertyChangeListen
|
424 | 424 | } |
425 | 425 | |
426 | 426 | public void updateEnabledState() { |
427 | | if (Main.main == null || !Main.main.hasEditLayer()) { |
428 | | setEnabled(false); |
429 | | return; |
430 | | } |
431 | | setEnabled(currentChangeset != null); |
| 427 | setEnabled(Main.getLayerManager().getEditLayer() != null && currentChangeset != null); |
432 | 428 | } |
433 | 429 | |
434 | 430 | @Override |
-
diff --git a/src/org/openstreetmap/josm/gui/history/NodeListViewer.java b/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
index dc37a0a..d3c7f7b 100644
a
|
b
|
public class NodeListViewer extends JPanel {
|
265 | 265 | } |
266 | 266 | |
267 | 267 | public void updateEnabledState() { |
268 | | if (!Main.main.hasEditLayer()) { |
269 | | setEnabled(false); |
270 | | return; |
271 | | } |
272 | | setEnabled(getPrimitiveToZoom() != null); |
| 268 | setEnabled(Main.getLayerManager().getEditLayer() != null && getPrimitiveToZoom() != null); |
273 | 269 | } |
274 | 270 | } |
275 | 271 | |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java b/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java
index 642e05d..a72a581 100644
a
|
b
|
public class ValidatorLayer extends Layer implements LayerChangeListener {
|
162 | 162 | */ |
163 | 163 | @Override |
164 | 164 | public void layerRemoving(LayerRemoveEvent e) { |
165 | | if (e.getRemovedLayer() instanceof OsmDataLayer && Main.isDisplayingMapView() && !Main.main.hasEditLayer()) { |
| 165 | // Removed layer is still in that list. |
| 166 | if (e.getRemovedLayer() instanceof OsmDataLayer && e.getSource().getLayersOfType(OsmDataLayer.class).size() <= 1) { |
166 | 167 | Main.getLayerManager().removeLayer(this); |
167 | 168 | } else if (e.getRemovedLayer() == this) { |
168 | 169 | Main.getLayerManager().removeLayerChangeListener(this); |
-
diff --git a/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java b/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java
index 7a470a5..9f64c14 100644
a
|
b
|
public class MapPaintMenu extends JMenu implements MapPaintSylesUpdateListener {
|
65 | 65 | |
66 | 66 | @Override |
67 | 67 | public void updateEnabledState() { |
68 | | setEnabled(Main.isDisplayingMapView() && (Main.main.hasEditLayer() || mapHasGpxorMarkerLayer())); |
| 68 | setEnabled(Main.isDisplayingMapView() && (Main.getLayerManager().getEditLayer() != null || mapHasGpxorMarkerLayer())); |
69 | 69 | } |
70 | 70 | |
71 | 71 | private static boolean mapHasGpxorMarkerLayer() { |
-
diff --git a/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java b/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
index 74c52c3..8d8dd68 100644
a
|
b
|
public class AddNodeHandler extends RequestHandler {
|
119 | 119 | } catch (NumberFormatException e) { |
120 | 120 | throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+')', e); |
121 | 121 | } |
122 | | if (!Main.main.hasEditLayer()) { |
| 122 | if (Main.getLayerManager().getEditLayer() == null) { |
123 | 123 | throw new RequestHandlerBadRequestException(tr("There is no layer opened to add node")); |
124 | 124 | } |
125 | 125 | } |
-
diff --git a/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java b/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
index 58c2f4b..75488ac 100644
a
|
b
|
public class AddWayHandler extends RequestHandler {
|
113 | 113 | } else if (allCoordinates.size() == 1) { |
114 | 114 | throw new RequestHandlerBadRequestException(tr("One node ways")); |
115 | 115 | } |
116 | | if (!Main.main.hasEditLayer()) { |
| 116 | if (Main.getLayerManager().getEditLayer() == null) { |
117 | 117 | throw new RequestHandlerBadRequestException(tr("There is no layer opened to add way")); |
118 | 118 | } |
119 | 119 | } |