| 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()); |
| | 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 | } |
| | 207 | } |
| | 208 | |