Ignore:
Timestamp:
2011-03-25T20:02:44+01:00 (15 years ago)
Author:
zverik
Message:

keyboard shortcuts for add, find, role (reltoolbox plugin)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/relcontext/src/relcontext/RelContextDialog.java

    r25715 r25717  
    11package relcontext;
    22
     3import org.openstreetmap.josm.actions.JosmAction;
    34import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    45import org.openstreetmap.josm.command.SequenceCommand;
     
    6768
    6869    public RelContextDialog() {
    69         super(tr("Relation Toolbox"), PREF_PREFIX,
    70                 tr("Open relation/multipolygon editor panel"),
    71                 Shortcut.registerShortcut("subwindow:reltoolbox", tr("Toggle: {0}", tr("Relation Toolbox")),
    72                 KeyEvent.VK_R, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 150, true);
     70        super(tr("Relation Toolbox"), PREF_PREFIX, tr("Open relation/multipolygon editor panel"), null, 150, true);
    7371
    7472        chosenRelation = new ChosenRelation();
     
    103101        });
    104102        roleBox.setVisible(false);
     103        final Action enterRoleAction = new EnterRoleAction(); // just for the shorcut
    105104
    106105        // [±][X] relation U [AZ][Down][Edit]
     
    513512    }
    514513
     514    private class EnterRoleAction extends JosmAction implements ChosenRelationListener {
     515
     516        public EnterRoleAction() {
     517            super("…", null, tr("Enter role for selected members"),
     518                    Shortcut.registerShortcut("reltoolbox:changerole", tr("Relation Toolbox: {0}", tr("Enter role for selected members")),
     519                    KeyEvent.VK_R, Shortcut.GROUP_EDIT), true);
     520            chosenRelation.addChosenRelationListener(this);
     521            updateEnabledState();
     522        }
     523
     524        public void actionPerformed( ActionEvent e ) {
     525            if( roleBoxModel.membersRole != null ) {
     526                String role = askForRoleName();
     527                if( role != null )
     528                    applyRoleToSelection(role);
     529            }
     530        }
     531
     532        public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
     533            setEnabled(newRelation != null);
     534        }
     535    }
     536
    515537    private class RoleComboBoxModel extends AbstractListModel implements ComboBoxModel {
    516538        private List<String> roles = new ArrayList<String>();
Note: See TracChangeset for help on using the changeset viewer.