Line | |
---|
1 | package org.openstreetmap.josm.command;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 |
|
---|
5 | import java.util.Collection;
|
---|
6 |
|
---|
7 | import javax.swing.JLabel;
|
---|
8 | import javax.swing.tree.DefaultMutableTreeNode;
|
---|
9 | import javax.swing.tree.MutableTreeNode;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
12 | import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
|
---|
13 |
|
---|
14 | public class ChangeCommand extends Command {
|
---|
15 |
|
---|
16 | private final OsmPrimitive osm;
|
---|
17 | private final OsmPrimitive newOsm;
|
---|
18 |
|
---|
19 | public ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm) {
|
---|
20 | this.osm = osm;
|
---|
21 | this.newOsm = newOsm;
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override public void executeCommand() {
|
---|
25 | super.executeCommand();
|
---|
26 | osm.cloneFrom(newOsm);
|
---|
27 | osm.modified = true;
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
|
---|
31 | modified.add(osm);
|
---|
32 | }
|
---|
33 |
|
---|
34 | @Override public MutableTreeNode description() {
|
---|
35 | NameVisitor v = new NameVisitor();
|
---|
36 | osm.visit(v);
|
---|
37 | return new DefaultMutableTreeNode(new JLabel(tr("Change")+" "+tr(v.className)+" "+v.name, v.icon, JLabel.HORIZONTAL));
|
---|
38 | }
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.