Changeset 5298 in josm
- Timestamp:
- 2012-06-24T21:02:36+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java
r5266 r5298 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.conflict; 3 4 import java.util.Map; 3 5 4 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 22 24 private final T their; 23 25 private final boolean isMyDeleted; 26 27 // mergedMap is only set if the conflict results from merging two layers 28 private Map<PrimitiveId, PrimitiveId> mergedMap; 24 29 25 30 public Conflict(T my, T their) { … … 111 116 return isMyDeleted; 112 117 } 118 119 public final Map<PrimitiveId, PrimitiveId> getMergedMap() { 120 return mergedMap; 121 } 122 123 public final void setMergedMap(Map<PrimitiveId, PrimitiveId> mergedMap) { 124 this.mergedMap = mergedMap; 125 } 113 126 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r5266 r5298 134 134 return null; 135 135 return targetDataSet.getPrimitiveById(targetId); 136 } 137 138 protected void addConflict(Conflict<?> c) { 139 c.setMergedMap(mergedMap); 140 conflicts.add(c); 141 } 142 143 protected void addConflict(OsmPrimitive my, OsmPrimitive their) { 144 addConflict(new Conflict<OsmPrimitive>(my, their)); 136 145 } 137 146 … … 188 197 // add a conflict and don't delete the object 189 198 if (!objectsToDelete.contains(referrer)) { 190 conflicts.add(target, source);199 addConflict(target, source); 191 200 it.remove(); 192 201 flag = true; … … 235 244 newNodes.add(targetNode); 236 245 if (targetNode.isDeleted() && !conflicts.hasConflictForMy(targetNode)) { 237 conflicts.add(new Conflict<OsmPrimitive>(targetNode, sourceNode, true));246 addConflict(new Conflict<OsmPrimitive>(targetNode, sourceNode, true)); 238 247 targetNode.setDeleted(false); 239 248 } … … 263 272 newMembers.add(newMember); 264 273 if (targetMember.isDeleted() && !conflicts.hasConflictForMy(targetMember)) { 265 conflicts.add(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true));274 addConflict(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true)); 266 275 targetMember.setDeleted(false); 267 276 } … … 317 326 for (OsmPrimitive referrer: source.getReferrers()) { 318 327 if (targetDataSet.getPrimitiveById(referrer.getPrimitiveId()) == null) { 319 conflicts.add(new Conflict<OsmPrimitive>(target, source, true));328 addConflict(new Conflict<OsmPrimitive>(target, source, true)); 320 329 target.setDeleted(false); 321 330 break; … … 352 361 // this have to be resolved manually. 353 362 // 354 conflicts.add(target,source);363 addConflict(target,source); 355 364 } else if (! target.hasEqualSemanticAttributes(source)) { 356 365 // target is modified and is not semantically equal with source. Can't automatically 357 366 // resolve the differences 358 367 // => create a conflict 359 conflicts.add(target,source);368 addConflict(target,source); 360 369 } else { 361 370 // clone from other. mergeFrom will mainly copy -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r5297 r5298 15 15 import java.util.HashMap; 16 16 import java.util.List; 17 import java.util.Map; 17 18 import java.util.Observable; 18 19 … … 21 22 import javax.swing.DefaultListSelectionModel; 22 23 import javax.swing.JOptionPane; 24 import javax.swing.JTable; 25 import javax.swing.ListSelectionModel; 23 26 import javax.swing.table.DefaultTableModel; 24 27 import javax.swing.table.TableModel; 25 28 26 29 import org.openstreetmap.josm.Main; 30 import org.openstreetmap.josm.data.osm.DataSet; 27 31 import org.openstreetmap.josm.data.osm.OsmPrimitive; 28 32 import org.openstreetmap.josm.data.osm.PrimitiveId; … … 30 34 import org.openstreetmap.josm.gui.help.HelpUtil; 31 35 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; 36 import org.openstreetmap.josm.tools.CheckParameterUtil; 32 37 33 38 /** … … 63 68 * @see ListMerger 64 69 */ 65 public abstract class ListMergeModel<T > extends Observable {70 public abstract class ListMergeModel<T extends PrimitiveId> extends Observable { 66 71 public static final String FROZEN_PROP = ListMergeModel.class.getName() + ".frozen"; 67 72 … … 81 86 private boolean isFrozen = false; 82 87 private final ComparePairListModel comparePairListModel; 88 89 private DataSet myDataset; 90 private Map<PrimitiveId, PrimitiveId> mergedMap; 83 91 84 92 /** … … 118 126 * @return Primitive from my dataset referenced by entry 119 127 */ 120 protected abstract OsmPrimitive getMyPrimitive(T entry); 128 protected OsmPrimitive getMyPrimitive(T entry) { 129 return getMyPrimitiveDefault(entry); 130 } 131 132 protected final OsmPrimitive getMyPrimitiveDefault(PrimitiveId entry) { 133 OsmPrimitive result = myDataset.getPrimitiveById(entry); 134 if (result == null && mergedMap != null) { 135 PrimitiveId id = mergedMap.get(entry); 136 if (id == null && entry instanceof OsmPrimitive) { 137 id = mergedMap.get(((OsmPrimitive)entry).getPrimitiveId()); 138 } 139 if (id != null) { 140 result = myDataset.getPrimitiveById(id); 141 } 142 } 143 return result; 144 } 121 145 122 146 protected void buildMyEntriesTableModel() { … … 310 334 getMergedEntries().clear(); 311 335 fireModelDataChanged(); 336 } 337 338 protected final void initPopulate(OsmPrimitive my, OsmPrimitive their, Map<PrimitiveId, PrimitiveId> mergedMap) { 339 CheckParameterUtil.ensureParameterNotNull(my, "my"); 340 CheckParameterUtil.ensureParameterNotNull(their, "their"); 341 this.myDataset = my.getDataSet(); 342 this.mergedMap = mergedMap; 343 getMergedEntries().clear(); 344 getMyEntries().clear(); 345 getTheirEntries().clear(); 312 346 } 313 347 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r5297 r5298 36 36 import javax.swing.event.ListSelectionListener; 37 37 38 import org.openstreetmap.josm.data.osm.PrimitiveId; 38 39 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTable; 39 40 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 46 47 * @see ListMergeModel 47 48 */ 48 public abstract class ListMerger<T > extends JPanel implements PropertyChangeListener, Observer {49 public abstract class ListMerger<T extends PrimitiveId> extends JPanel implements PropertyChangeListener, Observer { 49 50 protected OsmPrimitivesTable myEntriesTable; 50 51 protected OsmPrimitivesTable mergedEntriesTable; -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java
r5266 r5298 5 5 6 6 import java.util.ArrayList; 7 import java.util.Map; 7 8 8 9 import javax.swing.table.DefaultTableModel; … … 10 11 import org.openstreetmap.josm.command.WayNodesConflictResolverCommand; 11 12 import org.openstreetmap.josm.data.conflict.Conflict; 12 import org.openstreetmap.josm.data.osm.DataSet;13 13 import org.openstreetmap.josm.data.osm.Node; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 import org.openstreetmap.josm.data.osm.PrimitiveId; 15 16 import org.openstreetmap.josm.data.osm.Way; 16 17 import org.openstreetmap.josm.gui.conflict.pair.ListMergeModel; 17 18 import org.openstreetmap.josm.gui.conflict.pair.ListRole; 18 import org.openstreetmap.josm.tools.CheckParameterUtil;19 19 20 20 public class NodeListMergeModel extends ListMergeModel<Node>{ 21 private DataSet myDataset;22 21 23 22 /** … … 27 26 * @param my my way (i.e. the way in the local dataset) 28 27 * @param their their way (i.e. the way in the server dataset) 28 * @param mergedMap The map of merged primitives if the conflict results from merging two layers 29 29 * @exception IllegalArgumentException thrown, if my is null 30 30 * @exception IllegalArgumentException thrown, if their is null 31 31 */ 32 public void populate(Way my, Way their ) {33 this.myDataset = my.getDataSet();32 public void populate(Way my, Way their, Map<PrimitiveId, PrimitiveId> mergedMap) { 33 initPopulate(my, their, mergedMap); 34 34 35 CheckParameterUtil.ensureParameterNotNull(my, "my");36 CheckParameterUtil.ensureParameterNotNull(their, "their");37 getMergedEntries().clear();38 getMyEntries().clear();39 getTheirEntries().clear();40 35 for (Node n : my.getNodes()) { 41 36 getMyEntries().add(n); … … 85 80 return (Node) getMyPrimitive(entry); 86 81 } 87 88 @Override89 protected OsmPrimitive getMyPrimitive(Node entry) {90 return myDataset.getPrimitiveById(entry);91 }92 93 82 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java
r5297 r5298 57 57 Way myWay = (Way)conflict.getMy(); 58 58 Way theirWay = (Way)conflict.getTheir(); 59 ((NodeListMergeModel)model).populate(myWay, theirWay );59 ((NodeListMergeModel)model).populate(myWay, theirWay, conflict.getMergedMap()); 60 60 myEntriesTable.setLayer(findLayerFor(myWay)); 61 61 theirEntriesTable.setLayer(findLayerFor(theirWay)); -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java
r4191 r5298 5 5 6 6 import java.util.List; 7 import java.util.Map; 7 8 8 9 import javax.swing.table.DefaultTableModel; 9 10 10 11 import org.openstreetmap.josm.command.RelationMemberConflictResolverCommand; 11 import org.openstreetmap.josm.data.osm.DataSet;12 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 import org.openstreetmap.josm.data.osm.PrimitiveId; 13 14 import org.openstreetmap.josm.data.osm.Relation; 14 15 import org.openstreetmap.josm.data.osm.RelationMember; … … 21 22 */ 22 23 public class RelationMemberListMergeModel extends ListMergeModel<RelationMember>{ 23 private DataSet myDataset;24 24 25 25 @Override … … 60 60 * @param my my relation. Must not be null. 61 61 * @param their their relation. Must not be null. 62 * @param mergedMap The map of merged primitives if the conflict results from merging two layers 62 63 * 63 64 * @throws IllegalArgumentException if my is null 64 65 * @throws IllegalArgumentException if their is null 65 66 */ 66 public void populate(Relation my, Relation their) { 67 this.myDataset = my.getDataSet(); 68 69 CheckParameterUtil.ensureParameterNotNull(my, "my"); 70 CheckParameterUtil.ensureParameterNotNull(their, "their"); 71 72 getMergedEntries().clear(); 73 getMyEntries().clear(); 74 getTheirEntries().clear(); 67 public void populate(Relation my, Relation their, Map<PrimitiveId, PrimitiveId> mergedMap) { 68 initPopulate(my, their, mergedMap); 75 69 76 70 for (RelationMember n : my.getMembers()) { … … 94 88 @Override 95 89 protected RelationMember cloneEntryForMergedList(RelationMember entry) { 96 OsmPrimitive primitive = getMyPrimitive(entry); 97 return new RelationMember(entry.getRole(), primitive); 90 return new RelationMember(entry.getRole(), getMyPrimitive(entry)); 98 91 } 99 92 100 93 @Override 101 94 protected OsmPrimitive getMyPrimitive(RelationMember entry) { 102 return myDataset.getPrimitiveById(entry.getMember());95 return getMyPrimitiveDefault(entry.getMember()); 103 96 } 104 97 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java
r5297 r5298 48 48 public void populate(Conflict<? extends OsmPrimitive> conflict) { 49 49 RelationMemberListMergeModel model = (RelationMemberListMergeModel)getModel(); 50 model.populate((Relation)conflict.getMy(), (Relation)conflict.getTheir() );50 model.populate((Relation)conflict.getMy(), (Relation)conflict.getTheir(), conflict.getMergedMap()); 51 51 } 52 52 -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r5297 r5298 705 705 @Override 706 706 public void updateEnabledState() { 707 GuiHelper.runInEDT (new Runnable() {707 GuiHelper.runInEDTAndWait(new Runnable() { 708 708 @Override 709 709 public void run() {
Note:
See TracChangeset
for help on using the changeset viewer.