source: josm/trunk/src/org/openstreetmap/josm/command/SelectCommand.java@ 7587

Last change on this file since 7587 was 7122, checked in by simon04, 10 years ago

fix #6367 - Select last node of way when undoing Follow line (patch by Landwirt, updated, modified)

File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.command;
3
4import static org.openstreetmap.josm.tools.I18n.trn;
5
6import java.util.Collection;
7
8import org.openstreetmap.josm.Main;
9import org.openstreetmap.josm.data.osm.OsmPrimitive;
10
11/**
12 * Command that selects OSM primitives
13 *
14 * @author Landwirt
15 */
16public class SelectCommand extends Command {
17
18 /** the primitives to select when executing the command */
19 private final Collection<OsmPrimitive> newSelection;
20
21 /** the selection before applying the new selection */
22 private Collection<OsmPrimitive> oldSelection;
23
24 /**
25 * Constructs a new select command.
26 * @param newSelection the primitives to select when executing the command.
27 */
28 public SelectCommand(Collection<OsmPrimitive> newSelection) {
29 this.newSelection = newSelection;
30 }
31
32 @Override
33 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
34 }
35
36 @Override
37 public void undoCommand() {
38 Main.map.mapView.getEditLayer().data.setSelected(oldSelection);
39 }
40
41 @Override
42 public boolean executeCommand() {
43 oldSelection = Main.map.mapView.getEditLayer().data.getSelected();
44 Main.map.mapView.getEditLayer().data.setSelected(newSelection);
45 return true;
46 }
47
48 @Override
49 public String getDescriptionText() {
50 int size = newSelection != null ? newSelection.size() : 0;
51 return trn("Selected {0} object", "Selected {0} objects", size, size);
52 }
53}
Note: See TracBrowser for help on using the repository browser.