Changeset 25717 in osm for applications/editors


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

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

Location:
applications/editors/josm/plugins/relcontext/src/relcontext
Files:
3 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>();
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/AddRemoveMemberAction.java

    r25688 r25717  
    55import static org.openstreetmap.josm.tools.I18n.tr;
    66import java.awt.event.ActionEvent;
     7import java.awt.event.KeyEvent;
    78import org.openstreetmap.josm.Main;
    89import org.openstreetmap.josm.actions.JosmAction;
     
    1415import org.openstreetmap.josm.data.osm.Way;
    1516import org.openstreetmap.josm.tools.ImageProvider;
     17import org.openstreetmap.josm.tools.Shortcut;
    1618import relcontext.ChosenRelation;
    1719import relcontext.ChosenRelationListener;
     
    2931
    3032    public AddRemoveMemberAction( ChosenRelation rel ) {
    31         super(null, "relcontext/addremove", tr("Add/remove members from the chosen relation"), null, false);
     33        super(null, "relcontext/addremove", tr("Add/remove members from the chosen relation"),
     34                Shortcut.registerShortcut("reltoolbox:addremove", tr("Relation Toolbox: {0}", tr("Add/remove members from the chosen relation")),
     35                KeyEvent.VK_EQUALS, Shortcut.GROUP_EDIT), true);
    3236        this.rel = rel;
    3337        rel.addChosenRelationListener(this);
  • applications/editors/josm/plugins/relcontext/src/relcontext/actions/FindRelationAction.java

    r25695 r25717  
    1515import org.openstreetmap.josm.gui.DefaultNameFormatter;
    1616import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
     17import org.openstreetmap.josm.tools.Shortcut;
    1718import relcontext.ChosenRelation;
    1819
     
    2627
    2728    public FindRelationAction( ChosenRelation chRel ) {
    28         super("Find", "relcontext/find", "Find a relation", null, false);
     29        super("Find", "relcontext/find", tr("Find a relation"),
     30                Shortcut.registerShortcut("reltoolbox:find", tr("Relation Toolbox: {0}", tr("Find a relation")),
     31                KeyEvent.VK_F, Shortcut.GROUP_EDIT), true);
    2932        this.chRel = chRel;
    3033    }
Note: See TracChangeset for help on using the changeset viewer.