Changeset 5335 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-07-14T03:25:45+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/conflict/pair
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r5301 r5335 31 31 import org.openstreetmap.josm.data.osm.OsmPrimitive; 32 32 import org.openstreetmap.josm.data.osm.PrimitiveId; 33 import org.openstreetmap.josm.data.osm.RelationMember; 33 34 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 34 35 import org.openstreetmap.josm.gui.help.HelpUtil; … … 713 714 @Override 714 715 public OsmPrimitive getReferredPrimitive(int idx) { 715 return (OsmPrimitive) getValueAt(idx, 1); 716 Object value = getValueAt(idx, 1); 717 if (value instanceof OsmPrimitive) { 718 return (OsmPrimitive) value; 719 } else if (value instanceof RelationMember) { 720 return ((RelationMember)value).getMember(); 721 } else { 722 System.err.println("Unknown object type: "+value); 723 return null; 724 } 716 725 } 717 726 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r5298 r5335 18 18 import java.beans.PropertyChangeListener; 19 19 import java.util.ArrayList; 20 import java.util.Collection; 20 21 import java.util.HashMap; 22 import java.util.List; 21 23 import java.util.Observable; 22 24 import java.util.Observer; … … 36 38 import javax.swing.event.ListSelectionListener; 37 39 40 import org.openstreetmap.josm.Main; 41 import org.openstreetmap.josm.data.osm.OsmPrimitive; 38 42 import org.openstreetmap.josm.data.osm.PrimitiveId; 43 import org.openstreetmap.josm.data.osm.Relation; 44 import org.openstreetmap.josm.data.osm.Way; 45 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 39 46 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTable; 40 47 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 1024 1031 } 1025 1032 } 1033 1034 protected final <P extends OsmPrimitive> OsmDataLayer findLayerFor(P primitive) { 1035 if (primitive != null) { 1036 List<OsmDataLayer> layers = Main.map.mapView.getLayersOfType(OsmDataLayer.class); 1037 // Find layer with same dataset 1038 for (OsmDataLayer layer : layers) { 1039 if (layer.data == primitive.getDataSet()) { 1040 return layer; 1041 } 1042 } 1043 // Conflict after merging layers: a dataset could be no more in any layer, try to find another layer with same primitive 1044 for (OsmDataLayer layer : layers) { 1045 final Collection<? extends OsmPrimitive> collection; 1046 if (primitive instanceof Way) { 1047 collection = layer.data.getWays(); 1048 } else if (primitive instanceof Relation) { 1049 collection = layer.data.getRelations(); 1050 } else { 1051 collection = layer.data.allPrimitives(); 1052 } 1053 for (OsmPrimitive p : collection) { 1054 if (p.getPrimitiveId().equals(primitive.getPrimitiveId())) { 1055 return layer; 1056 } 1057 } 1058 } 1059 } 1060 return null; 1061 } 1026 1062 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java
r5301 r5335 2 2 package org.openstreetmap.josm.gui.conflict.pair.nodes; 3 3 4 import java.util.List;5 6 4 import javax.swing.JScrollPane; 7 5 8 import org.openstreetmap.josm.Main;9 6 import org.openstreetmap.josm.data.conflict.Conflict; 10 7 import org.openstreetmap.josm.data.osm.Node; … … 13 10 import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver; 14 11 import org.openstreetmap.josm.gui.conflict.pair.ListMerger; 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer;16 12 17 13 /** … … 65 61 } 66 62 67 protected OsmDataLayer findLayerFor(Way w) {68 List<OsmDataLayer> layers = Main.map.mapView.getLayersOfType(OsmDataLayer.class);69 // Find layer with same dataset70 for (OsmDataLayer layer : layers) {71 if (layer.data == w.getDataSet()) {72 return layer;73 }74 }75 // Conflict after merging layers: a dataset could be no more in any layer, try to find another layer with same primitive76 for (OsmDataLayer layer : layers) {77 for (Way way : layer.data.getWays()) {78 if (way.getPrimitiveId().equals(w.getPrimitiveId())) {79 return layer;80 }81 }82 }83 return null;84 }85 86 63 public void deletePrimitive(boolean deleted) { 87 64 if (deleted) { -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java
r5301 r5335 50 50 51 51 public void populate(Conflict<? extends OsmPrimitive> conflict) { 52 RelationMemberListMergeModel model = (RelationMemberListMergeModel)getModel(); 53 model.populate((Relation)conflict.getMy(), (Relation)conflict.getTheir(), conflict.getMergedMap()); 52 Relation myRel = (Relation)conflict.getMy(); 53 Relation theirRel = (Relation)conflict.getTheir(); 54 ((RelationMemberListMergeModel)model).populate(myRel, theirRel, conflict.getMergedMap()); 55 myEntriesTable.setLayer(findLayerFor(myRel)); 56 theirEntriesTable.setLayer(findLayerFor(theirRel)); 54 57 } 55 58
Note:
See TracChangeset
for help on using the changeset viewer.