Changeset 454 in josm
- Timestamp:
- 2007-11-04T21:22:34+01:00 (18 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r452 r454 45 45 private Mode mode = null; 46 46 private long mouseDownTime = 0; 47 private boolean didMove = false; 47 48 48 49 /** … … 175 176 Main.map.mapView.repaint(); 176 177 mousePos = e.getPoint(); 178 179 didMove = true; 177 180 } 178 181 … … 194 197 195 198 mouseDownTime = System.currentTimeMillis(); 196 197 // find the object that was clicked on. 198 // if the object is not part of the current selection, clear current 199 // selection before proceeding. 200 Collection<OsmPrimitive> osmColl = null; 201 OsmPrimitive osm = Main.map.mapView.getNearest(e.getPoint()); 202 if (osm == null) { 203 osmColl = Collections.emptySet(); 204 Main.ds.setSelected(); 205 } else { 206 osmColl = Collections.singleton(osm); 207 if (!Main.ds.getSelected().contains(osm)) Main.ds.setSelected(); 208 } 209 199 didMove = false; 200 201 Collection<OsmPrimitive> osmColl = 202 Main.map.mapView.getNearestCollection(e.getPoint()); 203 210 204 if (ctrl && shift) { 211 205 if (Main.ds.getSelected().isEmpty()) selectPrims(osmColl, true, false); … … 213 207 setCursor(ImageProvider.getCursor("rotate", null)); 214 208 } else if (!osmColl.isEmpty()) { 215 if (Main.ds.getSelected().isEmpty()) selectPrims(osmColl, shift, ctrl); 209 // Only add to selection for now, we only do replace and remove in 210 // mouseReleased if the user didn't try to move. 211 selectPrims(osmColl, true, ctrl); 216 212 mode = Mode.move; 217 213 } else { … … 239 235 if (mode == Mode.move) { 240 236 boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 241 if (ctrl) { 237 boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 238 if (!didMove) { 239 selectPrims( 240 Main.map.mapView.getNearestCollection(e.getPoint()), 241 shift, ctrl); 242 } else if (ctrl) { 242 243 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 243 244 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r422 r454 4 4 import java.awt.Point; 5 5 import java.util.Collection; 6 import java.util.Collections; 6 7 import java.util.HashSet; 7 8 import java.util.TreeMap; … … 242 243 osm = getNearestWay(p); 243 244 return osm; 245 } 246 247 /** 248 * Returns a singleton of the nearest object, or else an empty collection. 249 */ 250 public Collection<OsmPrimitive> getNearestCollection(Point p) { 251 OsmPrimitive osm = getNearest(p); 252 if (osm == null) { 253 return Collections.emptySet(); 254 } else { 255 return Collections.singleton(osm); 256 } 244 257 } 245 258
Note:
See TracChangeset
for help on using the changeset viewer.