Changeset 14826 in josm
- Timestamp:
- 2019-03-03T10:22:54+01:00 (6 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
r14825 r14826 19 19 20 20 import javax.swing.AbstractAction; 21 import javax.swing.Action; 21 22 import javax.swing.JComponent; 22 23 import javax.swing.JOptionPane; … … 126 127 buttons.add(selectButton); 127 128 128 lookupButton = new SideButton(new AbstractAction() { 129 { 130 putValue(NAME, tr("Lookup")); 131 putValue(SHORT_DESCRIPTION, tr("Looks up the selected primitives in the error list.")); 132 new ImageProvider("dialogs", "search").getResource().attachImageIcon(this, true); 133 } 134 135 @Override 136 public void actionPerformed(ActionEvent e) { 137 final DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 138 if (ds == null) { 139 return; 140 } 141 tree.selectRelatedErrors(ds.getSelected()); 142 } 143 }); 144 129 lookupButton = new SideButton(new LookupAction()); 145 130 buttons.add(lookupButton); 146 131 … … 179 164 } 180 165 createLayout(tree, true, buttons); 166 } 167 168 /** 169 * The action to lookup the selection in the error tree. 170 */ 171 class LookupAction extends AbstractAction implements DataSelectionListener { 172 173 LookupAction() { 174 putValue(NAME, tr("Lookup")); 175 putValue(SHORT_DESCRIPTION, tr("Looks up the selected primitives in the error list.")); 176 new ImageProvider("dialogs", "search").getResource().attachImageIcon(this, true); 177 SelectionEventManager.getInstance().addSelectionListener(this); 178 updateEnabledState(); 179 } 180 181 @Override 182 public void actionPerformed(ActionEvent e) { 183 final DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 184 if (ds == null) { 185 return; 186 } 187 tree.selectRelatedErrors(ds.getSelected()); 188 } 189 190 protected void updateEnabledState() { 191 boolean found = false; 192 for (TestError e : tree.getErrors()) { 193 for (OsmPrimitive p : e.getPrimitives()) { 194 if (p.isSelected()) { 195 found = true; 196 break; 197 } 198 } 199 } 200 setEnabled(found); 201 } 202 203 @Override 204 public void selectionChanged(SelectionChangeEvent event) { 205 updateEnabledState(); 206 } 181 207 } 182 208 … … 610 636 MainApplication.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate); 611 637 } 638 639 @Override 640 public void destroy() { 641 if (lookupButton != null && lookupButton.getAction() instanceof DataSelectionListener) { 642 Action a = lookupButton.getAction(); 643 SelectionEventManager.getInstance().removeSelectionListener((DataSelectionListener) a); 644 } 645 super.destroy(); 646 } 612 647 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
r14771 r14826 349 349 */ 350 350 public void selectRelatedErrors(final Collection<OsmPrimitive> primitives) { 351 final Collection<TreePath> paths = new ArrayList<>();351 final List<TreePath> paths = new ArrayList<>(); 352 352 walkAndSelectRelatedErrors(new TreePath(getRoot()), new HashSet<>(primitives)::contains, paths); 353 353 getSelectionModel().clearSelection(); … … 355 355 expandPath(path); 356 356 getSelectionModel().addSelectionPath(path); 357 } 358 // make sure that first path is visible 359 if (!paths.isEmpty()) { 360 scrollPathToVisible(paths.get(0)); 357 361 } 358 362 }
Note:
See TracChangeset
for help on using the changeset viewer.