Changeset 7781 in josm
- Timestamp:
- 2014-12-10T21:21:58+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r7750 r7781 82 82 public class SelectionListDialog extends ToggleDialog { 83 83 private JList<OsmPrimitive> lstPrimitives; 84 private DefaultListSelectionModel selectionModel= new DefaultListSelectionModel();85 private SelectionListModel model = new SelectionListModel(selectionModel);86 87 private SelectAction actSelect = new SelectAction();88 private SearchAction actSearch = new SearchAction();89 private ShowHistoryAction actShowHistory = new ShowHistoryAction();90 private ZoomToJOSMSelectionAction actZoomToJOSMSelection = new ZoomToJOSMSelectionAction();91 private ZoomToListSelection actZoomToListSelection = new ZoomToListSelection();92 private SelectInRelationListAction actSetRelationSelection = new SelectInRelationListAction();93 private EditRelationAction actEditRelationSelection = new EditRelationAction();94 private DownloadSelectedIncompleteMembersAction actDownloadSelectedIncompleteMembers = new DownloadSelectedIncompleteMembersAction();84 private final DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); 85 private final SelectionListModel model = new SelectionListModel(selectionModel); 86 87 private final SelectAction actSelect = new SelectAction(); 88 private final SearchAction actSearch = new SearchAction(); 89 private final ShowHistoryAction actShowHistory = new ShowHistoryAction(); 90 private final ZoomToJOSMSelectionAction actZoomToJOSMSelection = new ZoomToJOSMSelectionAction(); 91 private final ZoomToListSelection actZoomToListSelection = new ZoomToListSelection(); 92 private final SelectInRelationListAction actSetRelationSelection = new SelectInRelationListAction(); 93 private final EditRelationAction actEditRelationSelection = new EditRelationAction(); 94 private final DownloadSelectedIncompleteMembersAction actDownloadSelIncompleteMembers = new DownloadSelectedIncompleteMembersAction(); 95 95 96 96 /** the popup menu and its handler */ … … 169 169 public void showNotify() { 170 170 MapView.addEditLayerChangeListener(model); 171 SelectionEventManager.getInstance().addSelectionListener(actShowHistory, FireMode.IN_EDT_CONSOLIDATED); 171 172 SelectionEventManager.getInstance().addSelectionListener(model, FireMode.IN_EDT_CONSOLIDATED); 172 173 DatasetEventManager.getInstance().addDatasetListener(model, FireMode.IN_EDT); … … 185 186 MapView.removeEditLayerChangeListener(actSearch); 186 187 MapView.removeEditLayerChangeListener(model); 188 SelectionEventManager.getInstance().removeSelectionListener(actShowHistory); 187 189 SelectionEventManager.getInstance().removeSelectionListener(model); 188 190 DatasetEventManager.getInstance().removeDatasetListener(model); … … 237 239 handler.addAction(actEditRelationSelection); 238 240 handler.addSeparator(); 239 handler.addAction(actDownloadSel ectedIncompleteMembers);241 handler.addAction(actDownloadSelIncompleteMembers); 240 242 return handler; 241 243 } … … 348 350 * The action for showing history information of the current history item. 349 351 */ 350 class ShowHistoryAction extends AbstractAction implements ListSelectionListener {352 class ShowHistoryAction extends AbstractAction implements ListSelectionListener, SelectionChangedListener { 351 353 /** 352 354 * Constructs a new {@code ShowHistoryAction}. … … 356 358 putValue(SHORT_DESCRIPTION, tr("Display the history of the selected objects.")); 357 359 putValue(SMALL_ICON, ImageProvider.get("dialogs", "history")); 358 updateEnabledState( );360 updateEnabledState(model.getSize()); 359 361 } 360 362 … … 362 364 public void actionPerformed(ActionEvent e) { 363 365 Collection<OsmPrimitive> sel = model.getSelected(); 364 if (sel.isEmpty())return; 366 if (sel.isEmpty() && model.getSize() != 1) { 367 return; 368 } else if (sel.isEmpty()) { 369 sel = Collections.singleton(model.getElementAt(0)); 370 } 365 371 HistoryBrowserDialogManager.getInstance().showHistory(sel); 366 372 } 367 373 368 protected void updateEnabledState() { 369 setEnabled(!model.getSelected().isEmpty()); 374 protected void updateEnabledState(int osmSelectionSize) { 375 // See #10830 - allow to click on history button is a single object is selected, even if not selected again in the list 376 setEnabled(!model.getSelected().isEmpty() || osmSelectionSize == 1); 370 377 } 371 378 372 379 @Override 373 380 public void valueChanged(ListSelectionEvent e) { 374 updateEnabledState(); 381 updateEnabledState(model.getSize()); 382 } 383 384 @Override 385 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 386 updateEnabledState(newSelection.size()); 375 387 } 376 388 }
Note:
See TracChangeset
for help on using the changeset viewer.