Changeset 2348 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-10-29T19:45:49+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r2098 r2348 50 50 51 51 // the command may have changed the selection so tell the listeners about the current situation 52 DataSet.fireSelectionChanged(Main.main.getCurrentDataSet().getSelected());52 Main.main.getCurrentDataSet().fireSelectionChanged(); 53 53 } 54 54 -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2317 r2348 26 26 */ 27 27 public class DataSet implements Cloneable { 28 29 /** 30 * The API version that created this data set, if any. 31 */ 32 public String version; 33 34 /** 35 * All nodes goes here, even when included in other data (ways etc). This enables the instant 36 * conversion of the whole DataSet by iterating over this data structure. 37 */ 38 public QuadBuckets<Node> nodes = new QuadBuckets<Node>(); 39 40 /** 41 * All ways (Streets etc.) in the DataSet. 42 * 43 * The way nodes are stored only in the way list. 44 */ 45 public QuadBuckets<Way> ways = new QuadBuckets<Way>(); 46 47 /** 48 * All relations/relationships 49 */ 50 public Collection<Relation> relations = new LinkedList<Relation>(); 51 52 /** 53 * All data sources of this DataSet. 54 */ 55 public Collection<DataSource> dataSources = new LinkedList<DataSource>(); 56 28 57 29 /** 58 30 * A list of listeners to selection changed events. The list is static, as listeners register … … 61 33 */ 62 34 public static Collection<SelectionChangedListener> selListeners = new LinkedList<SelectionChangedListener>(); 63 35 36 /** 37 * notifies all registered selection change listeners about the current selection of 38 * primitives 39 * 40 * @param sel the current selection 41 */ 42 private static void notifySelectionChangeListeners(Collection<? extends OsmPrimitive> sel) { 43 for (SelectionChangedListener l : selListeners) { 44 l.selectionChanged(sel); 45 } 46 } 47 48 /** 49 * The API version that created this data set, if any. 50 */ 51 public String version; 52 53 /** 54 * All nodes goes here, even when included in other data (ways etc). This enables the instant 55 * conversion of the whole DataSet by iterating over this data structure. 56 */ 57 public QuadBuckets<Node> nodes = new QuadBuckets<Node>(); 58 59 /** 60 * All ways (Streets etc.) in the DataSet. 61 * 62 * The way nodes are stored only in the way list. 63 */ 64 public QuadBuckets<Way> ways = new QuadBuckets<Way>(); 65 66 /** 67 * All relations/relationships 68 */ 69 public Collection<Relation> relations = new LinkedList<Relation>(); 70 71 /** 72 * All data sources of this DataSet. 73 */ 74 public Collection<DataSource> dataSources = new LinkedList<DataSource>(); 75 64 76 /** 65 77 * @return A collection containing all primitives of the dataset. The data is ordered after: … … 242 254 LinkedHashSet<OsmPrimitive> selectedPrimitives = new LinkedHashSet<OsmPrimitive>(); 243 255 244 public boolean toggleSelected(OsmPrimitive osm) { 256 public boolean toggleSelected(Collection<OsmPrimitive> osm) { 257 for (OsmPrimitive o : osm) 258 this.__toggleSelected(o); 259 fireSelectionChanged(); 260 return true; 261 } 262 public boolean toggleSelected(OsmPrimitive... osm) { 263 return this.toggleSelected(Arrays.asList(osm)); 264 } 265 private boolean __toggleSelected(OsmPrimitive osm) { 245 266 if (!selectedPrimitives.remove(osm)) { 246 267 selectedPrimitives.add(osm); … … 276 297 selectedPrimitives = new LinkedHashSet<OsmPrimitive>(selection); 277 298 if (fireSelectionChangeEvent) { 278 fireSelectionChanged( selection);299 fireSelectionChanged(); 279 300 } 280 301 } … … 314 335 selectedPrimitives.addAll(selection); 315 336 if (fireSelectionChangeEvent) { 316 fireSelectionChanged( selection);337 fireSelectionChanged(); 317 338 } 318 339 } … … 326 347 List<OsmPrimitive> list = Arrays.asList(osm); 327 348 setSelected(list); 328 fireSelectionChanged( list);349 fireSelectionChanged(); 329 350 } 330 351 … … 359 380 clearSelection(Arrays.asList(osm)); 360 381 } 361 p rivatevoid clearSelection(Collection<? extends OsmPrimitive> list) {382 public void clearSelection(Collection<? extends OsmPrimitive> list) { 362 383 if (list == null) 363 384 return; 364 385 selectedPrimitives.removeAll(list); 386 } 387 public void clearSelection() { 388 selectedPrimitives.clear(); 365 389 } 366 390 … … 381 405 382 406 /** 383 * Remember to fire an selection changed event. A call to this will not fire the event 384 * immediately. For more, 385 * @see SelectionChangedListener 386 */ 387 public static void fireSelectionChanged(Collection<? extends OsmPrimitive> sel) { 388 for (SelectionChangedListener l : selListeners) { 389 l.selectionChanged(sel); 390 } 391 } 407 * Notifies all registered {@see SelectionChangedListener} about the current selection in 408 * this dataset. 409 * 410 */ 411 public void fireSelectionChanged(){ 412 notifySelectionChangeListeners(selectedPrimitives); 413 } 414 392 415 393 416 @Override public DataSet clone() {
Note:
See TracChangeset
for help on using the changeset viewer.