Changeset 2348 in josm for trunk/src/org
- Timestamp:
- 2009-10-29T19:45:49+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r2323 r2348 81 81 Main.main.undoRedo.add(new SequenceCommand(tr("Reverse ways"), c)); 82 82 if (propertiesUpdated) { 83 DataSet.fireSelectionChanged(getCurrentDataSet().getSelected());83 getCurrentDataSet().fireSelectionChanged(); 84 84 } 85 85 Main.map.repaint(); -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2323 r2348 688 688 // 689 689 layer.cleanupAfterUpload(processedPrimitives); 690 DataSet.fireSelectionChanged(layer.data.getSelected());690 layer.data.fireSelectionChanged(); 691 691 layer.fireDataChange(); 692 692 if (lastException != null) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r2339 r2348 245 245 // primitives 246 246 // 247 DataSet.fireSelectionChanged(getCurrentDataSet().getSelected());247 getCurrentDataSet().fireSelectionChanged(); 248 248 } 249 249 … … 272 272 private void tryAgain(MouseEvent e) { 273 273 getCurrentDataSet().setSelected(); 274 DataSet.fireSelectionChanged(getCurrentDataSet().getSelected());274 Main.main.getCurrentDataSet().fireSelectionChanged(); 275 275 mouseClicked(e); 276 276 } … … 284 284 // let everybody else know about the current selection 285 285 // 286 DataSet.fireSelectionChanged(getCurrentDataSet().getSelected());286 Main.main.getCurrentDataSet().fireSelectionChanged(); 287 287 lastUsedNode = null; 288 288 wayIsFinished = true; … … 345 345 // (this is just a convenience option so that people don't 346 346 // have to switch modes) 347 newSelection.clear();348 newSelection.add(n);347 getCurrentDataSet().setSelected(n); 348 selection = getCurrentDataSet().getSelected(); 349 349 // The user explicitly selected a node, so let him continue drawing 350 350 wayIsFinished = false; … … 523 523 524 524 extendedWay = true; 525 newSelection.clear();526 newSelection.add(wayToSelect);525 ds.setSelected(way); 526 ds.fireSelectionChanged(); 527 527 } 528 528 } … … 540 540 } 541 541 } 542 newSelection.add(n); 542 543 ds.setSelected(n); 544 ds.fireSelectionChanged(); 543 545 } else if (!newNode) { 544 546 title = tr("Connect existing way to node"); … … 585 587 (posn0 < selectedWay.getNodesCount()-1) && targetNode.equals(selectedWay.getNode(posn0+1))) { // next node 586 588 getCurrentDataSet().setSelected(targetNode); 587 DataSet.fireSelectionChanged(getCurrentDataSet().getSelected());589 getCurrentDataSet().fireSelectionChanged(); 588 590 lastUsedNode = targetNode; 589 591 return true; -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r2310 r2348 499 499 } 500 500 } 501 DataSet.fireSelectionChanged(selection);501 getCurrentDataSet().fireSelectionChanged(); 502 502 } 503 503 } … … 515 515 public void selectPrims(Collection<OsmPrimitive> selectionList, boolean shift, 516 516 boolean ctrl, boolean released, boolean area) { 517 DataSet ds = getCurrentDataSet(); 517 518 if ((shift && ctrl) || (ctrl && !released)) 518 519 return; // not allowed together 519 520 520 Collection<OsmPrimitive> curSel; 521 if (!ctrl && !shift) { 522 curSel = new LinkedList<OsmPrimitive>(); // new selection will replace the old. 521 // plain clicks with no modifiers clear the selection 522 if (!ctrl && !shift) 523 ds.clearSelection(); 524 525 if (ctrl) { 526 // Ctrl on an item toggles its selection status, 527 // but Ctrl on an *area* just clears those items 528 // out of the selection. 529 if (area) 530 ds.clearSelection(selectionList); 531 else 532 ds.toggleSelected(selectionList); 523 533 } else { 524 curSel = getCurrentDataSet().getSelected(); 525 } 526 527 for (OsmPrimitive osm : selectionList) 528 { 529 if (ctrl) 530 { 531 if(curSel.contains(osm)) { 532 curSel.remove(osm); 533 } else if(!area) { 534 curSel.add(osm); 535 } 536 } else { 537 curSel.add(osm); 538 } 539 } 540 getCurrentDataSet().setSelected(curSel); 534 // This is either a plain click (which means we 535 // previously cleared the selection), or a 536 // shift-click where we are adding things to an 537 // existing selection. 538 ds.addSelected(selectionList); 539 } 540 ds.fireSelectionChanged(); 541 541 Main.map.mapView.repaint(); 542 542 } -
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() { -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r2291 r2348 333 333 } 334 334 } 335 DataSet.fireSelectionChanged(ds.getSelected());335 ds.fireSelectionChanged(); 336 336 } 337 337 … … 463 463 // Let the user toggle the selection 464 464 ds.toggleSelected(osm); 465 DataSet.fireSelectionChanged(ds.getSelected());466 465 l.validate(); 467 466 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r2327 r2348 503 503 if (getCurrentDataSet() != null) { 504 504 getCurrentDataSet().setSelected(); 505 DataSet.fireSelectionChanged(getCurrentDataSet().getSelected());505 getCurrentDataSet().fireSelectionChanged(); 506 506 } 507 507 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r2224 r2348 267 267 } 268 268 269 DataSet.fireSelectionChanged(sel);269 Main.main.getCurrentDataSet().fireSelectionChanged(); 270 270 selectionChanged(sel); // update whole table 271 271 Main.parent.repaint(); // repaint all - drawing could have been changed … … 355 355 return; 356 356 Main.main.undoRedo.add(new ChangePropertyCommand(sel, key, value)); 357 DataSet.fireSelectionChanged(sel);357 Main.main.getCurrentDataSet().fireSelectionChanged(); 358 358 selectionChanged(sel); // update table 359 359 Main.parent.repaint(); // repaint all - drawing could have been changed … … 826 826 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 827 827 Main.main.undoRedo.add(new ChangePropertyCommand(sel, key, null)); 828 DataSet.fireSelectionChanged(sel);828 Main.main.getCurrentDataSet().fireSelectionChanged(); 829 829 selectionChanged(sel); // update table 830 830 … … 852 852 } 853 853 Main.main.undoRedo.add(new ChangeCommand(cur, rel)); 854 DataSet.fireSelectionChanged(sel);854 Main.main.getCurrentDataSet().fireSelectionChanged(); 855 855 selectionChanged(sel); // update whole table 856 856 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2317 r2348 517 517 } 518 518 Main.map.mapView.getEditLayer().data.setSelected(selection); 519 DataSet.fireSelectionChanged(selection);519 Main.map.mapView.getEditLayer().data.fireSelectionChanged(); 520 520 } 521 521 … … 545 545 } 546 546 Main.map.mapView.getEditLayer().data.setSelected(members); 547 DataSet.fireSelectionChanged(members);548 547 } 549 548 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2317 r2348 883 883 public void actionPerformed(ActionEvent e) { 884 884 getLayer().data.setSelected(memberTableModel.getSelectedChildPrimitives()); 885 DataSet.fireSelectionChanged(getLayer().data.getSelected());886 885 } 887 886 … … 1006 1005 // make sure everybody is notified about the changes 1007 1006 // 1008 DataSet.fireSelectionChanged(getLayer().data.getSelected());1007 getLayer().data.fireSelectionChanged(); 1009 1008 getLayer().fireDataChange(); 1010 1009 GenericRelationEditor.this.setRelation(newRelation); … … 1039 1038 memberTableModel.applyToRelation(editedRelation); 1040 1039 Main.main.undoRedo.add(new ChangeCommand(getRelation(), editedRelation)); 1041 DataSet.fireSelectionChanged(getLayer().data.getSelected());1040 getLayer().data.fireSelectionChanged(); 1042 1041 getLayer().fireDataChange(); 1043 1042 // this will refresh the snapshot and update the dialog title -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r2043 r2348 204 204 OsmPrimitive primitive = getMemberTableModel().getReferredPrimitive(row); 205 205 layer.data.setSelected(primitive); 206 DataSet.fireSelectionChanged(layer.data.getSelected());207 206 AutoScaleAction action = new AutoScaleAction("selection"); 208 207 action.autoScale(); -
trunk/src/org/openstreetmap/josm/gui/io/UploadLayerTask.java
r2198 r2348 144 144 return; 145 145 layer.cleanupAfterUpload(processedPrimitives); 146 DataSet.fireSelectionChanged(layer.data.getSelected());146 layer.data.fireSelectionChanged();; 147 147 layer.fireDataChange(); 148 148 layer.onPostUploadToServer();
Note:
See TracChangeset
for help on using the changeset viewer.