Ticket #22655: new_feature.diff
| File new_feature.diff, 4.9 KB (added by , 3 years ago) |
|---|
-
src/org/openstreetmap/josm/plugins/todo/TodoDialog.java
66 66 private final PassAction actPass = new PassAction(model); 67 67 private final MarkAction actMark = new MarkAction(model); 68 68 private final MarkSelectedAction actMarkSelected = new MarkSelectedAction(model); 69 private final ClearAndAddAction actClearAndAdd = new ClearAndAddAction(model); 69 70 /* The popup must be created AFTER actions */ 70 71 private final TodoPopup popupMenu = new TodoPopup(lstPrimitives); 71 72 … … 72 73 // CHECKSTYLE.OFF: LineLength 73 74 private final Shortcut sctPass = Shortcut.registerShortcut("subwindow:todo:pass", tr("Pass over element without marking it"), KeyEvent.VK_OPEN_BRACKET, Shortcut.DIRECT); 74 75 private final Shortcut sctMark = Shortcut.registerShortcut("subwindow:todo:mark", tr("Mark element done"), KeyEvent.VK_CLOSE_BRACKET, Shortcut.DIRECT); 76 private final Shortcut sctAdd = Shortcut.registerShortcut("subwindow:todo:add", tr("Add elements"), KeyEvent.VK_OPEN_BRACKET, Shortcut.CTRL); 77 private final Shortcut sctClearAndAdd = Shortcut.registerShortcut("subwindow:todo:clearandadd", tr("Clear and add elements"), KeyEvent.VK_CLOSE_BRACKET, Shortcut.CTRL); 75 78 // CHECKSTYLE.ON: LineLength 76 79 77 80 /** … … 111 114 // the add button 112 115 SideButton addButton = new SideButton(actAdd); 113 116 actAdd.updateEnabledState(); 117 MainApplication.registerActionShortcut(actAdd, sctAdd); 114 118 119 // the clear and add button 120 SideButton clearAndAddButton = new SideButton(actClearAndAdd); 121 actClearAndAdd.updateEnabledState(); 122 MainApplication.registerActionShortcut(actClearAndAdd, sctClearAndAdd); 123 115 124 // the pass button 116 125 SideButton passButton = new SideButton(actPass); 117 126 lstPrimitives.getSelectionModel().addListSelectionListener(actPass); … … 125 134 // the mark from map button 126 135 SideButton markSelectedButton = new SideButton(actMarkSelected); 127 136 128 createLayout(lstPrimitives, true, Arrays.asList(selectButton, addButton, passButton, markButton, markSelectedButton));137 createLayout(lstPrimitives, true, Arrays.asList(selectButton, addButton, clearAndAddButton, passButton, markButton, markSelectedButton)); 129 138 } 130 139 131 140 private static void zoom(OsmDataLayer layer) { … … 178 187 @Override 179 188 public void showNotify() { 180 189 SelectionEventManager.getInstance().addSelectionListenerForEdt(actAdd); 190 SelectionEventManager.getInstance().addSelectionListenerForEdt(actClearAndAdd); 181 191 SelectionEventManager.getInstance().addSelectionListenerForEdt(actMarkSelected); 182 192 actAdd.updateEnabledState(); 183 193 } … … 290 300 AddAction(TodoListModel model) { 291 301 this.model = model; 292 302 putValue(NAME, tr("Add")); 293 putValue(SHORT_DESCRIPTION, tr("Add the selected items to the todo list. "));303 putValue(SHORT_DESCRIPTION, tr("Add the selected items to the todo list. (ctrl + [).")); 294 304 new ImageProvider("dialogs", "add").getResource().attachImageIcon(this, true); 295 305 updateEnabledState(); 296 306 } … … 317 327 } 318 328 } 319 329 330 private class ClearAndAddAction extends AbstractAction implements DataSelectionListener { 331 private final TodoListModel model; 332 333 ClearAndAddAction(TodoListModel model) { 334 this.model = model; 335 putValue(NAME, "Clear and add"); 336 putValue(SHORT_DESCRIPTION, tr("Clear list, add the selected items to the todo list and zoom first item. (ctrl + ]).")); 337 new ImageProvider("dialogs", "selectionlist").getResource().attachImageIcon(this, true); 338 updateEnabledState(); 339 } 340 341 @Override 342 public void actionPerformed(ActionEvent e) { 343 model.clear(); 344 model.addItems(getItems()); 345 selectAndZoom(model.getSelected()); 346 } 347 348 /** 349 * Update the enabled state of the action 350 */ 351 public void updateEnabledState() { 352 if (MainApplication.getLayerManager().getEditLayer() == null) { 353 setEnabled(false); 354 } else { 355 setEnabled(!MainApplication.getLayerManager().getEditLayer().data.selectionEmpty()); 356 } 357 } 358 359 @Override 360 public void selectionChanged(SelectionChangeEvent event) { 361 updateEnabledState(); 362 } 363 } 364 320 365 private class MarkSelectedAction extends AbstractAction implements DataSelectionListener { 321 366 private final TodoListModel model; 322 367 … … 514 559 @Override 515 560 public void propertyChange(PropertyChangeEvent arg0) { 516 561 actAdd.updateEnabledState(); 562 actClearAndAdd.updateEnabledState(); 517 563 } 518 564 519 565 @Override
