Ticket #22655: updated.diff
| File updated.diff, 4.1 KB (added by , 3 years ago) |
|---|
-
src/org/openstreetmap/josm/plugins/todo/TodoDialog.java
29 29 30 30 import org.openstreetmap.josm.actions.AutoScaleAction; 31 31 import org.openstreetmap.josm.actions.AutoScaleAction.AutoScaleMode; 32 import org.openstreetmap.josm.actions.JosmAction; 32 33 import org.openstreetmap.josm.data.osm.DataSelectionListener; 33 34 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 35 import org.openstreetmap.josm.data.osm.event.DatasetEventManager; … … 66 67 private final PassAction actPass = new PassAction(model); 67 68 private final MarkAction actMark = new MarkAction(model); 68 69 private final MarkSelectedAction actMarkSelected = new MarkSelectedAction(model); 70 private final ClearAndAddAction actClearAndAdd = new ClearAndAddAction(model); 69 71 /* The popup must be created AFTER actions */ 70 72 private final TodoPopup popupMenu = new TodoPopup(lstPrimitives); 71 73 … … 112 114 SideButton addButton = new SideButton(actAdd); 113 115 actAdd.updateEnabledState(); 114 116 117 // the clear and add button 118 SideButton clearAndAddButton = new SideButton(actClearAndAdd); 119 actClearAndAdd.updateEnabledState(); 120 115 121 // the pass button 116 122 SideButton passButton = new SideButton(actPass); 117 123 lstPrimitives.getSelectionModel().addListSelectionListener(actPass); … … 125 131 // the mark from map button 126 132 SideButton markSelectedButton = new SideButton(actMarkSelected); 127 133 128 createLayout(lstPrimitives, true, Arrays.asList(selectButton, addButton, passButton, markButton, markSelectedButton));134 createLayout(lstPrimitives, true, Arrays.asList(selectButton, addButton, clearAndAddButton, passButton, markButton, markSelectedButton)); 129 135 } 130 136 131 137 private static void zoom(OsmDataLayer layer) { … … 178 184 @Override 179 185 public void showNotify() { 180 186 SelectionEventManager.getInstance().addSelectionListenerForEdt(actAdd); 187 SelectionEventManager.getInstance().addSelectionListenerForEdt(actClearAndAdd); 181 188 SelectionEventManager.getInstance().addSelectionListenerForEdt(actMarkSelected); 182 189 actAdd.updateEnabledState(); 183 190 } … … 317 324 } 318 325 } 319 326 327 private class ClearAndAddAction extends JosmAction implements DataSelectionListener { 328 private final TodoListModel model; 329 330 ClearAndAddAction(TodoListModel model) { 331 super( 332 tr("Clear and add"), 333 "dialogs/selectionlist", 334 tr("Clear list, add the selected items to the todo list and zoom first item."), 335 Shortcut.registerShortcut("subwindow:todo:clearandadd", tr("Clear and add elements"), KeyEvent.VK_CLOSE_BRACKET, Shortcut.CTRL), 336 false 337 ); 338 this.model = model; 339 updateEnabledState(); 340 } 341 342 @Override 343 public void actionPerformed(ActionEvent e) { 344 model.clear(); 345 model.addItems(getItems()); 346 selectAndZoom(model.getSelected()); 347 } 348 349 /** 350 * Update the enabled state of the action 351 */ 352 public void updateEnabledState() { 353 if (MainApplication.getLayerManager().getEditLayer() == null) { 354 setEnabled(false); 355 } else { 356 setEnabled(!MainApplication.getLayerManager().getEditLayer().data.selectionEmpty()); 357 } 358 } 359 360 @Override 361 public void selectionChanged(SelectionChangeEvent event) { 362 updateEnabledState(); 363 } 364 } 365 320 366 private class MarkSelectedAction extends AbstractAction implements DataSelectionListener { 321 367 private final TodoListModel model; 322 368 … … 514 560 @Override 515 561 public void propertyChange(PropertyChangeEvent arg0) { 516 562 actAdd.updateEnabledState(); 563 actClearAndAdd.updateEnabledState(); 517 564 } 518 565 519 566 @Override
