source: josm/src/org/openstreetmap/josm/command/AddCommand.java@ 40

Last change on this file since 40 was 40, checked in by imi, 18 years ago
  • added world boundaries
  • added bug report exception handler
  • raw gps/real data when open depends now on extension
File size: 1.1 KB
Line 
1package org.openstreetmap.josm.command;
2
3import java.util.Collection;
4
5import org.openstreetmap.josm.data.osm.DataSet;
6import org.openstreetmap.josm.data.osm.OsmPrimitive;
7import org.openstreetmap.josm.data.osm.visitor.AddVisitor;
8import org.openstreetmap.josm.data.osm.visitor.DeleteVisitor;
9
10/**
11 * A command that adds an osm primitive to a dataset. Keys cannot be added this
12 * way. Use ChangeKeyValueCommand instead.
13 *
14 * @author imi
15 */
16public class AddCommand implements Command {
17
18 /**
19 * The dataset this command operates on.
20 */
21 private DataSet ds;
22
23 /**
24 * The primitive to add to the dataset.
25 */
26 private final OsmPrimitive osm;
27
28 /**
29 * Create the command and specify the element to add.
30 */
31 public AddCommand(DataSet ds, OsmPrimitive osm) {
32 this.ds = ds;
33 this.osm = osm;
34 }
35
36 public void executeCommand() {
37 osm.visit(new AddVisitor(ds));
38 }
39
40 public void undoCommand() {
41 osm.visit(new DeleteVisitor(ds));
42 }
43
44 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
45 added.add(osm);
46 }
47}
Note: See TracBrowser for help on using the repository browser.