Changeset 630 in josm for trunk/src/org/openstreetmap/josm/command/SequenceCommand.java
- Timestamp:
- 2008-05-11T01:59:46+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/SequenceCommand.java
r627 r630 10 10 import javax.swing.tree.MutableTreeNode; 11 11 12 import org.openstreetmap.josm.Main; 12 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 14 … … 23 24 */ 24 25 private Command[] sequence; 26 private boolean sequence_complete; 25 27 private final String name; 28 public boolean continueOnError = false; 26 29 27 30 /** … … 42 45 } 43 46 44 @Override public void executeCommand() { 45 for (Command c : sequence) 46 c.executeCommand(); 47 public int executed_commands = 0; 48 @Override public boolean executeCommand() { 49 for (int i=0; i < sequence.length; i++) { 50 Command c = sequence[i]; 51 boolean result = c.executeCommand(); 52 if (!result) 53 Main.debug("SequenceCommand, executing command[" + i + "] " + c + " result: " + result); 54 if (!result && !continueOnError) { 55 this.undoCommands(i-1); 56 return false; 57 } 58 } 59 sequence_complete = true; 60 return true; 61 } 62 63 private void undoCommands(int start) { 64 // We probably aborted this halfway though the 65 // execution sequence because of a sub-command 66 // error. We already undid the sub-commands. 67 if (!sequence_complete) 68 return; 69 for (int i = start; i >= 0; --i) 70 sequence[i].undoCommand(); 47 71 } 48 72 49 73 @Override public void undoCommand() { 50 for (int i = sequence.length-1; i >= 0; --i) 51 sequence[i].undoCommand(); 74 this.undoCommands(sequence.length-1); 52 75 } 53 76
Note:
See TracChangeset
for help on using the changeset viewer.