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