- Timestamp:
- 2009-09-26T13:54:06+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2126 r2194 77 77 displaylist = new JList(model); 78 78 displaylist.setCellRenderer(new OsmPrimitivRenderer()); 79 displaylist.setSelectionMode(ListSelectionModel. SINGLE_SELECTION);79 displaylist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 80 80 displaylist.addMouseListener(new DoubleClickAdapter()); 81 81 add(new JScrollPane(displaylist), BorderLayout.CENTER); … … 97 97 buttonPanel.add(new SideButton(editAction), GBC.std()); 98 98 99 // the editaction99 // the duplicate action 100 100 // 101 101 DuplicateAction duplicateAction = new DuplicateAction(); … … 108 108 displaylist.addListSelectionListener(deleteAction); 109 109 buttonPanel.add(new SideButton(deleteAction), GBC.eol()); 110 111 // the select action 112 // 113 SelectAction selectAction = new SelectAction(); 114 displaylist.addListSelectionListener(selectAction); 115 buttonPanel.add(new SideButton(selectAction), GBC.eol()); 116 117 110 118 add(buttonPanel, BorderLayout.SOUTH); 111 119 … … 275 283 public EditAction() { 276 284 putValue(SHORT_DESCRIPTION,tr( "Open an editor for the selected relation")); 277 putValue(NAME, tr("Edit")); 285 //putValue(NAME, tr("Edit")); 278 286 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit")); 279 287 setEnabled(false); … … 303 311 304 312 public void valueChanged(ListSelectionEvent e) { 305 setEnabled(displaylist.getSelectedIndices() != null && displaylist.getSelectedIndices().length > 0);313 setEnabled(displaylist.getSelectedIndices() != null && displaylist.getSelectedIndices().length == 1); 306 314 } 307 315 } … … 311 319 * 312 320 */ 313 class DeleteAction extends AbstractAction implements ListSelectionListener , Runnable{321 class DeleteAction extends AbstractAction implements ListSelectionListener { 314 322 class AbortException extends Exception {} 315 323 316 324 public DeleteAction() { 317 325 putValue(SHORT_DESCRIPTION,tr("Delete the selected relation")); 318 putValue(NAME, tr("Delete")); 326 //putValue(NAME, tr("Delete")); 319 327 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete")); 320 328 setEnabled(false); 321 329 } 322 330 323 public void run() { 324 if (!isEnabled()) return; 325 Relation toDelete = getSelected(); 331 protected void deleteRelation(Relation toDelete) { 326 332 if (toDelete == null) 327 333 return; … … 333 339 334 340 public void actionPerformed(ActionEvent e) { 335 run(); 341 if (!isEnabled()) return; 342 int [] idx = displaylist.getSelectedIndices(); 343 ArrayList<Relation> toDelete = new ArrayList<Relation>(idx.length); 344 for (int i: idx) { 345 toDelete.add(model.getRelation(i)); 346 } 347 for (Relation r: toDelete) { 348 deleteRelation(r); 349 } 336 350 } 337 351 … … 348 362 public NewAction() { 349 363 putValue(SHORT_DESCRIPTION,tr("Create a new relation")); 350 putValue(NAME, tr("New")); 364 //putValue(NAME, tr("New")); 351 365 putValue(SMALL_ICON, ImageProvider.get("dialogs", "addrelation")); 352 366 setEnabled(false); … … 385 399 public DuplicateAction() { 386 400 putValue(SHORT_DESCRIPTION, tr("Create a copy of this relation and open it in another editor window")); 387 // FIXME provide an icon388 401 putValue(SMALL_ICON, ImageProvider.get("duplicate")); 389 putValue(NAME, tr("Duplicate")); 402 //putValue(NAME, tr("Duplicate")); 390 403 updateEnabledState(); 391 404 } … … 419 432 } 420 433 434 /** 435 * Sets the current selection to the list of relations selected in this dialog 436 * 437 */ 438 class SelectAction extends AbstractAction implements ListSelectionListener{ 439 public SelectAction() { 440 putValue(SHORT_DESCRIPTION,tr("Set the current selection to the list of selected relations")); 441 //putValue(NAME, tr("Select")); 442 putValue(SMALL_ICON, ImageProvider.get("dialogs", "select")); 443 setEnabled(false); 444 } 445 446 public void actionPerformed(ActionEvent e) { 447 if (!isEnabled()) return; 448 int [] idx = displaylist.getSelectedIndices(); 449 if (idx == null || idx.length == 0) return; 450 ArrayList<OsmPrimitive> selection = new ArrayList<OsmPrimitive>(idx.length); 451 for (int i: idx) { 452 selection.add(model.getRelation(i)); 453 } 454 Main.map.mapView.getEditLayer().data.setSelected(selection); 455 DataSet.fireSelectionChanged(selection); 456 } 457 458 public void valueChanged(ListSelectionEvent e) { 459 setEnabled(displaylist.getSelectedIndices() != null && displaylist.getSelectedIndices().length > 0); 460 } 461 } 462 421 463 private static class RelationListModel extends AbstractListModel { 422 464 private ArrayList<Relation> relations; … … 424 466 public ArrayList<Relation> getRelations() { 425 467 return relations; 468 } 469 470 public Relation getRelation(int idx) { 471 return relations.get(idx); 426 472 } 427 473
Note:
See TracChangeset
for help on using the changeset viewer.