- Timestamp:
- 2015-08-22T21:43:53+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
r8633 r8682 77 77 /** The select button */ 78 78 private SideButton selectButton; 79 /** The lookup button */ 80 private SideButton lookupButton; 79 81 80 82 private final JPopupMenu popupMenu = new JPopupMenu(); … … 114 116 selectButton.setEnabled(false); 115 117 buttons.add(selectButton); 118 119 lookupButton = new SideButton(new AbstractAction() { 120 { 121 putValue(NAME, tr("Lookup")); 122 putValue(SHORT_DESCRIPTION, tr("Looks up the the selected primitives in the error list.")); 123 putValue(SMALL_ICON, ImageProvider.get("dialogs", "search")); 124 } 125 126 @Override 127 public void actionPerformed(ActionEvent e) { 128 final DataSet ds = Main.main.getCurrentDataSet(); 129 if (ds == null) { 130 return; 131 } 132 tree.selectRelatedErrors(ds.getSelected()); 133 } 134 }); 135 136 buttons.add(lookupButton); 116 137 117 138 buttons.add(new SideButton(Main.main.validator.validateAction)); -
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
r8633 r8682 7 7 import java.awt.event.MouseEvent; 8 8 import java.util.ArrayList; 9 import java.util.Collection; 9 10 import java.util.Collections; 10 11 import java.util.EnumMap; … … 35 36 import org.openstreetmap.josm.tools.Destroyable; 36 37 import org.openstreetmap.josm.tools.MultiMap; 38 import org.openstreetmap.josm.tools.Predicate; 39 import org.openstreetmap.josm.tools.Predicates; 40 import org.openstreetmap.josm.tools.Utils; 37 41 38 42 /** … … 343 347 344 348 /** 349 * Selects all errors related to the specified {@code primitives}, i.e. where {@link TestError#getPrimitives()} 350 * returns a primitive present in {@code primitives}. 351 */ 352 public void selectRelatedErrors(final Collection<OsmPrimitive> primitives) { 353 final Collection<TreePath> paths = new ArrayList<>(); 354 walkAndSelectRelatedErrors(new TreePath(getRoot()), Predicates.inCollection(new HashSet<>(primitives)), paths); 355 getSelectionModel().clearSelection(); 356 for (TreePath path : paths) { 357 expandPath(path); 358 getSelectionModel().addSelectionPath(path); 359 } 360 } 361 362 private void walkAndSelectRelatedErrors(final TreePath p, final Predicate<OsmPrimitive> isRelevant, final Collection<TreePath> paths) { 363 final int count = getModel().getChildCount(p.getLastPathComponent()); 364 for (int i = 0; i < count; i++) { 365 final Object child = getModel().getChild(p.getLastPathComponent(), i); 366 if (getModel().isLeaf(child) && child instanceof DefaultMutableTreeNode 367 && ((DefaultMutableTreeNode) child).getUserObject() instanceof TestError) { 368 final TestError error = (TestError) ((DefaultMutableTreeNode) child).getUserObject(); 369 if (error.getPrimitives() != null) { 370 if (Utils.exists(error.getPrimitives(), isRelevant)) { 371 paths.add(p.pathByAddingChild(child)); 372 } 373 } 374 } else { 375 walkAndSelectRelatedErrors(p.pathByAddingChild(child), isRelevant, paths); 376 } 377 } 378 } 379 380 /** 345 381 * Returns the filter list 346 382 * @return the list of primitives used for filtering
Note:
See TracChangeset
for help on using the changeset viewer.