- Timestamp:
- 2010-02-23T08:58:12+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/Command.java
r2932 r3034 2 2 package org.openstreetmap.josm.command; 3 3 4 import java.util.ArrayList; 4 5 import java.util.Collection; 5 6 import java.util.HashMap; 6 import java.util. HashSet;7 import java.util.LinkedHashMap; 7 8 import java.util.Map; 8 9 import java.util.Map.Entry; … … 32 33 33 34 private static final class CloneVisitor extends AbstractVisitor { 34 public Map<OsmPrimitive, PrimitiveData> orig = new HashMap<OsmPrimitive, PrimitiveData>(); 35 public final Map<OsmPrimitive, PrimitiveData> orig = new LinkedHashMap<OsmPrimitive, PrimitiveData>(); 35 36 36 37 public void visit(Node n) { … … 72 73 public boolean executeCommand() { 73 74 CloneVisitor visitor = new CloneVisitor(); 74 Collection<OsmPrimitive> all = new HashSet<OsmPrimitive>();75 Collection<OsmPrimitive> all = new ArrayList<OsmPrimitive>(); 75 76 fillModifiedData(all, all, all); 76 77 for (OsmPrimitive osm : all) { -
trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java
r2512 r3034 23 23 24 24 /** the conflict to resolve */ 25 private Conflict< Node> conflict;25 private Conflict<? extends OsmPrimitive> conflict; 26 26 27 27 /** the merge decision */ … … 35 35 * @param decision the merge decision 36 36 */ 37 public CoordinateConflictResolveCommand( Node my, Node their, MergeDecisionType decision) {38 this.conflict = new Conflict<Node>(my,their);37 public CoordinateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) { 38 this.conflict = conflict; 39 39 this.decision = decision; 40 40 } … … 61 61 // do nothing 62 62 } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) { 63 Node my = conflict.getMy(); 64 Node their = conflict.getTheir(); 63 Node my = (Node)conflict.getMy(); 64 Node their = (Node)conflict.getTheir(); 65 65 my.setCoor(their.getCoor()); 66 66 } else -
trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java
r2945 r3034 23 23 24 24 /** the conflict to resolve */ 25 private Conflict<OsmPrimitive> conflict; 25 private Conflict<? extends OsmPrimitive> conflict; 26 26 27 27 /** the merge decision */ … … 35 35 * @param decision the merge decision 36 36 */ 37 public DeletedStateConflictResolveCommand( OsmPrimitive my,OsmPrimitivetheir, MergeDecisionType decision) {38 this.conflict = new Conflict<OsmPrimitive>(my, their);37 public DeletedStateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) { 38 this.conflict = conflict; 39 39 this.decision = decision; 40 40 } … … 61 61 62 62 if (decision.equals(MergeDecisionType.KEEP_MINE)) { 63 if (conflict.getMy().isDeleted()) { 63 if (conflict.getMy().isDeleted() || conflict.isMyDeleted()) { 64 64 // because my was involved in a conflict it my still be referred 65 65 // to from a way or a relation. Fix this now. 66 66 // 67 67 layer.data.unlinkReferencesToPrimitive(conflict.getMy()); 68 conflict.getMy().setDeleted(true); 68 69 } 69 70 } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) { … … 86 87 Collection<OsmPrimitive> added) { 87 88 modified.add(conflict.getMy()); 89 modified.addAll(conflict.getMy().getReferrers()); 88 90 } 89 91 } -
trunk/src/org/openstreetmap/josm/command/ModifiedConflictResolveCommand.java
r2844 r3034 24 24 25 25 /** the conflict to resolve */ 26 private Conflict<OsmPrimitive> conflict; 26 private Conflict<? extends OsmPrimitive> conflict; 27 27 28 28 /** … … 31 31 * @param their their primitive (i.e. the primitive from the server) 32 32 */ 33 public ModifiedConflictResolveCommand( OsmPrimitive my,OsmPrimitivetheir) {34 conflict = new Conflict<OsmPrimitive>(my, their);33 public ModifiedConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) { 34 this.conflict = conflict; 35 35 } 36 36 -
trunk/src/org/openstreetmap/josm/command/TagConflictResolveCommand.java
r2990 r3034 29 29 30 30 /** the conflict to resolve */ 31 private Conflict<OsmPrimitive> conflict; 31 private Conflict<? extends OsmPrimitive> conflict; 32 32 33 33 /** the list of merge decisions, represented as {@see TagMergeItem}s */ … … 56 56 * @param mergeItems the list of merge decisions, represented as {@see TagMergeItem}s 57 57 */ 58 public TagConflictResolveCommand( OsmPrimitive my,OsmPrimitivetheir, List<TagMergeItem> mergeItems) {59 this.conflict = new Conflict<OsmPrimitive>(my,their);58 public TagConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, List<TagMergeItem> mergeItems) { 59 this.conflict = conflict; 60 60 this.mergeItems = mergeItems; 61 61 } -
trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java
r2844 r3034 24 24 25 25 /** the conflict to resolve */ 26 private Conflict<OsmPrimitive> conflict; 26 private Conflict<? extends OsmPrimitive> conflict; 27 27 28 28 /** … … 31 31 * @param their their primitive (i.e. the primitive from the server) 32 32 */ 33 public VersionConflictResolveCommand( OsmPrimitive my,OsmPrimitivetheir) {34 conflict = new Conflict<OsmPrimitive>(my, their);33 public VersionConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) { 34 this.conflict = conflict; 35 35 } 36 36 … … 39 39 String msg = ""; 40 40 switch(OsmPrimitiveType.from(conflict.getMy())) { 41 42 43 41 case NODE: msg = marktr("Resolve version conflict for node {0}"); break; 42 case WAY: msg = marktr("Resolve version conflict for way {0}"); break; 43 case RELATION: msg = marktr("Resolve version conflict for relation {0}"); break; 44 44 } 45 45 return new DefaultMutableTreeNode( -
trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java
r2512 r3034 41 41 * @param mergedNodeList the list of merged nodes 42 42 */ 43 public WayNodesConflictResolverCommand(Way my, Way their, List<Node> mergedNodeList) { 44 conflict = new Conflict<Way>(my,their); 43 @SuppressWarnings("unchecked") 44 public WayNodesConflictResolverCommand(Conflict<? extends OsmPrimitive> conflict, List<Node> mergedNodeList) { 45 this.conflict = (Conflict<Way>) conflict; 45 46 this.mergedNodeList = mergedNodeList; 46 47 } -
trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java
r2979 r3034 21 21 private final T my; 22 22 private final T their; 23 private final boolean isMyDeleted; 23 24 24 25 public Conflict(T my, T their) { 26 this(my, their, false); 27 } 28 29 public Conflict(T my, T their, boolean isMyDeleted) { 25 30 this.my = my; 26 31 this.their = their; 32 this.isMyDeleted = isMyDeleted; 27 33 } 28 34 … … 96 102 return true; 97 103 } 104 105 /** 106 * 107 * @return True if my primitive was deleted but it has set non deleted status because it's referred by another 108 * primitive and references to deleted primitives are not allowed. 109 */ 110 public boolean isMyDeleted() { 111 return isMyDeleted; 112 } 98 113 } -
trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
r2949 r3034 33 33 * </ul> 34 34 */ 35 public class ConflictCollection implements Iterable<Conflict<?>>{ 36 private final List<Conflict<?>> conflicts; 35 public class ConflictCollection implements Iterable<Conflict<? extends OsmPrimitive>>{ 36 private final List<Conflict<? extends OsmPrimitive>> conflicts; 37 37 private CopyOnWriteArrayList<IConflictListener> listeners; 38 38 -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r3033 r3034 13 13 import java.util.logging.Logger; 14 14 15 import org.openstreetmap.josm.data.conflict.Conflict; 15 16 import org.openstreetmap.josm.data.conflict.ConflictCollection; 16 17 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 160 161 * @param other 161 162 */ 163 //TODO This method is probably useless 162 164 protected void fixIncompleteParentWays(Node other) { 163 165 Node myNode = (Node)getMergeTarget(other); … … 224 226 newNodes.add(targetNode); 225 227 if (targetNode.isDeleted() && !conflicts.hasConflictForMy(targetNode)) { 226 conflicts.add(targetNode, sourceNode); 228 conflicts.add(new Conflict<OsmPrimitive>(targetNode, sourceNode, true)); 229 targetNode.setDeleted(false); 227 230 } 228 231 } else { … … 255 258 newMembers.add(newMember); 256 259 if (targetMember.isDeleted() && !conflicts.hasConflictForMy(targetMember)) { 257 conflicts.add(targetMember, sourceMember.getMember()); 260 conflicts.add(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true)); 261 targetMember.setDeleted(false); 258 262 } 259 263 } else { … … 319 323 for (OsmPrimitive referrer: source.getReferrers()) { 320 324 if (targetDataSet.getPrimitiveById(referrer.getPrimitiveId()) == null) { 321 conflicts.add(target, source); 325 conflicts.add(new Conflict<OsmPrimitive>(target, source, true)); 326 target.setDeleted(false); 322 327 break; 323 328 } -
trunk/src/org/openstreetmap/josm/data/osm/User.java
r2863 r3034 27 27 28 28 private static long getNextLocalUid() { 29 synchronized(User.class) { 30 return uidCounter.decrementAndGet(); 31 } 29 return uidCounter.decrementAndGet(); 32 30 } 33 31 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java
r2945 r3034 19 19 import org.openstreetmap.josm.command.SequenceCommand; 20 20 import org.openstreetmap.josm.command.VersionConflictResolveCommand; 21 import org.openstreetmap.josm.data.conflict.Conflict; 21 22 import org.openstreetmap.josm.data.osm.Node; 22 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 77 78 private OsmPrimitive my; 78 79 private OsmPrimitive their; 80 private Conflict<? extends OsmPrimitive> conflict; 79 81 80 82 private ImageIcon mergeComplete; … … 228 230 * 229 231 */ 230 public void populate(OsmPrimitive my, OsmPrimitive their) { 231 setMy(my); 232 setTheir(their); 233 propertiesMerger.populate(my, their); 232 public void populate(Conflict<? extends OsmPrimitive> conflict) { 233 setMy(conflict.getMy()); 234 setTheir(conflict.getTheir()); 235 this.conflict = conflict; 236 propertiesMerger.populate(conflict); 234 237 if (propertiesMerger.getModel().hasVisibleStateConflict()) { 235 238 tabbedPane.setEnabledAt(1, false); … … 239 242 } 240 243 tabbedPane.setEnabledAt(0, true); 241 tagMerger.populate( my, their);244 tagMerger.populate(conflict); 242 245 tabbedPane.setEnabledAt(1, true); 243 246 … … 246 249 tabbedPane.setEnabledAt(3,false); 247 250 } else if (my instanceof Way) { 248 nodeListMerger.populate( my, their);251 nodeListMerger.populate(conflict); 249 252 tabbedPane.setEnabledAt(2, true); 250 253 tabbedPane.setEnabledAt(3, false); … … 252 255 tabbedPane.setIconAt(3, null); 253 256 } else if (my instanceof Relation) { 254 relationMemberMerger.populate( my, their);257 relationMemberMerger.populate(conflict); 255 258 tabbedPane.setEnabledAt(2, false); 256 259 tabbedPane.setTitleAt(2,tr("Nodes")); … … 271 274 if (propertiesMerger.getModel().hasVisibleStateConflict()) { 272 275 if (propertiesMerger.getModel().isDecidedVisibleState()) { 273 commands.addAll(propertiesMerger.getModel().buildResolveCommand( my, their));276 commands.addAll(propertiesMerger.getModel().buildResolveCommand(conflict)); 274 277 } 275 278 } else { 276 279 if (tagMerger.getModel().getNumResolvedConflicts() > 0) { 277 commands.add(tagMerger.getModel().buildResolveCommand( my, their));278 } 279 commands.addAll(propertiesMerger.getModel().buildResolveCommand( my, their));280 commands.add(tagMerger.getModel().buildResolveCommand(conflict)); 281 } 282 commands.addAll(propertiesMerger.getModel().buildResolveCommand(conflict)); 280 283 if (my instanceof Way && nodeListMerger.getModel().isFrozen()) { 281 284 NodeListMergeModel model =(NodeListMergeModel)nodeListMerger.getModel(); 282 commands.add(model.buildResolveCommand( (Way)my, (Way)their));285 commands.add(model.buildResolveCommand(conflict)); 283 286 } else if (my instanceof Relation && relationMemberMerger.getModel().isFrozen()) { 284 287 RelationMemberListMergeModel model =(RelationMemberListMergeModel)relationMemberMerger.getModel(); … … 286 289 } 287 290 if (isResolvedCompletely()) { 288 commands.add(new VersionConflictResolveCommand( my, their));289 commands.add(new ModifiedConflictResolveCommand( my, their));291 commands.add(new VersionConflictResolveCommand(conflict)); 292 commands.add(new ModifiedConflictResolveCommand(conflict)); 290 293 } 291 294 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/IConflictResolver.java
r2945 r3034 2 2 package org.openstreetmap.josm.gui.conflict.pair; 3 3 4 import org.openstreetmap.josm.data.conflict.Conflict; 4 5 import org.openstreetmap.josm.data.osm.OsmPrimitive; 5 6 … … 7 8 8 9 void deletePrimitive(boolean deleted); 9 void populate( OsmPrimitive my,OsmPrimitivetheir);10 void populate(Conflict<? extends OsmPrimitive> conflict); 10 11 11 12 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java
r2949 r3034 9 9 10 10 import org.openstreetmap.josm.command.WayNodesConflictResolverCommand; 11 import org.openstreetmap.josm.data.conflict.Conflict; 11 12 import org.openstreetmap.josm.data.osm.DataSet; 12 13 import org.openstreetmap.josm.data.osm.Node; … … 61 62 * @param their their way. Must not be null 62 63 * @return the command 63 * @exception IllegalArgumentException thrown, if my is null or not a {@see Way}64 * @exception IllegalArgumentException thrown, if their is null or not a {@see Way}65 64 * @exception IllegalStateException thrown, if the merge is not yet frozen 66 65 */ 67 public WayNodesConflictResolverCommand buildResolveCommand(Way my, Way their) { 68 CheckParameterUtil.ensureParameterNotNull(my, "my"); 69 CheckParameterUtil.ensureParameterNotNull(their, "their"); 66 public WayNodesConflictResolverCommand buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) { 70 67 if (! isFrozen()) 71 68 throw new IllegalArgumentException(tr("Merged nodes not frozen yet. Cannot build resolution command.")); 72 return new WayNodesConflictResolverCommand( my, their, getMergedEntries());69 return new WayNodesConflictResolverCommand(conflict, getMergedEntries()); 73 70 } 74 71 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java
r2945 r3034 4 4 import javax.swing.JTable; 5 5 6 import org.openstreetmap.josm.data.conflict.Conflict; 6 7 import org.openstreetmap.josm.data.osm.Node; 7 8 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 63 64 } 64 65 65 public void populate( OsmPrimitive my,OsmPrimitivetheir) {66 ((NodeListMergeModel)model).populate((Way) my, (Way)their);66 public void populate(Conflict<? extends OsmPrimitive> conflict) { 67 ((NodeListMergeModel)model).populate((Way)conflict.getMy(), (Way)conflict.getTheir()); 67 68 } 68 69 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java
r2940 r3034 21 21 import org.openstreetmap.josm.command.PurgePrimitivesCommand; 22 22 import org.openstreetmap.josm.command.UndeletePrimitivesCommand; 23 import org.openstreetmap.josm.data.conflict.Conflict; 23 24 import org.openstreetmap.josm.data.coor.LatLon; 24 25 import org.openstreetmap.josm.data.osm.DataSet; … … 161 162 * @param their their version of the primitive 162 163 */ 163 public void populate(OsmPrimitive my, OsmPrimitive their) { 164 this.my = my; 164 public void populate(Conflict<? extends OsmPrimitive> conflict) { 165 this.my = conflict.getMy(); 166 OsmPrimitive their = conflict.getTheir(); 165 167 if (my instanceof Node) { 166 168 myCoords = ((Node)my).getCoor(); … … 171 173 } 172 174 173 myDeletedState = my.isDeleted(); 175 myDeletedState = conflict.isMyDeleted() || my.isDeleted(); 174 176 theirDeletedState = their.isDeleted(); 175 177 … … 418 420 * @return the list of commands 419 421 */ 420 public List<Command> buildResolveCommand(OsmPrimitive my, OsmPrimitive their) throws OperationCancelledException{ 421 ArrayList<Command> cmds = new ArrayList<Command>(); 422 public List<Command> buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) throws OperationCancelledException{ 423 OsmPrimitive my = conflict.getMy(); 424 List<Command> cmds = new ArrayList<Command>(); 422 425 if (hasVisibleStateConflict() && isDecidedVisibleState()) { 423 426 if (isVisibleStateDecision(MergeDecisionType.KEEP_MINE)) { … … 436 439 } 437 440 if (hasCoordConflict() && isDecidedCoord()) { 438 cmds.add(new CoordinateConflictResolveCommand( (Node)my, (Node)their, coordMergeDecision));441 cmds.add(new CoordinateConflictResolveCommand(conflict, coordMergeDecision)); 439 442 } 440 443 if (hasDeletedStateConflict() && isDecidedDeletedState()) { 441 cmds.add(new DeletedStateConflictResolveCommand( my, their, deletedMergeDecision));444 cmds.add(new DeletedStateConflictResolveCommand(conflict, deletedMergeDecision)); 442 445 } 443 446 return cmds; -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java
r2945 r3034 22 22 import javax.swing.JPanel; 23 23 24 import org.openstreetmap.josm.data.conflict.Conflict; 24 25 import org.openstreetmap.josm.data.coor.LatLon; 25 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 718 719 } 719 720 720 public void populate( OsmPrimitive my,OsmPrimitivetheir) {721 model.populate( my, their);721 public void populate(Conflict<? extends OsmPrimitive> conflict) { 722 model.populate(conflict); 722 723 } 723 724 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java
r2945 r3034 5 5 import javax.swing.JTable; 6 6 7 import org.openstreetmap.josm.data.conflict.Conflict; 7 8 import org.openstreetmap.josm.data.osm.OsmPrimitive; 8 9 import org.openstreetmap.josm.data.osm.Relation; … … 54 55 } 55 56 56 public void populate( OsmPrimitive my,OsmPrimitivetheir) {57 public void populate(Conflict<? extends OsmPrimitive> conflict) { 57 58 RelationMemberListMergeModel model = (RelationMemberListMergeModel)getModel(); 58 model.populate((Relation) my, (Relation)their);59 model.populate((Relation)conflict.getMy(), (Relation)conflict.getTheir()); 59 60 } 60 61 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModel.java
r2945 r3034 12 12 13 13 import org.openstreetmap.josm.command.TagConflictResolveCommand; 14 import org.openstreetmap.josm.data.conflict.Conflict; 14 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 16 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; … … 189 190 } 190 191 191 public TagConflictResolveCommand buildResolveCommand( OsmPrimitive my,OsmPrimitivetheir) {192 return new TagConflictResolveCommand( my, their, tagMergeItems);192 public TagConflictResolveCommand buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) { 193 return new TagConflictResolveCommand(conflict, tagMergeItems); 193 194 } 194 195 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java
r2945 r3034 26 26 import javax.swing.event.ListSelectionListener; 27 27 28 import org.openstreetmap.josm.data.conflict.Conflict; 28 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 29 30 import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver; … … 421 422 } 422 423 423 public void populate( OsmPrimitive my,OsmPrimitivetheir) {424 model.populate( my, their);424 public void populate(Conflict<? extends OsmPrimitive> conflict) { 425 model.populate(conflict.getMy(), conflict.getTheir()); 425 426 mineTable.getSelectionModel().setSelectionInterval(0, 0); 426 427 theirTable.getSelectionModel().setSelectionInterval(0, 0); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r2945 r3034 144 144 } 145 145 146 Conflict<?> c = conflicts.get(index); 147 OsmPrimitive my = c.getMy(); 148 OsmPrimitive their = c.getTheir(); 146 Conflict<? extends OsmPrimitive> c = conflicts.get(index); 149 147 ConflictResolutionDialog dialog = new ConflictResolutionDialog(Main.parent); 150 dialog.getConflictResolver().populate( my, their);148 dialog.getConflictResolver().populate(c); 151 149 dialog.setVisible(true); 152 150
Note:
See TracChangeset
for help on using the changeset viewer.