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

Last change on this file since 40 was 31, checked in by imi, 19 years ago
  • fixed broken stuff from last checkin
  • complete undo and redo
  • futher simplification in DeleteAction
File size: 1.1 KB
Line 
1package org.openstreetmap.josm.command;
2
3import java.util.Collection;
4
5import org.openstreetmap.josm.data.osm.OsmPrimitive;
6
7/**
8 * A command consisting of a sequenz of other commands. Executes the other commands
9 * and undo them in reverse order.
10 * @author imi
11 */
12public class SequenceCommand implements Command {
13
14 /**
15 * The command sequenz to be executed.
16 */
17 private Command[] sequenz;
18
19 /**
20 * Create the command by specifying the list of commands to execute.
21 * @param sequenz The sequenz that should be executed.
22 */
23 public SequenceCommand(Collection<Command> sequenz) {
24 this.sequenz = new Command[sequenz.size()];
25 this.sequenz = sequenz.toArray(this.sequenz);
26 }
27
28 public void executeCommand() {
29 for (Command c : sequenz)
30 c.executeCommand();
31 }
32
33 public void undoCommand() {
34 for (int i = sequenz.length-1; i >= 0; --i)
35 sequenz[i].undoCommand();
36 }
37
38 public void fillModifiedData(Collection<OsmPrimitive> modified,
39 Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
40 for (Command c : sequenz)
41 c.fillModifiedData(modified, deleted, added);
42 }
43
44}
Note: See TracBrowser for help on using the repository browser.