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

Last change on this file since 12182 was 10428, checked in by stoecker, 8 years ago

see #9995 - patch mainly by strump - improve HIDPI behaviour

  • Property svn:eol-style set to native
File size: 1.6 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.
23 * If <code>false</code>, the relation will replace the current selection.
24 */
25 public SelectRelationAction(boolean add) {
26 putValue(SHORT_DESCRIPTION, add ? tr("Add the selected relations to the current selection") :
27 tr("Set the current selection to the list of selected relations"));
28 new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
29 putValue(NAME, add ? tr("Select relation (add)") : tr("Select relation"));
30 this.add = add;
31 }
32
33 @Override
34 public void actionPerformed(ActionEvent e) {
35 if (!isEnabled() || relations.isEmpty()) return;
36 OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
37 if (editLayer == null || editLayer.data == null) return;
38 if (add) {
39 editLayer.data.addSelected(relations);
40 } else {
41 editLayer.data.setSelected(relations);
42 }
43 }
44}
Note: See TracBrowser for help on using the repository browser.