Changeset 14768 in josm
- Timestamp:
- 2019-02-08T11:34:38+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/TestError.java
r13611 r14768 429 429 if (equals(o)) return 0; 430 430 431 MultipleNameVisitor v1 = new MultipleNameVisitor(); 432 MultipleNameVisitor v2 = new MultipleNameVisitor(); 433 434 v1.visit(getPrimitives()); 435 v2.visit(o.getPrimitives()); 436 return AlphanumComparator.getInstance().compare(v1.toString(), v2.toString()); 431 return AlphanumComparator.getInstance().compare(getNameVisitor().toString(), o.getNameVisitor().toString()); 432 } 433 434 /** 435 * @return Name visitor (used in cell renderer and for sorting) 436 */ 437 public MultipleNameVisitor getNameVisitor() { 438 MultipleNameVisitor v = new MultipleNameVisitor(); 439 v.visit(getPrimitives()); 440 return v; 437 441 } 438 442 -
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
r14672 r14768 40 40 import org.openstreetmap.josm.data.validation.Severity; 41 41 import org.openstreetmap.josm.data.validation.TestError; 42 import org.openstreetmap.josm.data.validation.util.MultipleNameVisitor;43 42 import org.openstreetmap.josm.gui.util.GuiHelper; 43 import org.openstreetmap.josm.tools.AlphanumComparator; 44 44 import org.openstreetmap.josm.tools.Destroyable; 45 45 import org.openstreetmap.josm.tools.ListenerList; 46 import org.openstreetmap.josm.tools.Pair; 46 47 47 48 /** … … 115 116 if (nodeInfo instanceof TestError) { 116 117 TestError error = (TestError) nodeInfo; 117 MultipleNameVisitor v = new MultipleNameVisitor(); 118 v.visit(error.getPrimitives()); 119 res = "<html>" + v.getText() + "<br>" + error.getMessage(); 118 res = "<html>" + error.getNameVisitor().getText() + "<br>" + error.getMessage(); 120 119 String d = error.getDescription(); 121 120 if (d != null) … … 156 155 } 157 156 // Sort validation errors - #8517 158 Collections.sort(errors);157 sortErrors(errors); 159 158 160 159 // Remember the currently expanded rows … … 270 269 271 270 /** 271 * Sort list or errors in place. 272 * @param errors error list to be sorted 273 */ 274 static void sortErrors(List<TestError> errors) { 275 // Calculate the string to sort only once for each element 276 // Avoids to call TestError.compare() which costly 277 List<Pair<String, TestError>> toSort = new ArrayList<>(); 278 for (int i = 0; i < errors.size(); i++) { 279 TestError e = errors.get(i); 280 toSort.add(new Pair<>(e.getNameVisitor().getText(), e)); 281 } 282 toSort.sort((o1,o2) -> AlphanumComparator.getInstance().compare(o1.a, o2.a)); 283 List<TestError> sortedErrors = new ArrayList<>(errors.size()); 284 for (Pair<String, TestError> p : toSort) { 285 sortedErrors.add(p.b); 286 } 287 errors.clear(); 288 errors.addAll(sortedErrors); 289 } 290 291 /** 272 292 * Add a new invalidation listener 273 293 * @param listener The listener -
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreeRenderer.java
r8378 r14768 33 33 } else if (nodeInfo instanceof TestError) { 34 34 TestError error = (TestError) nodeInfo; 35 MultipleNameVisitor v = new MultipleNameVisitor(); 36 v.visit(error.getPrimitives()); 35 MultipleNameVisitor v = error.getNameVisitor(); 37 36 setText(v.getText()); 38 37 setIcon(v.getIcon());
Note:
See TracChangeset
for help on using the changeset viewer.