Changeset 2439 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-11-11T21:34:54+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 4 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 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2410 r2439 35 35 import org.openstreetmap.josm.Main; 36 36 import org.openstreetmap.josm.data.osm.DataSet; 37 import org.openstreetmap.josm.data.osm.DataSetListener; 37 38 import org.openstreetmap.josm.data.osm.NameFormatter; 39 import org.openstreetmap.josm.data.osm.Node; 38 40 import org.openstreetmap.josm.data.osm.OsmPrimitive; 39 41 import org.openstreetmap.josm.data.osm.Relation; 40 42 import org.openstreetmap.josm.data.osm.RelationMember; 43 import org.openstreetmap.josm.data.osm.Way; 41 44 import org.openstreetmap.josm.gui.DefaultNameFormatter; 42 45 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; … … 44 47 import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor; 45 48 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 46 import org.openstreetmap.josm.gui.layer.DataChangeListener;47 49 import org.openstreetmap.josm.gui.layer.Layer; 48 50 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 59 61 * objects are visible on the map and can be selected there. Relations are not. 60 62 */ 61 public class RelationListDialog extends ToggleDialog implements LayerChangeListener, Data ChangeListener {63 public class RelationListDialog extends ToggleDialog implements LayerChangeListener, DataSetListener { 62 64 private static final Logger logger = Logger.getLogger(RelationListDialog.class.getName()); 63 65 … … 201 203 public void layerRemoved(Layer a) { 202 204 if (a instanceof OsmDataLayer) { 203 ((OsmDataLayer)a). listenerDataChanged.remove(this);205 ((OsmDataLayer)a).data.removeDataSetListener(this); 204 206 } 205 207 updateList(); … … 208 210 public void layerAdded(Layer a) { 209 211 if (a instanceof OsmDataLayer) { 210 ((OsmDataLayer)a).listenerDataChanged.add(this); 211 } 212 } 213 214 public void dataChanged(OsmDataLayer l) { 215 updateList(); 212 ((OsmDataLayer)a).data.addDataSetListener(this); 213 } 216 214 } 217 215 … … 677 675 } 678 676 } 677 678 public void nodeMoved(Node node) { } 679 680 public void wayNodesChanged(Way way) { } 681 682 public void primtivesAdded(Collection<? extends OsmPrimitive> added) { 683 updateList(); 684 } 685 686 public void primtivesRemoved(Collection<? extends OsmPrimitive> removed) { 687 updateList(); 688 } 689 690 public void relationMembersChanged(Relation r) { 691 updateList(); 692 } 693 694 public void tagsChanged(OsmPrimitive prim) { 695 updateList(); 696 } 679 697 }
Note:
See TracChangeset
for help on using the changeset viewer.