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("Selection: {0}", tr("Non-branching way sequences")),
|
---|
27 | KeyEvent.VK_W, Shortcut.SHIFT),
|
---|
28 | true);
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public void actionPerformed(ActionEvent ev) {
|
---|
33 | DataSet ds = getLayerManager().getActiveDataSet();
|
---|
34 | SelectNonBranchingWaySequences ws = new SelectNonBranchingWaySequences(ds.getSelectedWays());
|
---|
35 | ws.extend(ds);
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | protected boolean listenToSelectionChange() {
|
---|
40 | return false;
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Update the enabled state of the action when something in
|
---|
45 | * the JOSM state changes, i.e. when a layer is removed or added.
|
---|
46 | */
|
---|
47 | @Override
|
---|
48 | protected void updateEnabledState() {
|
---|
49 | setEnabled(getLayerManager().getActiveDataSet() != null);
|
---|
50 | }
|
---|
51 | }
|
---|