1 | /*
|
---|
2 | * This program is free software: you can redistribute it and/or modify it under
|
---|
3 | * the terms of the GNU General Public License as published by the
|
---|
4 | * Free Software Foundation, either version 3 of the License, or
|
---|
5 | * (at your option) any later version.
|
---|
6 | *
|
---|
7 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
---|
8 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
9 | * See the GNU General Public License for more details.
|
---|
10 | *
|
---|
11 | * You should have received a copy of the GNU General Public License along with this program.
|
---|
12 | * If not, see <http://www.gnu.org/licenses/>.
|
---|
13 | */
|
---|
14 | package org.openstreetmap.josm.plugins.fixAddresses;
|
---|
15 |
|
---|
16 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
17 |
|
---|
18 | import java.awt.event.ActionEvent;
|
---|
19 | import java.util.ArrayList;
|
---|
20 | import java.util.List;
|
---|
21 |
|
---|
22 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
23 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
24 |
|
---|
25 | @SuppressWarnings("serial")
|
---|
26 | public class SelectIncompleteAddressesAction extends JosmAction {
|
---|
27 |
|
---|
28 |
|
---|
29 | private AddressEditContainer addressEditContainer;
|
---|
30 |
|
---|
31 | public SelectIncompleteAddressesAction() {
|
---|
32 | super(tr("Select incomplete addresses"), "select_invaddr_24",
|
---|
33 | tr("Selects all addresses with incomplete data."), null, false);
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public void actionPerformed(ActionEvent arg0) {
|
---|
38 | addressEditContainer = new AddressEditContainer();
|
---|
39 | addressEditContainer.invalidate();
|
---|
40 |
|
---|
41 | if (addressEditContainer.getIncompleteAddresses() != null) {
|
---|
42 | List<OsmPrimitive> osms = new ArrayList<OsmPrimitive>();
|
---|
43 |
|
---|
44 | for (OSMAddress aNode : addressEditContainer.getIncompleteAddresses()) {
|
---|
45 | osms.add(aNode.getOsmObject());
|
---|
46 | }
|
---|
47 | getCurrentDataSet().setSelected(osms);
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | /* (non-Javadoc)
|
---|
52 | * @see org.openstreetmap.josm.actions.JosmAction#updateEnabledState()
|
---|
53 | */
|
---|
54 | @Override
|
---|
55 | protected void updateEnabledState() {
|
---|
56 | setEnabled(getCurrentDataSet() != null);
|
---|
57 | }
|
---|
58 | }
|
---|