Changeset 304 in josm for src/org/openstreetmap/josm/command
- Timestamp:
- 2007-08-10T21:12:53+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm/command
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/command/AddCommand.java
r301 r304 16 16 import org.openstreetmap.josm.data.osm.visitor.DeleteVisitor; 17 17 import org.openstreetmap.josm.data.osm.visitor.NameVisitor; 18 import org.openstreetmap.josm.gui.layer.Layer; 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 20 19 21 /** … … 37 39 public AddCommand(OsmPrimitive osm) { 38 40 this.osm = osm; 39 this.ds = Main. ds;41 this.ds = Main.main.editLayer().data; 40 42 } 41 43 … … 52 54 } 53 55 56 // faster implementation 57 @Override public boolean invalidBecauselayerRemoved(Layer oldLayer) { 58 return oldLayer instanceof OsmDataLayer && ((OsmDataLayer)oldLayer).data == ds; 59 } 60 54 61 @Override public MutableTreeNode description() { 55 62 NameVisitor v = new NameVisitor(); -
src/org/openstreetmap/josm/command/Command.java
r298 r304 1 // 1 //License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.command; 3 3 … … 15 15 import org.openstreetmap.josm.data.osm.Way; 16 16 import org.openstreetmap.josm.data.osm.visitor.Visitor; 17 import org.openstreetmap.josm.gui.layer.Layer; 18 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 19 18 20 … … 31 33 private static final class CloneVisitor implements Visitor { 32 34 public Map<OsmPrimitive, OsmPrimitive> orig = new HashMap<OsmPrimitive, OsmPrimitive>(); 33 35 34 36 public void visit(Node n) { 35 37 orig.put(n, new Node(n)); 36 38 } 37 39 public void visit(Segment s) { 38 40 orig.put(s, new Segment(s)); 39 41 } 40 42 public void visit(Way w) { 41 43 orig.put(w, new Way(w)); 42 44 } 43 45 } 44 46 45 47 private CloneVisitor orig; 46 48 47 49 /** 48 50 * Executes the command on the dataset. This implementation will remember all … … 69 71 } 70 72 73 74 /** 75 * Called, when a layer has been removed to have the command remove itself from 76 * any buffer if it is not longer applicable to the dataset (e.g. it was part of 77 * the removed layer) 78 */ 79 public boolean invalidBecauselayerRemoved(Layer oldLayer) { 80 if (!(oldLayer instanceof OsmDataLayer)) 81 return false; 82 HashSet<OsmPrimitive> modified = new HashSet<OsmPrimitive>(); 83 fillModifiedData(modified, modified, modified); 84 if (modified.isEmpty()) 85 return false; 86 87 HashSet<OsmPrimitive> all = new HashSet<OsmPrimitive>(((OsmDataLayer)oldLayer).data.allPrimitives()); 88 for (OsmPrimitive osm : all) 89 if (all.contains(osm)) 90 return true; 91 92 return false; 93 } 94 71 95 /** 72 96 * Fill in the changed data this command operates on.
Note:
See TracChangeset
for help on using the changeset viewer.