Ticket #17599: 17599.patch
| File 17599.patch, 4.8 KB (added by , 7 years ago) |
|---|
-
src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilder.java
16 16 import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole; 17 17 import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionType; 18 18 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 import org.openstreetmap.josm.tools.Utils; 19 20 20 21 /** 21 22 * TurnRestrictionBuilder creates a turn restriction and initializes it with … … 312 313 if (primitives.size() != 2) return null; 313 314 314 315 // we need exactly one node and one way in the selection ... 315 List<Node> nodes = OsmPrimitive.getFilteredList(primitives, Node.class);316 List<Way> ways = OsmPrimitive.getFilteredList(primitives, Way.class);316 List<Node> nodes = new ArrayList<>(Utils.filteredCollection(primitives, Node.class)); 317 List<Way> ways = new ArrayList<>(Utils.filteredCollection(primitives, Way.class)); 317 318 if (nodes.size() != 1 || ways.size() != 1) return null; 318 319 319 320 // .. and the node has to be the start or the node of the way … … 373 374 // if we have exactly two selected primitives, we expect two ways. 374 375 // See initNoUTurnRestriction() for the case where we have a selected way 375 376 // and a selected node 376 List<Way> selWays = OsmPrimitive.getFilteredList(primitives, Way.class);377 List<Way> selWays = new ArrayList<>(Utils.filteredCollection(primitives, Way.class)); 377 378 if (selWays.size() != 2) return null; 378 379 w1 = selWays.get(0); 379 380 w2 = selWays.get(1); … … 381 382 } else if (primitives.size() == 3) { 382 383 // if we have exactly three selected primitives, we need two ways and a 383 384 // node, which should be an acceptable via node 384 List<Way> selWays = OsmPrimitive.getFilteredList(primitives, Way.class);385 List<Node> selNodes = OsmPrimitive.getFilteredList(primitives, Node.class);385 List<Way> selWays = new ArrayList<>(Utils.filteredCollection(primitives, Way.class)); 386 List<Node> selNodes = new ArrayList<>(Utils.filteredCollection(primitives, Node.class)); 386 387 if (selWays.size() != 2) return null; 387 388 if (selNodes.size() != 1) return null; 388 389 w1 = selWays.get(0); … … 448 449 // case 0 already handled 449 450 case 1: 450 451 tr = initEmptyTurnRestriction(); 451 if ( OsmPrimitive.getFilteredList(primitives, Way.class).size() == 1) {452 if (Utils.filteredCollection(primitives, Way.class).size() == 1) { 452 453 // we have exactly one selected way? -> init the "from" leg 453 454 // of the turn restriction with it 454 455 tr.addMember(new RelationMember("from", primitives.get(0))); -
src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditor.java
19 19 import java.awt.event.MouseEvent; 20 20 import java.awt.event.MouseMotionAdapter; 21 21 import java.io.IOException; 22 import java.util.ArrayList; 22 23 import java.util.Collections; 23 24 import java.util.HashSet; 24 25 import java.util.List; … … 54 55 import org.openstreetmap.josm.tools.CheckParameterUtil; 55 56 import org.openstreetmap.josm.tools.ImageProvider; 56 57 import org.openstreetmap.josm.tools.Shortcut; 58 import org.openstreetmap.josm.tools.Utils; 57 59 58 60 /** 59 61 * This is an editor for one of the two legs of a turn restriction. … … 292 294 293 295 @Override 294 296 public void actionPerformed(ActionEvent e) { 295 List<Way> selWays = OsmPrimitive.getFilteredList(model.getJosmSelectionListModel().getSelected(), Way.class);297 List<Way> selWays = new ArrayList<>(Utils.filteredCollection(model.getJosmSelectionListModel().getSelected(), Way.class)); 296 298 if (selWays.size() != 1) return; 297 299 Way w = selWays.get(0); 298 300 model.setTurnRestrictionLeg(role, w); … … 299 301 } 300 302 301 303 public void updateEnabledState() { 302 setEnabled( OsmPrimitive.getFilteredList(model.getJosmSelectionListModel().getSelected(), Way.class).size() == 1);304 setEnabled(Utils.filteredCollection(model.getJosmSelectionListModel().getSelected(), Way.class).size() == 1); 303 305 } 304 306 305 307 @Override
