1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.ActionEvent;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
10 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
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) {
|
---|
32 | DataSet ds = getLayerManager().getActiveDataSet();
|
---|
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
|
---|
39 | * the JOSM state changes, i.e. when a layer is removed or added.
|
---|
40 | */
|
---|
41 | @Override
|
---|
42 | protected void updateEnabledState() {
|
---|
43 | setEnabled(getLayerManager().getActiveDataSet() != null);
|
---|
44 | }
|
---|
45 | }
|
---|