Last change
on this file since 1180 was 1169, checked in by stoecker, 15 years ago |
removed usage of tab stops
|
-
Property svn:eol-style
set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.command;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.Collection;
|
---|
7 |
|
---|
8 | import javax.swing.JLabel;
|
---|
9 | import javax.swing.tree.DefaultMutableTreeNode;
|
---|
10 | import javax.swing.tree.MutableTreeNode;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
13 | import 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 | */
|
---|
21 | public class ChangeCommand extends Command {
|
---|
22 |
|
---|
23 | private final OsmPrimitive osm;
|
---|
24 | private final OsmPrimitive newOsm;
|
---|
25 |
|
---|
26 | public ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm) {
|
---|
27 | this.osm = osm;
|
---|
28 | this.newOsm = newOsm;
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override public boolean executeCommand() {
|
---|
32 | super.executeCommand();
|
---|
33 | osm.cloneFrom(newOsm);
|
---|
34 | osm.modified = true;
|
---|
35 | return true;
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
|
---|
39 | modified.add(osm);
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override public MutableTreeNode description() {
|
---|
43 | NameVisitor v = new NameVisitor();
|
---|
44 | osm.visit(v);
|
---|
45 | return new DefaultMutableTreeNode(new JLabel(tr("Change")+" "+tr(v.className)+" "+v.name, v.icon, JLabel.HORIZONTAL));
|
---|
46 | }
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.