Changeset 10490 in osm for applications/editors/josm
- Timestamp:
- 2008-09-05T09:02:02+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ErrorTreePanel.java
r10408 r10490 126 126 127 127 Map<Severity, Bag<String, TestError>> errorTree = new HashMap<Severity, Bag<String, TestError>>(); 128 Map<Severity, HashMap<String, Bag<String, TestError>>> errorTreeDeep = new HashMap<Severity, HashMap<String, Bag<String, TestError>>>(); 128 129 for(Severity s : Severity.values()) 129 130 { 130 131 errorTree.put(s, new Bag<String, TestError>(20)); 132 errorTreeDeep.put(s, new HashMap<String, Bag<String, TestError>>()); 131 133 } 132 134 133 135 for(TestError e : errors) 134 136 { 135 errorTree.get(e.getSeverity()).add(e.getMessage(), e); 137 Severity s = e.getSeverity(); 138 String d = e.getDescription(); 139 String m = e.getMessage(); 140 if(d != null) 141 { 142 Bag<String, TestError> b = errorTreeDeep.get(s).get(m); 143 if(b == null) 144 { 145 b = new Bag<String, TestError>(20); 146 errorTreeDeep.get(s).put(m, b); 147 } 148 b.add(d, e); 149 } 150 else 151 errorTree.get(s).add(m, e); 136 152 } 137 153 … … 140 156 { 141 157 Bag<String, TestError> severityErrors = errorTree.get(s); 142 if( severityErrors.isEmpty() ) 158 Map<String, Bag<String, TestError>> severityErrorsDeep = errorTreeDeep.get(s); 159 if(severityErrors.isEmpty() && severityErrorsDeep.isEmpty()) 143 160 continue; 144 161 … … 168 185 } 169 186 } 187 for(Entry<String, Bag <String, TestError>> bag : severityErrorsDeep.entrySet()) 188 { 189 // Group node 190 Bag <String, TestError> errorlist = bag.getValue(); 191 String nmsg = bag.getKey() + " (" + errorlist.size() + ")"; 192 DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(nmsg); 193 severityNode.add(groupNode); 194 195 if( oldSelectedRows.contains(bag.getKey())) 196 expandedPaths.add( new TreePath( new Object[] {rootNode, severityNode, groupNode} ) ); 197 198 for(Entry<String, List<TestError>> msgErrors : errorlist.entrySet()) 199 { 200 // Message node 201 List<TestError> errors = msgErrors.getValue(); 202 String msg = msgErrors.getKey() + " (" + errors.size() + ")"; 203 DefaultMutableTreeNode messageNode = new DefaultMutableTreeNode(msg); 204 groupNode.add(messageNode); 205 206 if( oldSelectedRows.contains(msgErrors.getKey())) 207 expandedPaths.add( new TreePath( new Object[] {rootNode, severityNode, groupNode, messageNode} ) ); 208 209 for (TestError error : errors) 210 { 211 // Error node 212 DefaultMutableTreeNode errorNode = new DefaultMutableTreeNode(error); 213 messageNode.add(errorNode); 214 } 215 } 216 } 170 217 } 171 218 -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java
r9269 r10490 123 123 for (OsmPrimitive p : selection) 124 124 { 125 if( !p.deleted ||!p.incomplete )125 if( !p.deleted && !p.incomplete ) 126 126 p.visit(this); 127 127 } -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java
r9684 r10490 26 26 /** Deeper error description */ 27 27 private String description; 28 private String description_en; 28 29 /** The affected primitives */ 29 30 private List<? extends OsmPrimitive> primitives; … … 46 47 * @param code The test error reference code 47 48 */ 48 public TestError(Test tester, Severity severity, String message, String description, int code,49 public TestError(Test tester, Severity severity, String message, String description, String description_en, int code, 49 50 List<? extends OsmPrimitive> primitives, List<?> highlighted) { 50 51 this.tester = tester; … … 52 53 this.message = message; 53 54 this.description = description; 55 this.description_en = description_en; 54 56 this.primitives = primitives; 55 57 this.highlighted = highlighted; … … 58 60 public TestError(Test tester, Severity severity, String message, int code, List<? extends OsmPrimitive> primitives, List<?> highlighted) 59 61 { 60 this(tester, severity, message, null, code, primitives, highlighted); 61 } 62 public TestError(Test tester, Severity severity, String message, String description, int code, List<? extends OsmPrimitive> primitives) 63 { 64 this(tester, severity, message, description, code, primitives, primitives); 62 this(tester, severity, message, null, null, code, primitives, highlighted); 63 } 64 public TestError(Test tester, Severity severity, String message, String description, String description_en, 65 int code, List<? extends OsmPrimitive> primitives) 66 { 67 this(tester, severity, message, description, description_en, code, primitives, primitives); 65 68 } 66 69 public TestError(Test tester, Severity severity, String message, int code, List<? extends OsmPrimitive> primitives) 67 70 { 68 this(tester, severity, message, null, code, primitives, primitives);71 this(tester, severity, message, null, null, code, primitives, primitives); 69 72 } 70 73 public TestError(Test tester, Severity severity, String message, int code, OsmPrimitive primitive) 71 74 { 72 this(tester, severity, message, null, code, Collections.singletonList(primitive), Collections.singletonList(primitive)); 73 } 74 public TestError(Test tester, Severity severity, String message, String description, int code, OsmPrimitive primitive) 75 { 76 this(tester, severity, message, description, code, Collections.singletonList(primitive)); 75 this(tester, severity, message, null, null, code, Collections.singletonList(primitive), Collections.singletonList(primitive)); 76 } 77 public TestError(Test tester, Severity severity, String message, String description, 78 String description_en, int code, OsmPrimitive primitive) 79 { 80 this(tester, severity, message, description, description_en, code, Collections.singletonList(primitive)); 77 81 } 78 82 … … 147 151 { 148 152 Collection<String> strings = new TreeSet<String>(); 149 String ignorestring = Integer.toString(code);153 String ignorestring = getIgnoreSubGroup(); 150 154 for (OsmPrimitive o : primitives) 151 155 { … … 164 168 } 165 169 return ignorestring; 170 } 171 172 public String getIgnoreSubGroup() 173 { 174 String ignorestring = getIgnoreGroup(); 175 if(description_en != null) 176 ignorestring += "_"+description_en; 177 return ignorestring; 178 } 179 180 public String getIgnoreGroup() 181 { 182 return Integer.toString(code); 166 183 } 167 184 -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java
r9270 r10490 103 103 for(TestError error : errors) 104 104 { 105 String state = error.getIgnoreState(); 106 if(state != null && plugin.validationDialog.ignoredErrors.contains(state)) 105 List<String> s = new ArrayList<String>(); 106 s.add(error.getIgnoreState()); 107 s.add(error.getIgnoreGroup()); 108 s.add(error.getIgnoreSubGroup()); 109 for(String state : s) 107 110 { 108 error.setIgnored(true); 111 if(state != null && plugin.validationDialog.ignoredErrors.contains(state)) 112 { 113 error.setIgnored(true); 114 } 109 115 } 110 116 } -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateUploadHook.java
r6388 r10490 52 52 tests = null; 53 53 54 return displa ErrorScreen(errors);54 return displayErrorScreen(errors); 55 55 } 56 56 … … 62 62 * if the user requested cancel. 63 63 */ 64 private boolean displa ErrorScreen(List<TestError> errors)64 private boolean displayErrorScreen(List<TestError> errors) 65 65 { 66 66 if( errors == null || errors.isEmpty() ) -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java
r9598 r10490 30 30 import org.openstreetmap.josm.plugins.validator.util.Bag; 31 31 import org.openstreetmap.josm.plugins.validator.util.Util; 32 import org.openstreetmap.josm.tools.ImageProvider; 32 33 33 34 /** … … 77 78 selectButton.setEnabled(false); 78 79 buttonPanel.add(selectButton); 79 buttonPanel.add(new SideButton(marktr("Validate"), "refresh", "Validator", tr("Validate the data."), this)); 80 buttonPanel.add(new SideButton(marktr("Validate"), "refresh", "Validator", 81 tr("Validate either current selection or complete dataset."), this)); 80 82 fixButton = new SideButton(marktr("Fix"), "fix", "Validator", tr("Fix the selected errors."), this); 81 83 fixButton.setEnabled(false); … … 187 189 private void ignoreErrors(ActionEvent e) 188 190 { 191 int asked = JOptionPane.DEFAULT_OPTION; 189 192 boolean changed = false; 190 193 TreePath[] selectionPaths = tree.getSelectionPaths(); … … 198 201 if( node == null ) 199 202 continue; 203 204 Object mainNodeInfo = node.getUserObject(); 205 if(!(mainNodeInfo instanceof TestError)) 206 { 207 int depth = 1; 208 Set<String> state = new HashSet<String>(); 209 // ask if the whole set should be ignored 210 if(asked == JOptionPane.DEFAULT_OPTION) 211 { 212 String[] a = new String[]{tr("Whole group"), tr("Single elements"),tr("Nothing")}; 213 asked = JOptionPane.showOptionDialog(Main.parent, tr("Ignore whole group or individual elements?"), 214 tr("Ignoring elements"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, 215 ImageProvider.get("dialogs", "delete"), a, a[1]); 216 } 217 if(asked == JOptionPane.YES_NO_OPTION) 218 { 219 Enumeration<DefaultMutableTreeNode> children = node.breadthFirstEnumeration(); 220 while(children.hasMoreElements()) 221 { 222 DefaultMutableTreeNode childNode = children.nextElement(); 223 if(processedNodes.contains(childNode)) 224 continue; 225 226 processedNodes.add(childNode); 227 Object nodeInfo = childNode.getUserObject(); 228 if(nodeInfo instanceof TestError) 229 { 230 TestError err = (TestError)nodeInfo; 231 err.setIgnored(true); 232 changed = true; 233 state.add(node.getDepth() == 1 ? err.getIgnoreSubGroup() : err.getIgnoreGroup()); 234 } 235 } 236 for(String s : state) 237 ignoredErrors.add(s); 238 continue; 239 } 240 else if(asked == JOptionPane.CANCEL_OPTION) 241 continue; 242 } 200 243 201 244 Enumeration<DefaultMutableTreeNode> children = node.breadthFirstEnumeration(); -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/TagChecker.java
r10408 r10490 1 1 package org.openstreetmap.josm.plugins.validator.tests; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 … … 14 15 import java.lang.IllegalStateException; 15 16 import java.net.URL; 17 import java.text.MessageFormat; 16 18 import java.util.ArrayList; 17 19 import java.util.Collection; … … 298 300 { 299 301 errors.add( new TestError(this, d.getSeverity(), tr("Illegal tag/value combinations"), 300 d.getDescription(), d.get Code(), p) );302 d.getDescription(), d.getDescriptionOrig(), d.getCode(), p) ); 301 303 withErrors.add(p, "TC"); 302 304 break; … … 308 310 for(Entry<String, String> prop: props.entrySet() ) 309 311 { 312 String s = marktr("Key ''{0}'' invalid."); 310 313 String key = prop.getKey(); 311 314 String value = prop.getValue(); … … 313 316 { 314 317 errors.add( new TestError(this, Severity.WARNING, tr("Tags with empty values"), 315 tr( "Key ''{0}'' invalid.", key), EMPTY_VALUES, p) );318 tr(s, key), MessageFormat.format(s, key), EMPTY_VALUES, p) ); 316 319 withErrors.add(p, "EV"); 317 320 } … … 319 322 { 320 323 errors.add( new TestError(this, Severity.WARNING, tr("Invalid property key"), 321 tr( "Key ''{0}'' invalid.", key), INVALID_KEY, p) );324 tr(s, key), MessageFormat.format(s, key), INVALID_KEY, p) ); 322 325 withErrors.add(p, "IPK"); 323 326 } … … 325 328 { 326 329 errors.add( new TestError(this, Severity.WARNING, tr("Invalid white space in property key"), 327 tr( "Key ''{0}'' invalid.", key), INVALID_KEY_SPACE, p) );330 tr(s, key), MessageFormat.format(s, key), INVALID_KEY_SPACE, p) ); 328 331 withErrors.add(p, "IPK"); 329 332 } … … 331 334 { 332 335 errors.add( new TestError(this, Severity.OTHER, tr("Property values start or end with white space"), 333 tr( "Key ''{0}'' invalid.", key), INVALID_SPACE, p) );336 tr(s, key), MessageFormat.format(s, key), INVALID_SPACE, p) ); 334 337 withErrors.add(p, "SPACE"); 335 338 } … … 340 343 { 341 344 errors.add( new TestError(this, Severity.OTHER, tr("Unknown property values"), 342 tr( "Key ''{0}'' invalid.", key), INVALID_VALUE, p) );345 tr(s, key), MessageFormat.format(s, key), INVALID_VALUE, p) ); 343 346 withErrors.add(p, "UPV"); 344 347 } … … 758 761 return tr(description); 759 762 } 763 public String getDescriptionOrig() 764 { 765 return description; 766 } 760 767 public Severity getSeverity() 761 768 { -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UnclosedWays.java
r9854 r10490 1 1 package org.openstreetmap.josm.plugins.validator.tests; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 5 import java.util.*; 6 import java.text.MessageFormat; 7 import java.util.ArrayList; 8 import java.util.List; 6 9 7 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 44 47 } 45 48 49 private String type; 50 private String etype; 51 private int mode; 52 private boolean force; 53 public void set(boolean f, int m, String text, String desc) 54 { 55 etype = MessageFormat.format(text, desc); 56 type = tr(text, tr(desc)); 57 mode = m; 58 force = f; 59 } 60 public void set(boolean f, int m, String text) 61 { 62 etype = text; 63 type = tr(text); 64 mode = m; 65 force = f; 66 } 67 46 68 @Override 47 69 public void visit(Way w) 48 70 { 49 boolean force = false; /* force even if end-to-end distance is long */ 50 String type = null, test; 51 int mode = 0; 71 String test; 72 force = false; /* force even if end-to-end distance is long */ 73 type = etype = null; 74 mode = 0; 52 75 53 76 if( w.deleted || w.incomplete ) … … 56 79 test = w.get("natural"); 57 80 if(test != null) 58 { 59 if(!"coastline".equals(test)) 60 force = true; 61 type = tr("natural type {0}", tr(test)); 62 mode = 1101; 63 } 81 set(!"coastline".equals(test), 1101, marktr("natural type {0}"), test); 64 82 test = w.get("landuse"); 65 83 if(test != null) 66 { 67 force = true; 68 type = tr("landuse type {0}", tr(test)); 69 mode = 1102; 70 } 84 set(true, 1102, marktr("landuse type {0}"), test); 71 85 test = w.get("amenities"); 72 86 if(test != null) 73 { 74 force = true; 75 type = tr("amenities type {0}", tr(test)); 76 mode = 1103; 77 } 87 set(true, 1103, marktr("amenities type {0}"), test); 78 88 test = w.get("sport"); 79 if(test != null) 80 { 81 force = true; 82 type = tr("sport type {0}", tr(test)); 83 mode = 1104; 84 } 89 if(test != null && !test.equals("water_slide")) 90 set(true, 1104, marktr("sport type {0}"), test); 85 91 test = w.get("tourism"); 86 92 if(test != null) 87 { 88 force = true; 89 type = tr("tourism type {0}", tr(test)); 90 mode = 1105; 91 } 93 set(true, 1105, marktr("tourism type {0}"), test); 92 94 test = w.get("shop"); 93 95 if(test != null) 94 { 95 force = true; 96 type = tr("shop type {0}", tr(test)); 97 mode = 1106; 98 } 96 set(true, 1106, marktr("shop type {0}"), test); 99 97 test = w.get("leisure"); 100 98 if(test != null) 101 { 102 force = true; 103 type = tr("leisure type {0}", tr(test)); 104 mode = 1107; 105 } 99 set(true, 1107, marktr("leisure type {0}"), test); 106 100 test = w.get("waterway"); 107 101 if(test != null && test.equals("riverbank")) 108 { 109 force = true; 110 type = tr("waterway type {0}", tr(test)); 111 mode = 1108; 112 } 102 set(true, 1108, marktr("waterway type {0}"), test); 113 103 Boolean btest = OsmUtils.getOsmBoolean(w.get("building")); 114 104 if (btest != null && btest) 115 { 116 force = true; 117 type = tr("building"); 118 mode = 1120; 119 } 105 set(true, 1120, marktr("building")); 120 106 btest = OsmUtils.getOsmBoolean(w.get("area")); 121 107 if (btest != null && btest) 122 { 123 force = true; 124 type = tr("area"); 125 mode = 1130; 126 } 108 set(true, 1130, marktr("area")); 127 109 128 110 if(type != null) … … 135 117 List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 136 118 primitives.add(w); 137 errors.add(new TestError(this, Severity.WARNING, tr("Unclosed way"), type, mode, primitives));119 errors.add(new TestError(this, Severity.WARNING, tr("Unclosed way"), type, etype, mode, primitives)); 138 120 _errorWays.add(w,w); 139 121 }
Note:
See TracChangeset
for help on using the changeset viewer.