Changeset 12592 in josm
- Timestamp:
- 2017-08-11T19:47:58+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r12517 r12592 17 17 import java.util.Iterator; 18 18 import java.util.LinkedList; 19 import java.util.Optional; 19 20 import java.util.Set; 20 21 … … 250 251 */ 251 252 private boolean giveUserFeedback(MouseEvent e, int modifiers) { 252 Collection<OsmPrimitive> c = asColl(253 Optional<OsmPrimitive> c = Optional.ofNullable( 253 254 mv.getNearestNodeOrWay(e.getPoint(), mv.isSelectablePredicate, true)); 254 255 255 256 updateKeyModifiersEx(modifiers); 256 determineMapMode( !c.isEmpty());257 determineMapMode(c.isPresent()); 257 258 258 259 Set<OsmPrimitive> newHighlights = new HashSet<>(); … … 272 273 273 274 // return early if there can't be any highlights 274 if (!drawTargetHighlight || mode != Mode.MOVE || c.isEmpty())275 if (!drawTargetHighlight || mode != Mode.MOVE || !c.isPresent()) 275 276 return repaintIfRequired(newHighlights); 276 277 277 278 // CTRL toggles selection, but if while dragging CTRL means merge 278 279 final boolean isToggleMode = ctrl && !dragInProgress(); 279 for (OsmPrimitive x : c) {280 if (c.isPresent() && (isToggleMode || !c.get().isSelected())) { 280 281 // only highlight primitives that will change the selection 281 282 // when clicked. I.e. don't highlight selected elements unless 282 283 // we are in toggle mode. 283 if (isToggleMode || !x.isSelected()) { 284 newHighlights.add(x); 285 } 284 newHighlights.add(c.get()); 286 285 } 287 286 return repaintIfRequired(newHighlights); … … 295 294 * @return the cursor that should be displayed 296 295 */ 297 private Cursor getCursor( Collection<OsmPrimitive> nearbyStuff) {296 private Cursor getCursor(Optional<OsmPrimitive> nearbyStuff) { 298 297 String c = "rect"; 299 298 switch(mode) { … … 303 302 break; 304 303 } 305 final Iterator<OsmPrimitive> it = nearbyStuff.iterator(); 306 final OsmPrimitive osm = it.hasNext() ? it.next() : null; 304 final OsmPrimitive osm = nearbyStuff.orElse(null); 307 305 308 306 if (dragInProgress()) { … … 526 524 needsRepaint = true; 527 525 } 528 mv.setNewCursor(getCursor( asColl(p)), this);526 mv.setNewCursor(getCursor(Optional.ofNullable(p)), this); 529 527 // also update the stored mouse event, so we can display the correct cursor 530 528 // when dragging a node onto another one and then press CTRL to merge
Note:
See TracChangeset
for help on using the changeset viewer.