[6544] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.actions;
|
---|
| 3 |
|
---|
[12636] | 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
[6544] | 5 |
|
---|
| 6 | import java.awt.event.ActionEvent;
|
---|
| 7 | import java.awt.event.KeyEvent;
|
---|
| 8 |
|
---|
[12636] | 9 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
| 10 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
[6544] | 11 |
|
---|
| 12 | /**
|
---|
| 13 | * This allows to select a sequence of non-branching connected ways.
|
---|
| 14 | *
|
---|
| 15 | * @author Marko Mäkelä
|
---|
| 16 | */
|
---|
| 17 | public class SelectNonBranchingWaySequencesAction extends JosmAction {
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * Creates a new {@link SelectNonBranchingWaySequencesAction}
|
---|
| 21 | */
|
---|
| 22 | public SelectNonBranchingWaySequencesAction() {
|
---|
| 23 | super(tr("Non-branching way sequences"),
|
---|
| 24 | "way-select",
|
---|
| 25 | tr("Select non-branching sequences of ways"),
|
---|
| 26 | Shortcut.registerShortcut("wayselector:wayselect", tr("Non-branching way sequences"), KeyEvent.VK_W, Shortcut.SHIFT),
|
---|
| 27 | true);
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | @Override
|
---|
| 31 | public void actionPerformed(ActionEvent ev) {
|
---|
[12636] | 32 | DataSet ds = getLayerManager().getEditDataSet();
|
---|
[6544] | 33 | SelectNonBranchingWaySequences ws = new SelectNonBranchingWaySequences(ds.getSelectedWays());
|
---|
| 34 | ws.extend(ds);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * Update the enabled state of the action when something in
|
---|
[12636] | 39 | * the JOSM state changes, i.e. when a layer is removed or added.
|
---|
[6544] | 40 | */
|
---|
| 41 | @Override
|
---|
| 42 | protected void updateEnabledState() {
|
---|
[12636] | 43 | setEnabled(getLayerManager().getEditDataSet() != null);
|
---|
[6544] | 44 | }
|
---|
| 45 | }
|
---|