source: josm/trunk/src/org/openstreetmap/josm/actions/relation/SelectRelationAction.java@ 7937

Last change on this file since 7937 was 7937, checked in by bastiK, 9 years ago

add subversion property svn:eol=native

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions.relation;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7
8import org.openstreetmap.josm.Main;
9import org.openstreetmap.josm.gui.layer.OsmDataLayer;
10import org.openstreetmap.josm.tools.ImageProvider;
11
12/**
13 * Sets the current selection to specified list of relations
14 * @since 5793
15 */
16public class SelectRelationAction extends AbstractRelationAction {
17
18 private final boolean add;
19
20 /**
21 * Constructs a new <code>SelectRelationAction</code>.
22 * @param add if <code>true</code>, the relation will be added to current selection. If <code>false</code>, the relation will replace the current selection.
23 */
24 public SelectRelationAction(boolean add) {
25 putValue(SHORT_DESCRIPTION, add ? tr("Add the selected relations to the current selection") : tr("Set the current selection to the list of selected relations"));
26 putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));
27 putValue(NAME, add ? tr("Select relation (add)") : tr("Select relation"));
28 this.add = add;
29 }
30
31 @Override
32 public void actionPerformed(ActionEvent e) {
33 if (!isEnabled() || relations.isEmpty()) return;
34 OsmDataLayer editLayer = Main.main.getEditLayer();
35 if (editLayer==null || editLayer.data==null) return;
36 if (add) {
37 editLayer.data.addSelected(relations);
38 } else {
39 editLayer.data.setSelected(relations);
40 }
41 }
42}
Note: See TracBrowser for help on using the repository browser.