Changeset 2497 in josm
- Timestamp:
- 2009-11-22T12:06:30+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r2412 r2497 90 90 int count = 0; 91 91 for (Way w : OsmPrimitive.getFilteredList(n.getReferrers(), Way.class)) { 92 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) {92 if (w.isDeleted() || w.incomplete) { 93 93 continue; 94 94 } … … 353 353 // modify all ways containing the nodes 354 354 for (Way w : OsmPrimitive.getFilteredList(selectedNode.getReferrers(), Way.class)) { 355 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) {355 if (w.isDeleted() || w.incomplete) { 356 356 continue; 357 357 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2472 r2497 47 47 private Map<PrimitiveId, OsmPrimitive> primitivesMap = allPrimitives.foreignKey(new IdHash()); 48 48 private List<DataSetListener> listeners = new ArrayList<DataSetListener>(); 49 // Number of open calls to beginUpdate 50 private int updateCount; 49 51 50 52 /** … … 796 798 } 797 799 800 /** 801 * Can be called before bigger changes on dataset. Events are disabled until {@link #endUpdate()}. 802 * {@link DataSetListener#dataChanged()} event is triggered after end of changes 803 * <br> 804 * Typical usecase should look like this: 805 * <pre> 806 * ds.beginUpdate(); 807 * try { 808 * ... 809 * } finally { 810 * ds.endUpdate(); 811 * } 812 * </pre> 813 */ 814 public void beginUpdate() { 815 updateCount++; 816 } 817 818 /** 819 * @see DataSet#beginUpdate() 820 */ 821 public void endUpdate() { 822 if (updateCount > 0) { 823 updateCount--; 824 if (updateCount == 0) { 825 fireDataChanged(); 826 } 827 } else 828 throw new AssertionError("endUpdate called without beginUpdate"); 829 } 830 831 private void fireDataChanged() { 832 if (updateCount == 0) { 833 for (DataSetListener dsl : listeners) { 834 dsl.dataChanged(); 835 } 836 } 837 } 838 798 839 void firePrimitivesAdded(Collection<? extends OsmPrimitive> added) { 799 for (DataSetListener dsl : listeners) { 800 dsl.primtivesAdded(added); 840 if (updateCount == 0) { 841 for (DataSetListener dsl : listeners) { 842 dsl.primtivesAdded(added); 843 } 801 844 } 802 845 } 803 846 804 847 void firePrimitivesRemoved(Collection<? extends OsmPrimitive> removed) { 805 for (DataSetListener dsl : listeners) { 806 dsl.primtivesRemoved(removed); 848 if (updateCount == 0) { 849 for (DataSetListener dsl : listeners) { 850 dsl.primtivesRemoved(removed); 851 } 807 852 } 808 853 } 809 854 810 855 void fireTagsChanged(OsmPrimitive prim) { 811 for (DataSetListener dsl : listeners) { 812 dsl.tagsChanged(prim); 856 if (updateCount == 0) { 857 for (DataSetListener dsl : listeners) { 858 dsl.tagsChanged(prim); 859 } 813 860 } 814 861 } 815 862 816 863 void fireRelationMembersChanged(Relation r) { 817 for (DataSetListener dsl : listeners) { 818 dsl.relationMembersChanged(r); 819 } 820 } 821 822 public void fireNodeMoved(Node node) { 864 if (updateCount == 0) { 865 for (DataSetListener dsl : listeners) { 866 dsl.relationMembersChanged(r); 867 } 868 } 869 } 870 871 void fireNodeMoved(Node node) { 823 872 reindexNode(node); 824 for (DataSetListener dsl : listeners) { 825 dsl.nodeMoved(node); 826 } 827 } 828 829 public void fireWayNodesChanged(Way way) { 873 if (updateCount == 0) { 874 for (DataSetListener dsl : listeners) { 875 dsl.nodeMoved(node); 876 } 877 } 878 } 879 880 void fireWayNodesChanged(Way way) { 830 881 reindexWay(way); 831 for (DataSetListener dsl : listeners) { 832 dsl.wayNodesChanged(way); 882 if (updateCount == 0) { 883 for (DataSetListener dsl : listeners) { 884 dsl.wayNodesChanged(way); 885 } 833 886 } 834 887 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSetListener.java
r2439 r2497 37 37 * @param added A collection of newly-visible primitives 38 38 */ 39 publicvoid primtivesAdded(Collection<? extends OsmPrimitive> added);39 void primtivesAdded(Collection<? extends OsmPrimitive> added); 40 40 41 41 /** … … 45 45 * @param removed A collection of newly-invisible primitives 46 46 */ 47 publicvoid primtivesRemoved(Collection<? extends OsmPrimitive> removed);47 void primtivesRemoved(Collection<? extends OsmPrimitive> removed); 48 48 49 49 /** … … 53 53 * @param prim the primitive, whose tags were affected. 54 54 */ 55 publicvoid tagsChanged(OsmPrimitive prim);55 void tagsChanged(OsmPrimitive prim); 56 56 57 57 /** … … 59 59 * @param node The node that was moved. 60 60 */ 61 publicvoid nodeMoved(Node node);61 void nodeMoved(Node node); 62 62 63 63 /** … … 65 65 * @param way The way that was modified. 66 66 */ 67 publicvoid wayNodesChanged(Way way);67 void wayNodesChanged(Way way); 68 68 69 69 /** … … 71 71 * @param relation The relation that was modified. 72 72 */ 73 publicvoid relationMembersChanged(Relation r);73 void relationMembersChanged(Relation r); 74 74 75 /** 76 * Called after big changes in dataset. Usually other events are stopped using Dataset.beginUpdate() and 77 * after operation is completed (Dataset.endUpdate()), {@link #dataChanged()} is called. 78 */ 79 void dataChanged(); 75 80 76 81 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r2484 r2497 333 333 if (sourceDataSet == null) 334 334 return; 335 for (Node node: sourceDataSet.getNodes()) { 336 mergePrimitive(node); 337 } 338 for (Way way: sourceDataSet.getWays()) { 339 mergePrimitive(way); 340 } 341 for (Relation relation: sourceDataSet.getRelations()) { 342 mergePrimitive(relation); 343 } 344 fixReferences(); 335 targetDataSet.beginUpdate(); 336 try { 337 for (Node node: sourceDataSet.getNodes()) { 338 mergePrimitive(node); 339 } 340 for (Way way: sourceDataSet.getWays()) { 341 mergePrimitive(way); 342 } 343 for (Relation relation: sourceDataSet.getRelations()) { 344 mergePrimitive(relation); 345 } 346 fixReferences(); 347 } finally { 348 targetDataSet.endUpdate(); 349 } 345 350 } 346 351 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2492 r2497 788 788 } 789 789 790 public void dataChanged() { 791 Layer l = Main.main.getEditLayer(); 792 if (l != null) { 793 initFromLayer(l); 794 } 795 } 796 790 797 /* ---------------------------------------------------------------------------------- */ 791 798 /* DataSetListener */ -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r2448 r2497 822 822 } 823 823 824 public void dataChanged() { 825 dataChanged(getEditLayer()); 826 } 827 824 828 /* ---------------------------------------------------------------------- */ 825 829 /* DataChangeListener */ -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r2470 r2497 563 563 564 564 progressMonitor.subTask(tr("Preparing data set...")); 565 reader.processNodesAfterParsing(); 566 reader.processWaysAfterParsing(); 567 reader.processRelationsAfterParsing(); 565 reader.ds.beginUpdate(); 566 try { 567 reader.processNodesAfterParsing(); 568 reader.processWaysAfterParsing(); 569 reader.processRelationsAfterParsing(); 570 } finally { 571 reader.ds.endUpdate(); 572 } 568 573 progressMonitor.worked(1); 569 574 return reader.getDataSet();
Note:
See TracChangeset
for help on using the changeset viewer.