Changeset 4357 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-08-27T20:01:19+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r4310 r4357 10 10 import java.util.ArrayList; 11 11 import java.util.Collection; 12 import java.util.Collections; 12 13 import java.util.List; 13 14 import java.util.Map.Entry; … … 22 23 23 24 import org.openstreetmap.josm.Main; 25 import org.openstreetmap.josm.data.conflict.Conflict; 26 import org.openstreetmap.josm.data.conflict.ConflictCollection; 24 27 import org.openstreetmap.josm.data.osm.DataSet; 25 28 import org.openstreetmap.josm.data.osm.Node; 26 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 30 import org.openstreetmap.josm.data.osm.OsmPrimitiveComparator; 27 31 import org.openstreetmap.josm.data.osm.Relation; 28 32 import org.openstreetmap.josm.data.osm.RelationMember; 29 33 import org.openstreetmap.josm.data.osm.User; 30 34 import org.openstreetmap.josm.data.osm.Way; 35 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 31 36 import org.openstreetmap.josm.gui.DefaultNameFormatter; 32 37 import org.openstreetmap.josm.gui.ExtendedDialog; 33 38 import org.openstreetmap.josm.gui.NavigatableComponent; 39 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 34 40 import org.openstreetmap.josm.gui.mappaint.Cascade; 35 41 import org.openstreetmap.josm.gui.mappaint.ElemStyle; … … 53 59 * Might be useful for power users to give more detailed bug reports and 54 60 * to better understand the JOSM data representation. 55 *56 * TODO: show conflicts57 61 */ 58 62 public class InspectPrimitiveDialog extends ExtendedDialog { 59 protected Collection<OsmPrimitive> primitives; 63 protected List<OsmPrimitive> primitives; 64 protected OsmDataLayer layer; 60 65 private JTextArea txtData; 61 66 private JTextArea txtMappaint; 62 67 boolean mappaintTabLoaded; 63 68 64 public InspectPrimitiveDialog(Collection<OsmPrimitive> primitives ) {69 public InspectPrimitiveDialog(Collection<OsmPrimitive> primitives, OsmDataLayer layer) { 65 70 super(Main.parent, tr("Advanced object info"), new String[] {tr("Close")}); 66 this.primitives = primitives; 71 this.primitives = new ArrayList<OsmPrimitive>(primitives); 72 this.layer = layer; 67 73 setRememberWindowGeometry(getClass().getName() + ".geometry", 68 74 WindowGeometry.centerInWindow(Main.parent, new Dimension(750, 550))); … … 103 109 protected String buildDataText() { 104 110 StringBuilder s = new StringBuilder(); 105 for (Node n : new SubclassFilteredCollection<OsmPrimitive, Node>(primitives, OsmPrimitive.nodePredicate)) { 111 112 Collections.sort(primitives, new OsmPrimitiveComparator()); 113 114 String sep = ""; 115 for (OsmPrimitive o : primitives) { 116 s.append(sep); 117 sep = "\n"; 118 addInfo(s, o); 119 } 120 121 return s.toString(); 122 } 123 124 protected void addInfo(StringBuilder s, OsmPrimitive o) { 125 o.visit(new AddPrimitiveInfoVisitor(s)); 126 addConflicts(s, o); 127 } 128 129 protected void addConflicts(StringBuilder s, OsmPrimitive o) { 130 ConflictCollection conflicts = layer.getConflicts(); 131 Conflict<?> c = conflicts.getConflictForMy(o); 132 if (c != null) { 133 s.append(tr("In conflict with:\n")); 134 c.getTheir().visit(new AddPrimitiveInfoVisitor(s)); 135 } 136 } 137 138 protected class AddPrimitiveInfoVisitor extends AbstractVisitor { 139 StringBuilder s; 140 141 public AddPrimitiveInfoVisitor(StringBuilder s) { 142 this.s = s; 143 } 144 145 public void visit(Node n) { 106 146 s.append(tr("Node id={0}", n.getUniqueId())); 107 147 if (!checkDataSet(n)) { 108 148 s.append(tr(" not in data set")); 109 continue;149 return; 110 150 } 111 151 if (n.isIncomplete()) { … … 113 153 addWayReferrer(s, n); 114 154 addRelationReferrer(s, n); 115 continue;155 return; 116 156 } 117 157 s.append(tr(" lat={0} lon={1} (projected: x={2}, y={3}); ", … … 122 162 addWayReferrer(s, n); 123 163 addRelationReferrer(s, n); 124 s.append('\n'); 125 } 126 127 for (Way w : new SubclassFilteredCollection<OsmPrimitive, Way>(primitives, OsmPrimitive.wayPredicate)) { 164 } 165 166 public void visit(Way w) { 128 167 s.append(tr("Way id={0}", w.getUniqueId())); 129 168 if (!checkDataSet(w)) { 130 169 s.append(tr(" not in data set")); 131 continue;170 return; 132 171 } 133 172 if (w.isIncomplete()) { 134 173 s.append(tr(" incomplete\n")); 135 174 addRelationReferrer(s, w); 136 continue;175 return; 137 176 } 138 177 s.append(trn(" {0} node; ", " {0} nodes; ", w.getNodes().size(), w.getNodes().size())); … … 145 184 s.append(String.format(" %d\n", n.getUniqueId())); 146 185 } 147 s.append('\n'); 148 } 149 150 for (Relation r : new SubclassFilteredCollection<OsmPrimitive, Relation>(primitives, OsmPrimitive.relationPredicate)) { 186 } 187 188 public void visit(Relation r) { 151 189 s.append(tr("Relation id={0}",r.getUniqueId())); 152 190 if (!checkDataSet(r)) { 153 191 s.append(tr(" not in data set")); 154 continue;192 return; 155 193 } 156 194 if (r.isIncomplete()) { 157 195 s.append(tr(" incomplete\n")); 158 196 addRelationReferrer(s, r); 159 continue;197 return; 160 198 } 161 199 s.append(trn(" {0} member; ", " {0} members; ", r.getMembersCount(), r.getMembersCount())); … … 168 206 s.append(String.format(" %s%d '%s'\n", m.getMember().getType().getAPIName().substring(0,1), m.getMember().getUniqueId(), m.getRole())); 169 207 } 170 s.append('\n'); 171 } 172 173 return s.toString().trim(); 208 } 174 209 } 175 210 -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r4354 r4357 861 861 Collection<OsmPrimitive> sel = model.getSelected(); 862 862 if (sel.isEmpty()) return; 863 InspectPrimitiveDialog inspectDialog = new InspectPrimitiveDialog(sel );863 InspectPrimitiveDialog inspectDialog = new InspectPrimitiveDialog(sel, Main.map.mapView.getEditLayer()); 864 864 inspectDialog.showDialog(); 865 865 }
Note:
See TracChangeset
for help on using the changeset viewer.