source: josm/trunk/src/org/openstreetmap/josm/command/ChangeCommand.java@ 1766

Last change on this file since 1766 was 1750, checked in by Gubaer, 15 years ago

new: replaced global conflict list by conflict list per layer, similar to datasets

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.command;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collection;
7
8import javax.swing.JLabel;
9import javax.swing.tree.DefaultMutableTreeNode;
10import javax.swing.tree.MutableTreeNode;
11
12import org.openstreetmap.josm.data.osm.OsmPrimitive;
13import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
14
15/**
16 * Command that basically replaces one OSM primitive by another of the
17 * same type.
18 *
19 * @author Imi
20 */
21public class ChangeCommand extends Command {
22
23 private final OsmPrimitive osm;
24 private final OsmPrimitive newOsm;
25
26 public ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm) {
27 super();
28 this.osm = osm;
29 this.newOsm = newOsm;
30 }
31
32 @Override public boolean executeCommand() {
33 super.executeCommand();
34 osm.cloneFrom(newOsm);
35 osm.modified = true;
36 return true;
37 }
38
39 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
40 modified.add(osm);
41 }
42
43 @Override public MutableTreeNode description() {
44 NameVisitor v = new NameVisitor();
45 osm.visit(v);
46 return new DefaultMutableTreeNode(new JLabel(tr("Change {0} {1}", tr(v.className), v.name), v.icon, JLabel.HORIZONTAL));
47 }
48}
Note: See TracBrowser for help on using the repository browser.