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

Last change on this file since 100 was 100, checked in by imi, 18 years ago
  • fixed JOSM crash when importing GeoImages on layers without timestamp
  • fixed merging: incomplete segments do not overwrite complete on ways
  • fixed focus when entering the popups from PropertyDialog
  • fixed broken "draw lines between gps points"
  • added doubleclick on bookmarklist
  • added background color configuration
  • added GpxImport to import 1.0 and 1.1 GPX files

This is release JOSM 1.3

File size: 1.5 KB
Line 
1package org.openstreetmap.josm.command;
2
3import java.util.Collection;
4
5import javax.swing.tree.DefaultMutableTreeNode;
6import javax.swing.tree.MutableTreeNode;
7
8import org.openstreetmap.josm.data.osm.OsmPrimitive;
9
10/**
11 * A command consisting of a sequenz of other commands. Executes the other commands
12 * and undo them in reverse order.
13 * @author imi
14 */
15public class SequenceCommand extends Command {
16
17 /**
18 * The command sequenz to be executed.
19 */
20 private Command[] sequence;
21 private final String name;
22
23 /**
24 * Create the command by specifying the list of commands to execute.
25 * @param sequenz The sequenz that should be executed.
26 */
27 public SequenceCommand(String name, Collection<Command> sequenz) {
28 this.name = name;
29 this.sequence = new Command[sequenz.size()];
30 this.sequence = sequenz.toArray(this.sequence);
31 }
32
33 @Override public void executeCommand() {
34 for (Command c : sequence)
35 c.executeCommand();
36 }
37
38 @Override public void undoCommand() {
39 for (int i = sequence.length-1; i >= 0; --i)
40 sequence[i].undoCommand();
41 }
42
43 @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
44 for (Command c : sequence)
45 c.fillModifiedData(modified, deleted, added);
46 }
47
48 @Override public MutableTreeNode description() {
49 DefaultMutableTreeNode root = new DefaultMutableTreeNode("Sequence: "+name);
50 for (Command c : sequence)
51 root.add(c.description());
52 return root;
53 }
54}
Note: See TracBrowser for help on using the repository browser.