Changeset 6886 in josm
- Timestamp:
- 2014-02-26T23:33:44+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java
r6881 r6886 5 5 6 6 import java.util.Collection; 7 import java.util.Set; 7 8 8 9 import javax.swing.Icon; … … 11 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 13 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer;14 14 import org.openstreetmap.josm.tools.ImageProvider; 15 15 16 16 /** 17 17 * Represents the resolution of a conflict between the deleted flag of two {@link OsmPrimitive}s. 18 * 18 * @since 1654 19 19 */ 20 20 public class DeletedStateConflictResolveCommand extends ConflictResolveCommand { … … 27 27 28 28 /** 29 * constructor29 * Constructs a new {@code DeletedStateConflictResolveCommand}. 30 30 * 31 31 * @param conflict the conflict data set … … 49 49 @Override 50 50 public boolean executeCommand() { 51 // remember the current state of modified primitives, i.e. of 52 // OSM primitive 'my' 53 // 51 // remember the current state of modified primitives, i.e. of OSM primitive 'my' 54 52 super.executeCommand(); 55 56 OsmDataLayer layer = getLayer();57 53 58 54 if (decision.equals(MergeDecisionType.KEEP_MINE)) { … … 60 56 // because my was involved in a conflict it my still be referred 61 57 // to from a way or a relation. Fix this now. 62 // 63 layer.data.unlinkReferencesToPrimitive(conflict.getMy()); 64 conflict.getMy().setDeleted(true); 58 deleteMy(); 65 59 } 66 60 } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) { 67 61 if (conflict.getTheir().isDeleted()) { 68 layer.data.unlinkReferencesToPrimitive(conflict.getMy()); 69 conflict.getMy().setDeleted(true); 62 deleteMy(); 70 63 } else { 71 64 conflict.getMy().setDeleted(false); … … 78 71 return true; 79 72 } 73 74 private void deleteMy() { 75 Set<OsmPrimitive> referrers = getLayer().data.unlinkReferencesToPrimitive(conflict.getMy()); 76 for (OsmPrimitive p : referrers) { 77 if (!p.isNew() && !p.isDeleted()) { 78 p.setModified(true); 79 } 80 } 81 conflict.getMy().setDeleted(true); 82 } 80 83 81 84 @Override -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r6830 r6886 10 10 import java.util.Collections; 11 11 import java.util.HashMap; 12 import java.util.HashSet; 12 13 import java.util.Iterator; 13 14 import java.util.LinkedHashSet; … … 814 815 815 816 /** 816 * removes all references from ways in this dataset to a particular node817 * Removes all references from ways in this dataset to a particular node. 817 818 * 818 819 * @param node the node 819 */ 820 public void unlinkNodeFromWays(Node node) { 820 * @return The set of ways that have been modified 821 */ 822 public Set<Way> unlinkNodeFromWays(Node node) { 823 Set<Way> result = new HashSet<Way>(); 821 824 beginUpdate(); 822 825 try { … … 829 832 way.setNodes(wayNodes); 830 833 } 834 result.add(way); 831 835 } 832 836 } … … 834 838 endUpdate(); 835 839 } 840 return result; 836 841 } 837 842 … … 840 845 * 841 846 * @param primitive the primitive 842 */ 843 public void unlinkPrimitiveFromRelations(OsmPrimitive primitive) { 847 * @return The set of relations that have been modified 848 */ 849 public Set<Relation> unlinkPrimitiveFromRelations(OsmPrimitive primitive) { 850 Set<Relation> result = new HashSet<Relation>(); 844 851 beginUpdate(); 845 852 try { … … 859 866 if (removed) { 860 867 relation.setMembers(members); 868 result.add(relation); 861 869 } 862 870 } … … 864 872 endUpdate(); 865 873 } 866 }867 868 /** 869 * removes all references from other primitives to the870 * referenced primitive874 return result; 875 } 876 877 /** 878 * Removes all references from other primitives to the referenced primitive. 871 879 * 872 880 * @param referencedPrimitive the referenced primitive 873 */ 874 public void unlinkReferencesToPrimitive(OsmPrimitive referencedPrimitive) { 881 * @return The set of primitives that have been modified 882 */ 883 public Set<OsmPrimitive> unlinkReferencesToPrimitive(OsmPrimitive referencedPrimitive) { 884 Set<OsmPrimitive> result = new HashSet<OsmPrimitive>(); 875 885 beginUpdate(); 876 886 try { 877 887 if (referencedPrimitive instanceof Node) { 878 unlinkNodeFromWays((Node)referencedPrimitive); 879 unlinkPrimitiveFromRelations(referencedPrimitive); 880 } else { 881 unlinkPrimitiveFromRelations(referencedPrimitive); 882 } 888 result.addAll(unlinkNodeFromWays((Node)referencedPrimitive)); 889 } 890 result.addAll(unlinkPrimitiveFromRelations(referencedPrimitive)); 883 891 } finally { 884 892 endUpdate(); 885 893 } 894 return result; 886 895 } 887 896
Note:
See TracChangeset
for help on using the changeset viewer.