source: josm/trunk/src/org/openstreetmap/josm/command/ChangeNodesCommand.java@ 6830

Last change on this file since 6830 was 4918, checked in by simon04, 12 years ago

fix #7370 - Refactor Command.getDescription

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. See LICENSE file for details.
2package org.openstreetmap.josm.command;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collection;
7import java.util.List;
8import javax.swing.Icon;
9
10import org.openstreetmap.josm.data.osm.Node;
11import org.openstreetmap.josm.data.osm.Way;
12import org.openstreetmap.josm.data.osm.OsmPrimitive;
13import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
14import org.openstreetmap.josm.gui.DefaultNameFormatter;
15import org.openstreetmap.josm.tools.ImageProvider;
16
17/**
18 * Command that changes the nodes list of a way.
19 * The same can be done with ChangeCommand, but this is more
20 * efficient. (Needed for the duplicate node fixing
21 * tool of the validator plugin, when processing large data sets.)
22 *
23 * @author Imi
24 */
25public class ChangeNodesCommand extends Command {
26
27 private final Way way;
28 private final List<Node> newNodes;
29
30 public ChangeNodesCommand(Way way, List<Node> newNodes) {
31 super();
32 this.way = way;
33 this.newNodes = newNodes;
34 }
35
36 @Override public boolean executeCommand() {
37 super.executeCommand();
38 way.setNodes(newNodes);
39 way.setModified(true);
40 return true;
41 }
42
43 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
44 modified.add(way);
45 }
46
47 @Override
48 public String getDescriptionText() {
49 return tr("Changed nodes of {0}", way.getDisplayName(DefaultNameFormatter.getInstance()));
50 }
51
52 @Override
53 public Icon getDescriptionIcon() {
54 return ImageProvider.get(OsmPrimitiveType.WAY);
55 }
56}
Note: See TracBrowser for help on using the repository browser.