Changeset 10382 in josm for trunk/src/org
- Timestamp:
- 2016-06-15T12:45:52+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r10378 r10382 15 15 import org.openstreetmap.josm.Main; 16 16 import org.openstreetmap.josm.data.notes.Note; 17 import org.openstreetmap.josm.data.osm.DataSet; 17 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 19 import org.openstreetmap.josm.gui.HelpAwareOptionPane; … … 99 100 protected void launchInfoBrowsersForSelectedPrimitivesAndNote() { 100 101 List<OsmPrimitive> primitivesToShow = new ArrayList<>(); 101 if (getCurrentDataSet() != null) { 102 primitivesToShow.addAll(getCurrentDataSet().getAllSelected()); 102 DataSet ds = getLayerManager().getEditDataSet(); 103 if (ds != null) { 104 primitivesToShow.addAll(ds.getAllSelected()); 103 105 } 104 106 … … 157 159 @Override 158 160 protected void updateEnabledState() { 159 setEnabled(getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty()); 161 DataSet ds = getLayerManager().getEditDataSet(); 162 setEnabled(ds != null && !ds.getSelected().isEmpty()); 160 163 } 161 164 -
trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java
r8790 r10382 65 65 // add the node 66 66 Main.main.undoRedo.add(new AddCommand(nnew)); 67 get CurrentDataSet().setSelected(nnew);67 getLayerManager().getEditDataSet().setSelected(nnew); 68 68 if (Main.map.mapView.getRealBounds().contains(nnew.getCoor())) { 69 69 Main.map.mapView.repaint(); … … 75 75 @Override 76 76 protected void updateEnabledState() { 77 setEnabled(get EditLayer() != null);77 setEnabled(getLayerManager().getEditLayer() != null); 78 78 } 79 79 } -
trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r10378 r10382 22 22 import org.openstreetmap.josm.command.SequenceCommand; 23 23 import org.openstreetmap.josm.data.coor.EastNorth; 24 import org.openstreetmap.josm.data.osm.DataSet; 24 25 import org.openstreetmap.josm.data.osm.Node; 25 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 131 132 return; 132 133 133 Collection<OsmPrimitive> sel = get CurrentDataSet().getSelected();134 Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected(); 134 135 List<Node> nodes = new LinkedList<>(); 135 136 // fixNodes: All nodes for which the angle relative to center should not be modified … … 374 375 @Override 375 376 protected void updateEnabledState() { 376 setEnabled(getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty()); 377 DataSet ds = getLayerManager().getEditDataSet(); 378 setEnabled(ds != null && !ds.getSelected().isEmpty()); 377 379 } 378 380 -
trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java
r10378 r10382 22 22 import org.openstreetmap.josm.command.SequenceCommand; 23 23 import org.openstreetmap.josm.data.coor.EastNorth; 24 import org.openstreetmap.josm.data.osm.DataSet; 24 25 import org.openstreetmap.josm.data.osm.Node; 25 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 169 170 return; 170 171 171 List<Node> selectedNodes = new ArrayList<>(getCurrentDataSet().getSelectedNodes()); 172 List<Way> selectedWays = new ArrayList<>(getCurrentDataSet().getSelectedWays()); 172 DataSet ds = getLayerManager().getEditDataSet(); 173 List<Node> selectedNodes = new ArrayList<>(ds.getSelectedNodes()); 174 List<Way> selectedWays = new ArrayList<>(ds.getSelectedWays()); 173 175 174 176 try { … … 415 417 @Override 416 418 protected void updateEnabledState() { 417 setEnabled(getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty()); 419 DataSet ds = getLayerManager().getEditDataSet(); 420 setEnabled(ds != null && !ds.getSelected().isEmpty()); 418 421 } 419 422 -
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r10318 r10382 279 279 Collection<OsmPrimitive> sel = new HashSet<>(); 280 280 if ("selection".equals(mode)) { 281 sel = get CurrentDataSet().getSelected();281 sel = getLayerManager().getEditDataSet().getSelected(); 282 282 } else { 283 283 Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict(); … … 312 312 lastZoomTime = -1; 313 313 } 314 final DataSet dataset = get CurrentDataSet();314 final DataSet dataset = getLayerManager().getEditDataSet(); 315 315 if (dataset != null) { 316 316 List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources()); … … 341 341 @Override 342 342 protected void updateEnabledState() { 343 DataSet ds = getLayerManager().getEditDataSet(); 343 344 switch (mode) { 344 345 case "selection": 345 setEnabled( getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty());346 setEnabled(ds != null && !ds.getSelected().isEmpty()); 346 347 break; 347 348 case "layer": … … 352 353 break; 353 354 case "download": 354 setEnabled( getCurrentDataSet() != null && !getCurrentDataSet().getDataSources().isEmpty());355 setEnabled(ds != null && !ds.getDataSources().isEmpty()); 355 356 break; 356 357 case "problem": … … 364 365 break; 365 366 default: 366 setEnabled(! Main.getLayerManager().getLayers().isEmpty());367 setEnabled(!getLayerManager().getLayers().isEmpty()); 367 368 } 368 369 } -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r10378 r10382 28 28 import org.openstreetmap.josm.command.SequenceCommand; 29 29 import org.openstreetmap.josm.corrector.ReverseWayTagCorrector; 30 import org.openstreetmap.josm.data.osm.DataSet; 30 31 import org.openstreetmap.josm.data.osm.Node; 31 32 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 205 206 @Override 206 207 public void actionPerformed(ActionEvent event) { 207 if (getCurrentDataSet() == null) 208 final DataSet ds = getLayerManager().getEditDataSet(); 209 if (ds == null) 208 210 return; 209 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();211 Collection<OsmPrimitive> selection = ds.getSelected(); 210 212 Set<Way> selectedWays = OsmPrimitive.getFilteredSet(selection, Way.class); 211 213 if (selectedWays.size() < 2) { … … 233 235 @Override 234 236 public void run() { 235 getCurrentDataSet().setSelected(selectedWay);237 ds.setSelected(selectedWay); 236 238 } 237 239 }; … … 242 244 @Override 243 245 protected void updateEnabledState() { 244 if (getCurrentDataSet() == null) { 246 DataSet ds = getLayerManager().getEditDataSet(); 247 if (ds == null) { 245 248 setEnabled(false); 246 249 return; 247 250 } 248 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 249 updateEnabledState(selection); 251 updateEnabledState(ds.getSelected()); 250 252 } 251 253 -
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r8870 r10382 13 13 14 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.data.osm.DataSet; 15 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 17 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 44 45 public void actionPerformed(ActionEvent e) { 45 46 if (isEmptySelection()) return; 46 Collection<OsmPrimitive> selection = get CurrentDataSet().getSelected();47 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected(); 47 48 48 copy(get EditLayer(), selection);49 copy(getLayerManager().getEditLayer(), selection); 49 50 } 50 51 … … 74 75 @Override 75 76 protected void updateEnabledState() { 76 if (getCurrentDataSet() == null) { 77 DataSet ds = getLayerManager().getEditDataSet(); 78 if (ds == null) { 77 79 setEnabled(false); 78 80 } else { 79 updateEnabledState( getCurrentDataSet().getSelected());81 updateEnabledState(ds.getSelected()); 80 82 } 81 83 } -
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r10378 r10382 25 25 import org.openstreetmap.josm.data.coor.EastNorth; 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 import org.openstreetmap.josm.data.osm.DataSet; 27 28 import org.openstreetmap.josm.data.osm.Node; 28 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 136 137 } 137 138 138 Collection<OsmPrimitive> sel = get CurrentDataSet().getSelected();139 Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected(); 139 140 List<Node> nodes = OsmPrimitive.getFilteredList(sel, Node.class); 140 141 List<Way> ways = OsmPrimitive.getFilteredList(sel, Way.class); … … 289 290 @Override 290 291 protected void updateEnabledState() { 291 if (getCurrentDataSet() == null) { 292 DataSet ds = getLayerManager().getEditDataSet(); 293 if (ds == null) { 292 294 setEnabled(false); 293 295 } else { 294 updateEnabledState( getCurrentDataSet().getSelected());296 updateEnabledState(ds.getSelected()); 295 297 } 296 298 } -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r10378 r10382 28 28 import org.openstreetmap.josm.command.Command; 29 29 import org.openstreetmap.josm.command.SequenceCommand; 30 import org.openstreetmap.josm.data.osm.DataSet; 30 31 import org.openstreetmap.josm.data.osm.MultipolygonBuilder; 31 32 import org.openstreetmap.josm.data.osm.MultipolygonBuilder.JoinedPolygon; … … 260 261 @Override 261 262 protected void updateEnabledState() { 262 if (getCurrentDataSet() == null) { 263 DataSet ds = getLayerManager().getEditDataSet(); 264 if (ds == null) { 263 265 setEnabled(false); 264 266 } else { 265 updateEnabledState( getCurrentDataSet().getSelected());267 updateEnabledState(ds.getSelected()); 266 268 } 267 269 } … … 274 276 @Override 275 277 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 276 if (getCurrentDataSet() == null) { 278 DataSet ds = getLayerManager().getEditDataSet(); 279 if (ds == null) { 277 280 setEnabled(false); 278 281 } else if (update) { 279 282 setEnabled(getSelectedMultipolygonRelation() != null); 280 283 } else { 281 setEnabled(!get CurrentDataSet().getSelectedWays().isEmpty());284 setEnabled(!getLayerManager().getEditDataSet().getSelectedWays().isEmpty()); 282 285 } 283 286 } -
trunk/src/org/openstreetmap/josm/actions/DeleteAction.java
r7434 r10382 10 10 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.data.osm.DataSet; 12 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 14 import org.openstreetmap.josm.tools.Shortcut; … … 37 38 @Override 38 39 protected void updateEnabledState() { 39 if (getCurrentDataSet() == null) { 40 DataSet ds = getLayerManager().getEditDataSet(); 41 if (ds == null) { 40 42 setEnabled(false); 41 43 } else { 42 updateEnabledState( getCurrentDataSet().getSelected());44 updateEnabledState(ds.getSelected()); 43 45 } 44 46 } -
trunk/src/org/openstreetmap/josm/actions/DistributeAction.java
r9258 r10382 20 20 import org.openstreetmap.josm.command.MoveCommand; 21 21 import org.openstreetmap.josm.command.SequenceCommand; 22 import org.openstreetmap.josm.data.osm.DataSet; 22 23 import org.openstreetmap.josm.data.osm.Node; 23 24 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 58 59 59 60 // Collect user selected objects 60 Collection<OsmPrimitive> selected = get CurrentDataSet().getSelected();61 Collection<OsmPrimitive> selected = getLayerManager().getEditDataSet().getSelected(); 61 62 Collection<Way> ways = new LinkedList<>(); 62 63 Collection<Node> nodes = new HashSet<>(); … … 300 301 @Override 301 302 protected void updateEnabledState() { 302 if (getCurrentDataSet() == null) { 303 DataSet ds = getLayerManager().getEditDataSet(); 304 if (ds == null) { 303 305 setEnabled(false); 304 306 } else { 305 updateEnabledState( getCurrentDataSet().getSelected());307 updateEnabledState(ds.getSelected()); 306 308 } 307 309 } -
trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
r9881 r10382 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask; 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 61 62 @Override 62 63 protected void updateEnabledState() { 63 if (getCurrentDataSet() == null) { 64 DataSet ds = getLayerManager().getEditDataSet(); 65 if (ds == null) { 64 66 setEnabled(false); 65 67 } else { 66 updateEnabledState( getCurrentDataSet().getSelected());68 updateEnabledState(ds.getSelected()); 67 69 } 68 70 } -
trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java
r9059 r10382 11 11 12 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 15 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy; … … 29 30 @Override 30 31 public void actionPerformed(ActionEvent e) { 31 Main.main.menu.paste.pasteData(new PrimitiveDeepCopy(getCurrentDataSet().getSelected()), getEditLayer(), e); 32 Main.main.menu.paste.pasteData( 33 new PrimitiveDeepCopy(getLayerManager().getEditDataSet().getSelected()), getLayerManager().getEditLayer(), e); 32 34 } 33 35 34 36 @Override 35 37 protected void updateEnabledState() { 36 if (getCurrentDataSet() == null) { 38 DataSet ds = getLayerManager().getEditDataSet(); 39 if (ds == null) { 37 40 setEnabled(false); 38 41 } else { 39 updateEnabledState( getCurrentDataSet().getSelected());42 updateEnabledState(ds.getSelected()); 40 43 } 41 44 } -
trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java
r8036 r10382 16 16 import org.openstreetmap.josm.command.SelectCommand; 17 17 import org.openstreetmap.josm.command.SequenceCommand; 18 import org.openstreetmap.josm.data.osm.DataSet; 18 19 import org.openstreetmap.josm.data.osm.Node; 19 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 47 48 @Override 48 49 protected void updateEnabledState() { 49 if (getCurrentDataSet() == null) { 50 DataSet ds = getLayerManager().getEditDataSet(); 51 if (ds == null) { 50 52 setEnabled(false); 51 53 } else { 52 updateEnabledState( getCurrentDataSet().getSelected());54 updateEnabledState(ds.getSelected()); 53 55 } 54 56 } -
trunk/src/org/openstreetmap/josm/actions/HistoryInfoAction.java
r8061 r10382 37 37 @Override 38 38 public void actionPerformed(ActionEvent ae) { 39 DataSet set = get CurrentDataSet();39 DataSet set = getLayerManager().getEditDataSet(); 40 40 if (set != null && !set.getAllSelected().isEmpty()) { 41 41 HistoryBrowserDialogManager.getInstance().showHistory(set.getAllSelected()); -
trunk/src/org/openstreetmap/josm/actions/InfoAction.java
r7859 r10382 35 35 @Override 36 36 public void actionPerformed(ActionEvent ae) { 37 DataSet set = get CurrentDataSet();37 DataSet set = getLayerManager().getEditDataSet(); 38 38 if (set != null) { 39 39 new InspectPrimitiveDialog(set.getAllSelected(), Main.main.getEditLayer()).showDialog(); … … 43 43 @Override 44 44 public void updateEnabledState() { 45 if (getCurrentDataSet() == null) { 45 DataSet ds = getLayerManager().getEditDataSet(); 46 if (ds == null) { 46 47 setEnabled(false); 47 48 } else { 48 updateEnabledState( getCurrentDataSet().getAllSelected());49 updateEnabledState(ds.getAllSelected()); 49 50 } 50 51 } -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r10378 r10382 955 955 956 956 if (chunks.size() > 1) { 957 SplitWayResult split = SplitWayAction.splitWay(get EditLayer(), way, chunks,957 SplitWayResult split = SplitWayAction.splitWay(getLayerManager().getEditLayer(), way, chunks, 958 958 Collections.<OsmPrimitive>emptyList(), SplitWayAction.Strategy.keepFirstChunk()); 959 959 … … 1548 1548 @Override 1549 1549 protected void updateEnabledState() { 1550 if (getCurrentDataSet() == null) { 1550 DataSet ds = getLayerManager().getEditDataSet(); 1551 if (ds == null) { 1551 1552 setEnabled(false); 1552 1553 } else { 1553 updateEnabledState( getCurrentDataSet().getSelected());1554 updateEnabledState(ds.getSelected()); 1554 1555 } 1555 1556 } -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r9880 r10382 25 25 import org.openstreetmap.josm.command.SequenceCommand; 26 26 import org.openstreetmap.josm.data.coor.EastNorth; 27 import org.openstreetmap.josm.data.osm.DataSet; 27 28 import org.openstreetmap.josm.data.osm.Node; 28 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 83 84 if (!isEnabled()) 84 85 return; 85 Collection<Node> selectedNodes = get CurrentDataSet().getSelectedNodes();86 Collection<Node> selectedNodes = getLayerManager().getEditDataSet().getSelectedNodes(); 86 87 Collection<Command> cmds = new LinkedList<>(); 87 88 Map<Way, MultiMap<Integer, Node>> data = new HashMap<>(); … … 89 90 // If the user has selected some ways, only join the node to these. 90 91 boolean restrictToSelectedWays = 91 !get CurrentDataSet().getSelectedWays().isEmpty();92 !getLayerManager().getEditDataSet().getSelectedWays().isEmpty(); 92 93 93 94 // Planning phase: decide where we'll insert the nodes and put it all in "data" … … 208 209 @Override 209 210 protected void updateEnabledState() { 210 if (getCurrentDataSet() == null) { 211 DataSet ds = getLayerManager().getEditDataSet(); 212 if (ds == null) { 211 213 setEnabled(false); 212 214 } else { 213 updateEnabledState( getCurrentDataSet().getSelected());215 updateEnabledState(ds.getSelected()); 214 216 } 215 217 } -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r9970 r10382 26 26 import org.openstreetmap.josm.data.coor.EastNorth; 27 27 import org.openstreetmap.josm.data.coor.LatLon; 28 import org.openstreetmap.josm.data.osm.DataSet; 28 29 import org.openstreetmap.josm.data.osm.Node; 29 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 68 69 if (!isEnabled()) 69 70 return; 70 Collection<OsmPrimitive> selection = get CurrentDataSet().getAllSelected();71 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getAllSelected(); 71 72 List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class); 72 73 … … 351 352 @Override 352 353 protected void updateEnabledState() { 353 if (getCurrentDataSet() == null) { 354 DataSet ds = getLayerManager().getEditDataSet(); 355 if (ds == null) { 354 356 setEnabled(false); 355 357 } else { 356 updateEnabledState( getCurrentDataSet().getAllSelected());358 updateEnabledState(ds.getAllSelected()); 357 359 } 358 360 } -
trunk/src/org/openstreetmap/josm/actions/MergeSelectionAction.java
r8510 r10382 10 10 import java.util.List; 11 11 12 import org.openstreetmap.josm.data.osm.DataSet; 12 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 14 import org.openstreetmap.josm.data.osm.visitor.MergeSourceBuildingVisitor; … … 41 42 */ 42 43 public void mergeSelected() { 43 List<Layer> targetLayers = LayerListDialog.getInstance().getModel().getPossibleMergeTargets(getEditLayer()); 44 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 45 List<Layer> targetLayers = LayerListDialog.getInstance().getModel().getPossibleMergeTargets(editLayer); 44 46 if (targetLayers.isEmpty()) { 45 warnNoTargetLayersForSourceLayer( getEditLayer());47 warnNoTargetLayersForSourceLayer(editLayer); 46 48 return; 47 49 } … … 49 51 if (targetLayer == null) 50 52 return; 51 if ( getEditLayer().isUploadDiscouraged() && targetLayer instanceof OsmDataLayer53 if (editLayer.isUploadDiscouraged() && targetLayer instanceof OsmDataLayer 52 54 && !((OsmDataLayer) targetLayer).isUploadDiscouraged() 53 && getEditLayer().data.getAllSelected().size() > 155 && editLayer.data.getAllSelected().size() > 1 54 56 && warnMergingUploadDiscouragedObjects(targetLayer)) { 55 57 return; 56 58 } 57 MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor( getEditLayer().data);59 MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(editLayer.data); 58 60 ((OsmDataLayer) targetLayer).mergeFrom(builder.build()); 59 61 } … … 61 63 @Override 62 64 public void actionPerformed(ActionEvent e) { 63 if (getEditLayer() == null || getEditLayer().data.getAllSelected().isEmpty()) 65 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 66 if (editLayer == null || editLayer.data.getAllSelected().isEmpty()) 64 67 return; 65 68 mergeSelected(); … … 68 71 @Override 69 72 protected void updateEnabledState() { 70 if (getCurrentDataSet() == null) { 73 DataSet ds = getLayerManager().getEditDataSet(); 74 if (ds == null) { 71 75 setEnabled(false); 72 76 } else { 73 updateEnabledState( getCurrentDataSet().getAllSelected());77 updateEnabledState(ds.getAllSelected()); 74 78 } 75 79 } -
trunk/src/org/openstreetmap/josm/actions/MirrorAction.java
r8510 r10382 18 18 import org.openstreetmap.josm.command.MoveCommand; 19 19 import org.openstreetmap.josm.command.SequenceCommand; 20 import org.openstreetmap.josm.data.osm.DataSet; 20 21 import org.openstreetmap.josm.data.osm.Node; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 45 46 @Override 46 47 public void actionPerformed(ActionEvent e) { 47 Collection<OsmPrimitive> sel = get CurrentDataSet().getSelected();48 Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected(); 48 49 Set<Node> nodes = new HashSet<>(); 49 50 … … 86 87 @Override 87 88 protected void updateEnabledState() { 88 if (getCurrentDataSet() == null) { 89 DataSet ds = getLayerManager().getEditDataSet(); 90 if (ds == null) { 89 91 setEnabled(false); 90 92 } else { 91 updateEnabledState( getCurrentDataSet().getSelected());93 updateEnabledState(ds.getSelected()); 92 94 } 93 95 } -
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r10378 r10382 15 15 import org.openstreetmap.josm.command.MoveCommand; 16 16 import org.openstreetmap.josm.data.coor.EastNorth; 17 import org.openstreetmap.josm.data.osm.DataSet; 17 18 import org.openstreetmap.josm.data.osm.Node; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 116 117 } 117 118 118 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 119 DataSet ds = getLayerManager().getEditDataSet(); 120 Collection<OsmPrimitive> selection = ds.getSelected(); 119 121 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 120 122 … … 122 124 ? Main.main.undoRedo.commands.getLast() : null; 123 125 124 getCurrentDataSet().beginUpdate();126 ds.beginUpdate(); 125 127 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { 126 128 ((MoveCommand) c).moveAgain(distx, disty); … … 129 131 Main.main.undoRedo.add(c); 130 132 } 131 getCurrentDataSet().endUpdate();133 ds.endUpdate(); 132 134 133 135 for (Node n : affectedNodes) { … … 150 152 @Override 151 153 protected void updateEnabledState() { 152 if (getCurrentDataSet() == null) { 154 DataSet ds = getLayerManager().getEditDataSet(); 155 if (ds == null) { 153 156 setEnabled(false); 154 157 } else { 155 updateEnabledState( getCurrentDataSet().getSelected());158 updateEnabledState(ds.getSelected()); 156 159 } 157 160 } -
trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java
r8443 r10382 11 11 import org.openstreetmap.josm.command.MoveCommand; 12 12 import org.openstreetmap.josm.data.coor.LatLon; 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.data.osm.Node; 14 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 33 34 @Override 34 35 public void actionPerformed(ActionEvent e) { 35 if (!isEnabled() || (getCurrentDataSet().getSelectedNodes().size() != 1)) 36 Collection<Node> selNodes = getLayerManager().getEditDataSet().getSelectedNodes(); 37 if (!isEnabled() || selNodes.size() != 1) 36 38 return; 37 39 38 40 LatLonDialog dialog = new LatLonDialog(Main.parent, tr("Move Node..."), ht("/Action/MoveNode")); 39 Node n = (Node) getCurrentDataSet().getSelectedNodes().toArray()[0];41 Node n = (Node) selNodes.toArray()[0]; 40 42 dialog.setCoordinates(n.getCoor()); 41 43 dialog.showDialog(); … … 54 56 @Override 55 57 protected void updateEnabledState() { 56 if (getCurrentDataSet() == null) { 58 DataSet ds = getLayerManager().getEditDataSet(); 59 if (ds == null) { 57 60 setEnabled(false); 58 61 } else { 59 updateEnabledState( getCurrentDataSet().getSelected());62 updateEnabledState(ds.getSelected()); 60 63 } 61 64 } -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r10378 r10382 26 26 import org.openstreetmap.josm.command.SequenceCommand; 27 27 import org.openstreetmap.josm.data.coor.EastNorth; 28 import org.openstreetmap.josm.data.osm.DataSet; 28 29 import org.openstreetmap.josm.data.osm.Node; 29 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 99 100 return; 100 101 final Collection<Command> commands = new LinkedList<>(); 101 final Collection<OsmPrimitive> sel = get CurrentDataSet().getSelected();102 final Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected(); 102 103 try { 103 104 for (OsmPrimitive p : sel) { … … 146 147 } 147 148 148 final Collection<OsmPrimitive> sel = get CurrentDataSet().getSelected();149 final Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected(); 149 150 150 151 try { … … 617 618 @Override 618 619 protected void updateEnabledState() { 619 setEnabled(getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty()); 620 DataSet ds = getLayerManager().getEditDataSet(); 621 setEnabled(ds != null && !ds.getSelected().isEmpty()); 620 622 } 621 623 -
trunk/src/org/openstreetmap/josm/actions/PasteAction.java
r10378 r10382 201 201 @Override 202 202 protected void updateEnabledState() { 203 if (get CurrentDataSet() == null || Main.pasteBuffer == null) {203 if (getLayerManager().getEditDataSet() == null || Main.pasteBuffer == null) { 204 204 setEnabled(false); 205 205 return; -
trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java
r9968 r10382 19 19 import org.openstreetmap.josm.command.Command; 20 20 import org.openstreetmap.josm.command.SequenceCommand; 21 import org.openstreetmap.josm.data.osm.DataSet; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 23 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 253 254 @Override 254 255 public void actionPerformed(ActionEvent e) { 255 Collection<OsmPrimitive> selection = get CurrentDataSet().getSelected();256 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected(); 256 257 257 258 if (selection.isEmpty()) … … 330 331 @Override 331 332 protected void updateEnabledState() { 332 if (getCurrentDataSet() == null) { 333 DataSet ds = getLayerManager().getEditDataSet(); 334 if (ds == null) { 333 335 setEnabled(false); 334 336 return; 335 337 } 336 338 // buffer listening slows down the program and is not very good for arbitrary text in buffer 337 setEnabled(! getCurrentDataSet().getSelected().isEmpty());339 setEnabled(!ds.getSelected().isEmpty()); 338 340 } 339 341 -
trunk/src/org/openstreetmap/josm/actions/PurgeAction.java
r10378 r10382 33 33 import org.openstreetmap.josm.Main; 34 34 import org.openstreetmap.josm.command.PurgeCommand; 35 import org.openstreetmap.josm.data.osm.DataSet; 35 36 import org.openstreetmap.josm.data.osm.Node; 36 37 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 94 95 return; 95 96 96 Collection<OsmPrimitive> sel = get CurrentDataSet().getAllSelected();97 Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getAllSelected(); 97 98 layer = Main.main.getEditLayer(); 98 99 … … 221 222 if (clearUndoRedo) { 222 223 Main.main.undoRedo.clean(); 223 get CurrentDataSet().clearSelectionHistory();224 getLayerManager().getEditDataSet().clearSelectionHistory(); 224 225 } 225 226 } … … 303 304 @Override 304 305 protected void updateEnabledState() { 305 if (getCurrentDataSet() == null) { 306 DataSet ds = getLayerManager().getEditDataSet(); 307 if (ds == null) { 306 308 setEnabled(false); 307 309 } else { 308 setEnabled(! (getCurrentDataSet().selectionEmpty()));310 setEnabled(!ds.selectionEmpty()); 309 311 } 310 312 } -
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r9067 r10382 21 21 import org.openstreetmap.josm.corrector.ReverseWayNoTagCorrector; 22 22 import org.openstreetmap.josm.corrector.ReverseWayTagCorrector; 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; … … 74 75 @Override 75 76 public void actionPerformed(ActionEvent e) { 76 if (!isEnabled()) 77 return; 78 if (getCurrentDataSet() == null) 77 DataSet ds = getLayerManager().getEditDataSet(); 78 if (!isEnabled() || ds == null) 79 79 return; 80 80 81 final Collection<Way> sel = getCurrentDataSet().getSelectedWays();81 final Collection<Way> sel = ds.getSelectedWays(); 82 82 if (sel.isEmpty()) { 83 83 new Notification( … … 103 103 Main.main.undoRedo.add(new SequenceCommand(tr("Reverse ways"), c)); 104 104 if (propertiesUpdated) { 105 getCurrentDataSet().fireSelectionChanged();105 ds.fireSelectionChanged(); 106 106 } 107 107 Main.map.repaint(); … … 129 129 @Override 130 130 protected void updateEnabledState() { 131 if (getCurrentDataSet() == null) { 131 DataSet ds = getLayerManager().getEditDataSet(); 132 if (ds == null) { 132 133 setEnabled(false); 133 134 } else { 134 updateEnabledState( getCurrentDataSet().getSelected());135 updateEnabledState(ds.getSelected()); 135 136 } 136 137 } -
trunk/src/org/openstreetmap/josm/actions/SelectAllAction.java
r8510 r10382 8 8 import java.awt.event.KeyEvent; 9 9 10 import org.openstreetmap.josm.data.osm.DataSet; 10 11 import org.openstreetmap.josm.tools.Shortcut; 11 12 … … 25 26 if (!isEnabled()) 26 27 return; 27 getCurrentDataSet().setSelected(getCurrentDataSet().allNonDeletedCompletePrimitives()); 28 DataSet ds = getLayerManager().getEditDataSet(); 29 ds.setSelected(ds.allNonDeletedCompletePrimitives()); 28 30 } 29 31 … … 34 36 @Override 35 37 protected void updateEnabledState() { 36 setEnabled(get EditLayer() != null);38 setEnabled(getLayerManager().getEditLayer() != null); 37 39 } 38 40 } -
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r10378 r10382 94 94 @Override 95 95 public void actionPerformed(ActionEvent e) { 96 DataSet ds = get CurrentDataSet();96 DataSet ds = getLayerManager().getEditDataSet(); 97 97 ds.beginUpdate(); 98 98 try { … … 276 276 @Override 277 277 protected void updateEnabledState() { 278 if (getCurrentDataSet() == null) { 278 DataSet ds = getLayerManager().getEditDataSet(); 279 if (ds == null) { 279 280 setEnabled(false); 280 281 } else { 281 updateEnabledState( getCurrentDataSet().getSelected());282 updateEnabledState(ds.getSelected()); 282 283 } 283 284 } -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r10254 r10382 35 35 import org.openstreetmap.josm.command.Command; 36 36 import org.openstreetmap.josm.command.SequenceCommand; 37 import org.openstreetmap.josm.data.osm.DataSet; 37 38 import org.openstreetmap.josm.data.osm.Node; 38 39 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 139 140 } 140 141 141 Collection<OsmPrimitive> selection = get CurrentDataSet().getSelected();142 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected(); 142 143 143 144 List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class); … … 214 215 } 215 216 if (wayToKeep != null) { 216 final SplitWayResult result = doSplitWay(get EditLayer(), selectedWay, wayToKeep, newWays, sel);217 final SplitWayResult result = doSplitWay(getLayerManager().getEditLayer(), selectedWay, wayToKeep, newWays, sel); 217 218 Main.main.undoRedo.add(result.getCommand()); 218 get CurrentDataSet().setSelected(result.getNewSelection());219 getLayerManager().getEditDataSet().setSelected(result.getNewSelection()); 219 220 } 220 221 } … … 751 752 @Override 752 753 protected void updateEnabledState() { 753 if (getCurrentDataSet() == null) { 754 DataSet ds = getLayerManager().getEditDataSet(); 755 if (ds == null) { 754 756 setEnabled(false); 755 757 } else { 756 updateEnabledState( getCurrentDataSet().getSelected());758 updateEnabledState(ds.getSelected()); 757 759 } 758 760 } -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r10378 r10382 32 32 import org.openstreetmap.josm.command.Command; 33 33 import org.openstreetmap.josm.command.SequenceCommand; 34 import org.openstreetmap.josm.data.osm.DataSet; 34 35 import org.openstreetmap.josm.data.osm.Node; 35 36 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 90 91 protected void unglue(ActionEvent e) throws UserCancelException { 91 92 92 Collection<OsmPrimitive> selection = get CurrentDataSet().getSelected();93 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected(); 93 94 94 95 String errMsg = null; … … 323 324 324 325 Main.main.undoRedo.add(new SequenceCommand(tr("Unglued Node"), cmds)); 325 get CurrentDataSet().setSelected(n);326 getLayerManager().getEditDataSet().setSelected(n); 326 327 Main.map.mapView.repaint(); 327 328 } … … 652 653 trn("Dupe {0} node into {1} nodes", "Dupe {0} nodes into {1} nodes", 653 654 selectedNodes.size(), selectedNodes.size(), selectedNodes.size()+allNewNodes.size()), cmds)); 654 get CurrentDataSet().setSelected(allNewNodes);655 getLayerManager().getEditDataSet().setSelected(allNewNodes); 655 656 } 656 657 657 658 @Override 658 659 protected void updateEnabledState() { 659 if (getCurrentDataSet() == null) { 660 DataSet ds = getLayerManager().getEditDataSet(); 661 if (ds == null) { 660 662 setEnabled(false); 661 663 } else { 662 updateEnabledState( getCurrentDataSet().getSelected());664 updateEnabledState(ds.getSelected()); 663 665 } 664 666 } -
trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java
r10074 r10382 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.command.RemoveNodesCommand; 20 import org.openstreetmap.josm.data.osm.DataSet; 20 21 import org.openstreetmap.josm.data.osm.Node; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 47 48 public void actionPerformed(ActionEvent e) { 48 49 49 Collection<OsmPrimitive> selection = get CurrentDataSet().getSelected();50 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected(); 50 51 51 52 List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class); … … 186 187 @Override 187 188 protected void updateEnabledState() { 188 if (getCurrentDataSet() == null) { 189 DataSet ds = getLayerManager().getEditDataSet(); 190 if (ds == null) { 189 191 setEnabled(false); 190 192 } else { 191 updateEnabledState( getCurrentDataSet().getSelected());193 updateEnabledState(ds.getSelected()); 192 194 } 193 195 } -
trunk/src/org/openstreetmap/josm/actions/UnselectAllAction.java
r9059 r10382 27 27 if (!isEnabled()) 28 28 return; 29 get CurrentDataSet().setSelected();29 getLayerManager().getEditDataSet().setSelected(); 30 30 } 31 31 … … 35 35 @Override 36 36 protected void updateEnabledState() { 37 setEnabled(get EditLayer() != null);37 setEnabled(getLayerManager().getEditLayer() != null); 38 38 } 39 39 } -
trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r10074 r10382 15 15 import org.openstreetmap.josm.actions.downloadtasks.DownloadTaskList; 16 16 import org.openstreetmap.josm.data.DataSource; 17 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 18 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 18 19 import org.openstreetmap.josm.io.OnlineResource; … … 40 41 @Override 41 42 protected void updateEnabledState() { 42 setEnabled(get EditLayer() != null && !Main.isOffline(OnlineResource.OSM_API));43 setEnabled(getLayerManager().getEditLayer() != null && !Main.isOffline(OnlineResource.OSM_API)); 43 44 } 44 45 45 46 @Override 46 47 public void actionPerformed(ActionEvent e) { 47 if (!isEnabled()) 48 return; 49 if (getEditLayer() == null) 48 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 49 if (!isEnabled() || editLayer == null) 50 50 return; 51 51 52 52 List<Area> areas = new ArrayList<>(); 53 for (DataSource ds : getEditLayer().data.dataSources) {53 for (DataSource ds : editLayer.data.dataSources) { 54 54 areas.add(new Area(ds.bounds.asRect())); 55 55 } … … 57 57 // The next two blocks removes every intersection from every DataSource Area 58 58 // This prevents downloading the same data numerous times at intersections 59 // and also skips smaller bounding boxes that are contained within larger ones 60 // entirely. 59 // and also skips smaller bounding boxes that are contained within larger ones entirely. 61 60 for (int i = 0; i < areas.size(); i++) { 62 61 for (int j = i+1; j < areas.size(); j++) { … … 80 79 81 80 if (areasToDownload.isEmpty()) { 82 // no bounds defined in the dataset? we update all primitives in the data set 83 // using a series of multi fetch requests 84 // 85 UpdateSelectionAction.updatePrimitives(getEditLayer().data.allPrimitives()); 81 // no bounds defined in the dataset? we update all primitives in the data set using a series of multi fetch requests 82 UpdateSelectionAction.updatePrimitives(editLayer.data.allPrimitives()); 86 83 } else { 87 84 // bounds defined? => use the bbox downloader 88 //89 85 final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download data")); 90 86 final Future<?> future = new DownloadTaskList().download(false /* no new layer */, areasToDownload, true, false, monitor); -
trunk/src/org/openstreetmap/josm/actions/UpdateModifiedAction.java
r9989 r10382 10 10 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.data.osm.DataSet; 12 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 14 import org.openstreetmap.josm.io.OnlineResource; … … 45 46 @Override 46 47 protected void updateEnabledState() { 47 setEnabled(get CurrentDataSet() != null && !Main.isOffline(OnlineResource.OSM_API));48 setEnabled(getLayerManager().getEditDataSet() != null && !Main.isOffline(OnlineResource.OSM_API)); 48 49 } 49 50 … … 55 56 @Override 56 57 public Collection<OsmPrimitive> getData() { 57 if (getCurrentDataSet() == null) return Collections.emptyList();58 return getCurrentDataSet().allModifiedPrimitives();58 DataSet ds = getLayerManager().getEditDataSet(); 59 return ds == null ? Collections.<OsmPrimitive>emptyList() : ds.allModifiedPrimitives(); 59 60 } 60 61 } -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r10212 r10382 114 114 @Override 115 115 protected void updateEnabledState() { 116 if (getCurrentDataSet() == null) { 116 DataSet ds = getLayerManager().getEditDataSet(); 117 if (ds == null) { 117 118 setEnabled(false); 118 119 } else { 119 updateEnabledState( getCurrentDataSet().getAllSelected());120 updateEnabledState(ds.getAllSelected()); 120 121 } 121 122 } … … 148 149 */ 149 150 public Collection<OsmPrimitive> getData() { 150 return get CurrentDataSet().getAllSelected();151 return getLayerManager().getEditDataSet().getAllSelected(); 151 152 } 152 153 } -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r9972 r10382 126 126 } 127 127 128 /** 129 * Constructs a new {@code UploadAction}. 130 */ 128 131 public UploadAction() { 129 132 super(tr("Upload data"), "upload", tr("Upload all changes in the active data layer to the OSM server"), … … 138 141 @Override 139 142 protected void updateEnabledState() { 140 setEnabled(get EditLayer() != null);143 setEnabled(getLayerManager().getEditLayer() != null); 141 144 } 142 145 -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r10234 r10382 58 58 @Override 59 59 protected void updateEnabledState() { 60 if (getCurrentDataSet() == null) { 60 DataSet ds = getLayerManager().getEditDataSet(); 61 if (ds == null) { 61 62 setEnabled(false); 62 63 } else { 63 updateEnabledState( getCurrentDataSet().getAllSelected());64 updateEnabledState(ds.getAllSelected()); 64 65 } 65 66 } … … 94 95 @Override 95 96 public void actionPerformed(ActionEvent e) { 97 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 96 98 if (!isEnabled()) 97 99 return; 98 if ( getEditLayer().isUploadDiscouraged()) {99 if (UploadAction.warnUploadDiscouraged( getEditLayer())) {100 if (editLayer.isUploadDiscouraged()) { 101 if (UploadAction.warnUploadDiscouraged(editLayer)) { 100 102 return; 101 103 } 102 104 } 103 Collection<OsmPrimitive> modifiedCandidates = getModifiedPrimitives( getEditLayer().data.getAllSelected());104 Collection<OsmPrimitive> deletedCandidates = getDeletedPrimitives( getEditLayer().data);105 Collection<OsmPrimitive> modifiedCandidates = getModifiedPrimitives(editLayer.data.getAllSelected()); 106 Collection<OsmPrimitive> deletedCandidates = getDeletedPrimitives(editLayer.data); 105 107 if (modifiedCandidates.isEmpty() && deletedCandidates.isEmpty()) { 106 108 JOptionPane.showMessageDialog( … … 130 132 return; 131 133 } 132 uploadPrimitives( getEditLayer(), toUpload);134 uploadPrimitives(editLayer, toUpload); 133 135 } 134 136 -
trunk/src/org/openstreetmap/josm/actions/ValidateAction.java
r10378 r10382 96 96 @Override 97 97 public void updateEnabledState() { 98 setEnabled(get EditLayer() != null);98 setEnabled(getLayerManager().getEditLayer() != null); 99 99 } 100 100 -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r9496 r10382 211 211 private void repaintIfRequired(Set<OsmPrimitive> newHighlights, WaySegment newHighlightedWaySegment) { 212 212 boolean needsRepaint = false; 213 DataSet ds = get CurrentDataSet();213 DataSet ds = getLayerManager().getEditDataSet(); 214 214 215 215 if (newHighlightedWaySegment == null && oldHighlightedWaySegment != null) { … … 294 294 } 295 295 296 get CurrentDataSet().setSelected();296 getLayerManager().getEditDataSet().setSelected(); 297 297 giveUserFeedback(e); 298 298 } … … 390 390 private Command buildDeleteCommands(MouseEvent e, int modifiers, boolean silent) { 391 391 DeleteParameters parameters = getDeleteParameters(e, modifiers); 392 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 392 393 switch (parameters.mode) { 393 394 case node: 394 return DeleteCommand.delete( getEditLayer(), Collections.singleton(parameters.nearestNode), false, silent);395 return DeleteCommand.delete(editLayer, Collections.singleton(parameters.nearestNode), false, silent); 395 396 case node_with_references: 396 return DeleteCommand.deleteWithReferences( getEditLayer(), Collections.singleton(parameters.nearestNode), silent);397 return DeleteCommand.deleteWithReferences(editLayer, Collections.singleton(parameters.nearestNode), silent); 397 398 case segment: 398 return DeleteCommand.deleteWaySegment( getEditLayer(), parameters.nearestSegment);399 return DeleteCommand.deleteWaySegment(editLayer, parameters.nearestSegment); 399 400 case way: 400 return DeleteCommand.delete( getEditLayer(), Collections.singleton(parameters.nearestSegment.way), false, silent);401 return DeleteCommand.delete(editLayer, Collections.singleton(parameters.nearestSegment.way), false, silent); 401 402 case way_with_nodes: 402 return DeleteCommand.delete( getEditLayer(), Collections.singleton(parameters.nearestSegment.way), true, silent);403 return DeleteCommand.delete(editLayer, Collections.singleton(parameters.nearestSegment.way), true, silent); 403 404 case way_with_references: 404 return DeleteCommand.deleteWithReferences( getEditLayer(), Collections.singleton(parameters.nearestSegment.way), true);405 return DeleteCommand.deleteWithReferences(editLayer, Collections.singleton(parameters.nearestSegment.way), true); 405 406 default: 406 407 return null; -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r10378 r10382 185 185 186 186 // update selection to reflect which way being modified 187 DataSet currentDataSet = get CurrentDataSet();187 DataSet currentDataSet = getLayerManager().getEditDataSet(); 188 188 if (getCurrentBaseNode() != null && currentDataSet != null && !currentDataSet.getSelected().isEmpty()) { 189 189 Way continueFrom = getWayForNode(getCurrentBaseNode()); … … 219 219 // determine if selection is suitable to continue drawing. If it 220 220 // isn't, set wayIsFinished to true to avoid superfluous repaints. 221 determineCurrentBaseNodeAndPreviousNode(get CurrentDataSet().getSelected());221 determineCurrentBaseNodeAndPreviousNode(getLayerManager().getEditDataSet().getSelected()); 222 222 wayIsFinished = getCurrentBaseNode() == null; 223 223 … … 272 272 // primitives 273 273 // 274 DataSet ds = get CurrentDataSet();274 DataSet ds = getLayerManager().getEditDataSet(); 275 275 if (ds != null) { 276 276 ds.fireSelectionChanged(); … … 324 324 325 325 private void tryAgain(MouseEvent e) { 326 get CurrentDataSet().setSelected();326 getLayerManager().getEditDataSet().setSelected(); 327 327 mouseReleased(e); 328 328 } … … 394 394 mousePos = e.getPoint(); 395 395 396 DataSet ds = get CurrentDataSet();396 DataSet ds = getLayerManager().getEditDataSet(); 397 397 Collection<OsmPrimitive> selection = new ArrayList<>(ds.getSelected()); 398 398 … … 400 400 Node n = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive.isSelectablePredicate); 401 401 if (ctrl) { 402 Iterator<Way> it = getCurrentDataSet().getSelectedWays().iterator();402 Iterator<Way> it = ds.getSelectedWays().iterator(); 403 403 if (it.hasNext()) { 404 404 // ctrl-click on node of selected way = reuse node despite of ctrl … … 416 416 // have to switch modes) 417 417 418 getCurrentDataSet().setSelected(n);418 ds.setSelected(n); 419 419 // If we extend/continue an existing way, select it already now to make it obvious 420 420 Way continueFrom = getWayForNode(n); 421 421 if (continueFrom != null) { 422 getCurrentDataSet().addSelected(continueFrom);422 ds.addSelected(continueFrom); 423 423 } 424 424 … … 615 615 } 616 616 617 getCurrentDataSet().setSelected(newSelection);617 ds.setSelected(newSelection); 618 618 619 619 // "viewport following" mode for tracing long features … … 695 695 (posn0 < selectedWay.getNodesCount()-1) && targetNode.equals(selectedWay.getNode(posn0+1))) { // next node 696 696 // CHECKSTYLE.ON: SingleSpaceSeparator 697 get CurrentDataSet().setSelected(targetNode);697 getLayerManager().getEditDataSet().setSelected(targetNode); 698 698 lastUsedNode = targetNode; 699 699 return true; … … 779 779 } 780 780 781 Collection<OsmPrimitive> selection = get CurrentDataSet().getSelected();781 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected(); 782 782 783 783 MapView mv = Main.map.mapView; … … 1085 1085 1086 1086 // This happens when nothing is selected, but we still want to highlight the "target node" 1087 if (mouseOnExistingNode == null && get CurrentDataSet().getSelected().isEmpty()1087 if (mouseOnExistingNode == null && getLayerManager().getEditDataSet().getSelected().isEmpty() 1088 1088 && mousePos != null) { 1089 1089 mouseOnExistingNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive.isSelectablePredicate); … … 1209 1209 1210 1210 Node n = mouseOnExistingNode; 1211 DataSet ds = getLayerManager().getEditDataSet(); 1211 1212 /* 1212 1213 * Handle special case: Highlighted node == selected node => finish drawing 1213 1214 */ 1214 if (n != null && getCurrentDataSet() != null && getCurrentDataSet().getSelectedNodes().contains(n)) {1215 if (n != null && ds != null && ds.getSelectedNodes().contains(n)) { 1215 1216 if (wayIsFinished) { 1216 1217 rv = new StringBuilder(tr("Select node under cursor.")); … … 1223 1224 * Handle special case: Self-Overlapping or closing way 1224 1225 */ 1225 if ( getCurrentDataSet() != null && !getCurrentDataSet().getSelectedWays().isEmpty() && !wayIsFinished && !alt) {1226 Way w = getCurrentDataSet().getSelectedWays().iterator().next();1226 if (ds != null && !ds.getSelectedWays().isEmpty() && !wayIsFinished && !alt) { 1227 Way w = ds.getSelectedWays().iterator().next(); 1227 1228 for (Node m : w.getNodes()) { 1228 1229 if (m.equals(mouseOnExistingNode) || mouseOnExistingWays.contains(w)) { … … 1246 1247 */ 1247 1248 public Collection<OsmPrimitive> getInProgressSelection() { 1248 DataSet ds = get CurrentDataSet();1249 DataSet ds = getLayerManager().getEditDataSet(); 1249 1250 if (ds == null) return null; 1250 1251 if (getCurrentBaseNode() != null && !ds.getSelected().isEmpty()) { … … 1263 1264 @Override 1264 1265 protected void updateEnabledState() { 1265 setEnabled(get EditLayer() != null);1266 setEnabled(getLayerManager().getEditLayer() != null); 1266 1267 } 1267 1268 … … 1295 1296 // select last added node - maybe we will continue drawing from it 1296 1297 if (n != null) { 1297 get CurrentDataSet().addSelected(n);1298 getLayerManager().getEditDataSet().addSelected(n); 1298 1299 } 1299 1300 } … … 1635 1636 projectionSource = null; 1636 1637 if (snapToProjections) { 1637 DataSet ds = get CurrentDataSet();1638 DataSet ds = getLayerManager().getEditDataSet(); 1638 1639 Collection<Way> selectedWays = ds.getSelectedWays(); 1639 1640 if (selectedWays.size() == 1) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r10378 r10382 427 427 mode = Mode.create_new; 428 428 // create a new segment and then select and extrude the new segment 429 get CurrentDataSet().setSelected(selectedSegment.way);429 getLayerManager().getEditDataSet().setSelected(selectedSegment.way); 430 430 alwaysCreateNodes = true; 431 431 } else { 432 432 mode = Mode.extrude; 433 get CurrentDataSet().setSelected(selectedSegment.way);433 getLayerManager().getEditDataSet().setSelected(selectedSegment.way); 434 434 alwaysCreateNodes = shift; 435 435 } … … 611 611 Command c = new SequenceCommand(tr("Extrude Way"), cmds); 612 612 Main.main.undoRedo.add(c); 613 get CurrentDataSet().setSelected(wnew);613 getLayerManager().getEditDataSet().setSelected(wnew); 614 614 } 615 615 -
trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
r10214 r10382 135 135 oldModeHelpText = ""; 136 136 137 if (get CurrentDataSet() == null) {137 if (getLayerManager().getEditDataSet() == null) { 138 138 return; 139 139 } … … 211 211 @Override 212 212 protected void updateEnabledState() { 213 setEnabled(get EditLayer() != null);213 setEnabled(getLayerManager().getEditLayer() != null); 214 214 } 215 215 … … 410 410 if (state == State.selecting) { 411 411 if (targetWay != null) { 412 get CurrentDataSet().setSelected(targetWay.getPrimitiveId());412 getLayerManager().getEditDataSet().setSelected(targetWay.getPrimitiveId()); 413 413 updateStateByCurrentSelection(); 414 414 } … … 501 501 List<Node> nodeList = new ArrayList<>(); 502 502 nodeList.add(candidateNode); 503 Command deleteCmd = DeleteCommand.delete(get EditLayer(), nodeList, true);503 Command deleteCmd = DeleteCommand.delete(getLayerManager().getEditLayer(), nodeList, true); 504 504 if (deleteCmd != null) { 505 505 Main.main.undoRedo.add(deleteCmd); … … 513 513 EastNorth cursorEN = mv.getEastNorth(mousePos.x, mousePos.y); 514 514 515 Main.main.undoRedo.add(new MoveCommand(candidateNode, cursorEN.east() - nodeEN.east(), cursorEN.north() 516 - nodeEN.north())); 515 Main.main.undoRedo.add(new MoveCommand(candidateNode, cursorEN.east() - nodeEN.east(), cursorEN.north() - nodeEN.north())); 517 516 } 518 517 } … … 619 618 state = State.improving; 620 619 621 Collection<OsmPrimitive> currentSelection = getCurrentDataSet().getSelected(); 620 DataSet ds = getLayerManager().getEditDataSet(); 621 Collection<OsmPrimitive> currentSelection = ds.getSelected(); 622 622 if (currentSelection.size() != 1 623 623 || !currentSelection.iterator().next().equals(targetWay)) { 624 624 selectionChangedBlocked = true; 625 getCurrentDataSet().clearSelection();626 getCurrentDataSet().setSelected(targetWay.getPrimitiveId());625 ds.clearSelection(); 626 ds.setSelected(targetWay.getPrimitiveId()); 627 627 selectionChangedBlocked = false; 628 628 } … … 645 645 final List<Node> nodeList = new ArrayList<>(); 646 646 final List<Way> wayList = new ArrayList<>(); 647 final Collection<OsmPrimitive> sel = get CurrentDataSet().getSelected();647 final Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected(); 648 648 649 649 // Collecting nodes and ways from the selection -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r10378 r10382 160 160 //// Needed to update the mouse cursor if modifiers are changed when the mouse is motionless 161 161 Main.map.keyDetector.addModifierListener(this); 162 sourceWays = new LinkedHashSet<>(get CurrentDataSet().getSelectedWays());162 sourceWays = new LinkedHashSet<>(getLayerManager().getEditDataSet().getSelectedWays()); 163 163 for (Way w : sourceWays) { 164 164 w.setHighlighted(true); … … 302 302 // Since the created way is left selected, we need to unselect again here 303 303 if (pWays != null && pWays.getWays() != null) { 304 get CurrentDataSet().clearSelection(pWays.getWays());304 getLayerManager().getEditDataSet().clearSelection(pWays.getWays()); 305 305 pWays = null; 306 306 } … … 490 490 } 491 491 492 // //We keep the source ways and the selection in sync so the user can see the source way's tags492 // We keep the source ways and the selection in sync so the user can see the source way's tags 493 493 private void addSourceWay(Way w) { 494 494 assert sourceWays != null; 495 get CurrentDataSet().addSelected(w);495 getLayerManager().getEditDataSet().addSelected(w); 496 496 w.setHighlighted(true); 497 497 sourceWays.add(w); … … 500 500 private void removeSourceWay(Way w) { 501 501 assert sourceWays != null; 502 get CurrentDataSet().clearSelection(w);502 getLayerManager().getEditDataSet().clearSelection(w); 503 503 w.setHighlighted(false); 504 504 sourceWays.remove(w); … … 507 507 private void clearSourceWays() { 508 508 assert sourceWays != null; 509 get CurrentDataSet().clearSelection(sourceWays);509 getLayerManager().getEditDataSet().clearSelection(sourceWays); 510 510 for (Way w : sourceWays) { 511 511 w.setHighlighted(false); … … 543 543 pWays = new ParallelWays(sourceWays, copyTags, referenceWayIndex); 544 544 pWays.commit(); 545 get CurrentDataSet().setSelected(pWays.getWays());545 getLayerManager().getEditDataSet().setSelected(pWays.getWays()); 546 546 return true; 547 547 } catch (IllegalArgumentException e) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r10342 r10382 256 256 if (mode == Mode.MOVE) { 257 257 if (!dragInProgress() && virtualManager.activateVirtualNodeNearPoint(e.getPoint())) { 258 DataSet ds = get CurrentDataSet();258 DataSet ds = getLayerManager().getEditDataSet(); 259 259 if (ds != null && drawTargetHighlight) { 260 260 ds.setHighlightedVirtualNodes(virtualManager.virtualWays); … … 306 306 // only consider merge if ctrl is pressed and there are nodes in 307 307 // the selection that could be merged 308 if (!ctrl || get CurrentDataSet().getSelectedNodes().isEmpty()) {308 if (!ctrl || getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) { 309 309 c = "move"; 310 310 break; … … 348 348 private boolean removeHighlighting() { 349 349 boolean needsRepaint = false; 350 DataSet ds = get CurrentDataSet();350 DataSet ds = getLayerManager().getEditDataSet(); 351 351 if (ds != null && !ds.getHighlightedVirtualNodes().isEmpty()) { 352 352 needsRepaint = true; … … 427 427 case SCALE: 428 428 // if nothing was selected, select primitive under cursor for scaling or rotating 429 if (getCurrentDataSet().getSelected().isEmpty()) { 430 getCurrentDataSet().setSelected(asColl(nearestPrimitive)); 429 DataSet ds = getLayerManager().getEditDataSet(); 430 if (ds.getSelected().isEmpty()) { 431 ds.setSelected(asColl(nearestPrimitive)); 431 432 } 432 433 … … 519 520 // If ctrl is pressed we are in merge mode. Look for a nearby node, 520 521 // highlight it and adjust the cursor accordingly. 521 final boolean canMerge = ctrl && !get CurrentDataSet().getSelectedNodes().isEmpty();522 final boolean canMerge = ctrl && !getLayerManager().getEditDataSet().getSelectedNodes().isEmpty(); 522 523 final OsmPrimitive p = canMerge ? findNodeToMergeTo(e.getPoint()) : null; 523 524 boolean needsRepaint = removeHighlighting(); … … 593 594 594 595 // Select Draw Tool if no selection has been made 595 if (get CurrentDataSet().getSelected().isEmpty() && !cancelDrawMode) {596 if (getLayerManager().getEditDataSet().getSelected().isEmpty() && !cancelDrawMode) { 596 597 Main.map.selectDrawTool(true); 597 598 updateStatusLine(); … … 611 612 612 613 // If the user double-clicked a node, change to draw mode 613 Collection<OsmPrimitive> c = get CurrentDataSet().getSelected();614 Collection<OsmPrimitive> c = getLayerManager().getEditDataSet().getSelected(); 614 615 if (e.getClickCount() >= 2 && c.size() == 1 && c.iterator().next() instanceof Node) { 615 616 // We need to do it like this as otherwise drawAction will see a double … … 705 706 // Currently we support only transformations which do not affect relations. 706 707 // So don't add them in the first place to make handling easier 707 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelectedNodesAndWays(); 708 DataSet ds = getLayerManager().getEditDataSet(); 709 Collection<OsmPrimitive> selection = ds.getSelectedNodesAndWays(); 708 710 if (selection.isEmpty()) { // if nothing was selected to drag, just select nearest node/way to the cursor 709 711 OsmPrimitive nearestPrimitive = mv.getNearestNodeOrWay(mv.getPoint(startEN), mv.isSelectablePredicate, true); 710 getCurrentDataSet().setSelected(nearestPrimitive);712 ds.setSelected(nearestPrimitive); 711 713 } 712 714 … … 719 721 if (mode == Mode.MOVE) { 720 722 if (startEN == null) return false; // fix #8128 721 getCurrentDataSet().beginUpdate();723 ds.beginUpdate(); 722 724 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { 723 725 ((MoveCommand) c).saveCheckpoint(); … … 732 734 // Revert move 733 735 ((MoveCommand) c).resetToCheckpoint(); 734 getCurrentDataSet().endUpdate();736 ds.endUpdate(); 735 737 JOptionPane.showMessageDialog( 736 738 Main.parent, … … 749 751 } 750 752 751 getCurrentDataSet().beginUpdate();753 ds.beginUpdate(); 752 754 753 755 if (mode == Mode.ROTATE) { … … 765 767 } 766 768 767 Collection<Way> ways = getCurrentDataSet().getSelectedWays();769 Collection<Way> ways = ds.getSelectedWays(); 768 770 if (doesImpactStatusLine(affectedNodes, ways)) { 769 771 Main.map.statusLine.setDist(ways); 770 772 } 771 773 } 772 getCurrentDataSet().endUpdate();774 ds.endUpdate(); 773 775 return true; 774 776 } … … 790 792 private void useLastMoveCommandIfPossible() { 791 793 Command c = getLastCommand(); 792 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(get CurrentDataSet().getSelected());794 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(getLayerManager().getEditDataSet().getSelected()); 793 795 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { 794 796 // old command was created with different base point of movement, we need to recalculate it … … 829 831 } 830 832 int max = Main.pref.getInteger("warn.move.maxelements", 20), limit = max; 831 for (OsmPrimitive osm : get CurrentDataSet().getSelected()) {833 for (OsmPrimitive osm : getLayerManager().getEditDataSet().getSelected()) { 832 834 if (osm instanceof Way) { 833 835 limit -= ((Way) osm).getNodes().size(); … … 855 857 if (ctrl) mergePrims(e.getPoint()); 856 858 } 857 get CurrentDataSet().fireSelectionChanged();859 getLayerManager().getEditDataSet().fireSelectionChanged(); 858 860 } 859 861 … … 890 892 */ 891 893 private void mergePrims(Point p) { 892 Collection<Node> selNodes = getCurrentDataSet().getSelectedNodes(); 894 DataSet ds = getLayerManager().getEditDataSet(); 895 Collection<Node> selNodes = ds.getSelectedNodes(); 893 896 if (selNodes.isEmpty()) 894 897 return; … … 900 903 if (selNodes.size() == 1) { 901 904 // Move all selected primitive to preserve shape #10748 902 Collection<OsmPrimitive> selection = 903 getCurrentDataSet().getSelectedNodesAndWays(); 905 Collection<OsmPrimitive> selection = ds.getSelectedNodesAndWays(); 904 906 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 905 907 Command c = getLastCommand(); 906 getCurrentDataSet().beginUpdate();908 ds.beginUpdate(); 907 909 if (c instanceof MoveCommand 908 910 && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { … … 913 915 targetEN.getY() - selectedEN.getY()); 914 916 } 915 getCurrentDataSet().endUpdate();917 ds.endUpdate(); 916 918 } 917 919 … … 941 943 private Node findNodeToMergeTo(Point p) { 942 944 Collection<Node> target = mv.getNearestNodes(p, 943 get CurrentDataSet().getSelectedNodes(),945 getLayerManager().getEditDataSet().getSelectedNodes(), 944 946 mv.isSelectablePredicate); 945 947 return target.isEmpty() ? null : target.iterator().next(); … … 947 949 948 950 private void selectPrims(Collection<OsmPrimitive> prims, boolean released, boolean area) { 949 DataSet ds = get CurrentDataSet();951 DataSet ds = getLayerManager().getEditDataSet(); 950 952 951 953 // not allowed together: do not change dataset selection, return early … … 996 998 return tr("Release the mouse button to select the objects in the rectangle."); 997 999 else if (mode == Mode.MOVE && (System.currentTimeMillis() - mouseDownTime >= initialMoveDelay)) { 998 final boolean canMerge = getCurrentDataSet() != null && !getCurrentDataSet().getSelectedNodes().isEmpty(); 999 final String mergeHelp = canMerge ? ' ' + tr("Ctrl to merge with nearest node.") : ""; 1000 final DataSet ds = getLayerManager().getEditDataSet(); 1001 final boolean canMerge = ds != null && !ds.getSelectedNodes().isEmpty(); 1002 final String mergeHelp = canMerge ? (' ' + tr("Ctrl to merge with nearest node.")) : ""; 1000 1003 return tr("Release the mouse button to stop moving.") + mergeHelp; 1001 1004 } else if (mode == Mode.ROTATE) … … 1110 1113 // updateKeyModifiers() already called before! 1111 1114 1112 DataSet ds = get CurrentDataSet();1115 DataSet ds = getLayerManager().getEditDataSet(); 1113 1116 OsmPrimitive first = cycleList.iterator().next(), foundInDS = null; 1114 1117 OsmPrimitive nxt = first; … … 1245 1248 virtualWays.size()); 1246 1249 Main.main.undoRedo.add(new SequenceCommand(text, virtualCmds)); 1247 get CurrentDataSet().setSelected(Collections.singleton((OsmPrimitive) virtualNode));1250 getLayerManager().getEditDataSet().setSelected(Collections.singleton((OsmPrimitive) virtualNode)); 1248 1251 clear(); 1249 1252 } -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r10001 r10382 784 784 @Override 785 785 protected void updateEnabledState() { 786 setEnabled(get EditLayer() != null);786 setEnabled(getLayerManager().getEditLayer() != null); 787 787 } 788 788 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchPrimitiveDialog.java
r9445 r10382 52 52 @Override 53 53 protected void updateEnabledState() { 54 setEnabled(get EditLayer() != null);54 setEnabled(getLayerManager().getEditLayer() != null); 55 55 } 56 56 }
Note:
See TracChangeset
for help on using the changeset viewer.