Changeset 2439 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-11-11T21:34:54+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2438 r2439 47 47 private Storage<OsmPrimitive> allPrimitives = new Storage<OsmPrimitive>(new IdHash()); 48 48 private Map<PrimitiveId, OsmPrimitive> primitivesMap = allPrimitives.foreignKey(new IdHash()); 49 private List<DataSetListener> listeners = new ArrayList<DataSetListener>(); 49 50 50 51 /** … … 191 192 allPrimitives.add(primitive); 192 193 primitive.setDataset(this); 194 firePrimitivesAdded(Collections.singletonList(primitive)); 193 195 } 194 196 … … 232 234 allPrimitives.remove(primitive); 233 235 primitive.setDataset(null); 236 firePrimitivesRemoved(Collections.singletonList(primitive)); 234 237 } 235 238 … … 784 787 } 785 788 789 790 public void addDataSetListener(DataSetListener dsl) { 791 listeners.add(dsl); 792 } 793 794 public void removeDataSetListener(DataSetListener dsl) { 795 listeners.remove(dsl); 796 } 797 798 void firePrimitivesAdded(Collection<? extends OsmPrimitive> added) { 799 for (DataSetListener dsl : listeners) { 800 dsl.primtivesAdded(added); 801 } 802 } 803 804 void firePrimitivesRemoved(Collection<? extends OsmPrimitive> removed) { 805 for (DataSetListener dsl : listeners) { 806 dsl.primtivesRemoved(removed); 807 } 808 } 809 810 void fireTagsChanged(OsmPrimitive prim) { 811 for (DataSetListener dsl : listeners) { 812 dsl.tagsChanged(prim); 813 } 814 } 815 816 void fireRelationMembersChanged(Relation r) { 817 for (DataSetListener dsl : listeners) { 818 dsl.relationMembersChanged(r); 819 } 820 } 821 786 822 public void fireNodeMoved(Node node) { 787 // TODO Fire event788 823 reindexNode(node); 824 for (DataSetListener dsl : listeners) { 825 dsl.nodeMoved(node); 826 } 789 827 } 790 828 791 829 public void fireWayNodesChanged(Way way) { 792 // TODO Fire event793 830 reindexWay(way); 831 for (DataSetListener dsl : listeners) { 832 dsl.wayNodesChanged(way); 833 } 794 834 } 795 835 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2437 r2439 492 492 } 493 493 setModified(deleted); 494 if (dataSet != null) { 495 if (deleted) { 496 dataSet.firePrimitivesRemoved(Collections.singleton(this)); 497 } else { 498 dataSet.firePrimitivesAdded(Collections.singleton(this)); 499 } 500 } 494 501 } 495 502 … … 774 781 updateHasDirectionKeys(); 775 782 updateTagged(); 783 if (dataSet != null) { 784 dataSet.fireTagsChanged(this); 785 } 776 786 } 777 787 -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r2437 r2439 52 52 } 53 53 54 fireMembersChanged(); 54 55 } 55 56 … … 80 81 members.add(member); 81 82 member.getMember().addReferrer(this); 83 fireMembersChanged(); 82 84 } 83 85 … … 91 93 members.add(index, member); 92 94 member.getMember().addReferrer(this); 95 fireMembersChanged(); 93 96 } 94 97 … … 105 108 member.getMember().addReferrer(this); 106 109 result.getMember().removeReferrer(this); 110 fireMembersChanged(); 107 111 } 108 112 return result; … … 123 127 } 124 128 result.getMember().removeReferrer(this); 129 fireMembersChanged(); 125 130 return result; 126 131 } … … 264 269 primitive.removeReferrer(this); 265 270 members.removeAll(todelete); 271 fireMembersChanged(); 266 272 } 267 273 … … 298 304 primitive.removeReferrer(this); 299 305 } 306 fireMembersChanged(); 300 307 } 301 308 … … 335 342 // Do nothing for now 336 343 } 344 345 private void fireMembersChanged() { 346 if (getDataSet() != null) { 347 getDataSet().fireRelationMembersChanged(this); 348 } 349 } 337 350 }
Note:
See TracChangeset
for help on using the changeset viewer.