Changeset 4158 in josm for trunk/src


Ignore:
Timestamp:
2011-06-22T11:47:21+02:00 (13 years ago)
Author:
stoecker
Message:

fix #6296 - allow to relations to selection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r4070 r4158  
    139139        // the select action
    140140        //
    141         SelectAction selectAction = new SelectAction();
     141        SelectAction selectAction = new SelectAction(false);
    142142        displaylist.addListSelectionListener(selectAction);
    143143        tp.add(new SideButton(selectAction, false));
     
    430430     */
    431431    class SelectAction extends AbstractAction implements ListSelectionListener{
    432         public SelectAction() {
    433             putValue(SHORT_DESCRIPTION,tr("Set the current selection to the list of selected relations"));
     432        boolean add;
     433        public SelectAction(boolean add) {
     434            putValue(SHORT_DESCRIPTION, add ? tr("Add the selected relations to the current selection")
     435            : tr("Set the current selection to the list of selected relations"));
    434436            putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));
    435             setEnabled(false);
     437            putValue(NAME, add ? tr("Select relation (add)") : tr("Select relation"));
     438            this.add = add;
     439            updateEnabledState();
    436440        }
    437441
     
    444448                selection.add(model.getRelation(i));
    445449            }
    446             Main.map.mapView.getEditLayer().data.setSelected(selection);
     450            if(add)
     451                Main.map.mapView.getEditLayer().data.addSelected(selection);
     452            else
     453                Main.map.mapView.getEditLayer().data.setSelected(selection);
     454        }
     455
     456        protected void updateEnabledState() {
     457            setEnabled(displaylist.getSelectedIndices() != null && displaylist.getSelectedIndices().length > 0);
    447458        }
    448459
    449460        public void valueChanged(ListSelectionEvent e) {
    450             setEnabled(displaylist.getSelectedIndices() != null && displaylist.getSelectedIndices().length > 0);
     461            updateEnabledState();
    451462        }
    452463    }
     
    457468     */
    458469    class SelectMembersAction extends AbstractAction implements ListSelectionListener{
    459         public SelectMembersAction() {
    460             putValue(SHORT_DESCRIPTION,tr("Select the members of all selected relations"));
     470        boolean add;
     471        public SelectMembersAction(boolean add) {
     472            putValue(SHORT_DESCRIPTION,add ? tr("Add the members of all selected relations to current selection")
     473            : tr("Select the members of all selected relations"));
    461474            putValue(SMALL_ICON, ImageProvider.get("selectall"));
    462             putValue(NAME, tr("Select members"));
     475            putValue(NAME, add ? tr("Select members (add)") : tr("Select members"));
     476            this.add = add;
    463477            updateEnabledState();
    464478        }
     
    471485                members.addAll(r.getMemberPrimitives());
    472486            }
    473             Main.map.mapView.getEditLayer().data.setSelected(members);
     487            if(add)
     488                Main.map.mapView.getEditLayer().data.addSelected(members);
     489            else
     490                Main.map.mapView.getEditLayer().data.setSelected(members);
    474491        }
    475492
     
    783800            // -- select members action
    784801            //
    785             SelectMembersAction selectMembersAction = new SelectMembersAction();
     802            SelectMembersAction selectMembersAction = new SelectMembersAction(false);
    786803            displaylist.addListSelectionListener(selectMembersAction);
    787804            add(selectMembersAction);
     805
     806            selectMembersAction = new SelectMembersAction(true);
     807            displaylist.addListSelectionListener(selectMembersAction);
     808            add(selectMembersAction);
     809
     810            // -- select action
     811            //
     812            SelectAction selectAction = new SelectAction(false);
     813            displaylist.addListSelectionListener(selectAction);
     814            add(selectAction);
     815
     816            selectAction = new SelectAction(true);
     817            displaylist.addListSelectionListener(selectAction);
     818            add(selectAction);
    788819        }
    789820
Note: See TracChangeset for help on using the changeset viewer.