1
package org.herac.tuxguitar.gui.undo.undoables;
3
import java.util.ArrayList;
6
import org.herac.tuxguitar.gui.undo.CannotRedoException;
7
import org.herac.tuxguitar.gui.undo.CannotUndoException;
8
import org.herac.tuxguitar.gui.undo.UndoableEdit;
10
public class UndoableJoined implements UndoableEdit{
12
private UndoableCaretHelper undoCaret;
13
private UndoableCaretHelper redoCaret;
14
private List undoables;
16
public UndoableJoined(){
17
this.doAction = UNDO_ACTION;
18
this.undoCaret = new UndoableCaretHelper();
19
this.undoables = new ArrayList();
22
public void addUndoableEdit(UndoableEdit undoable){
23
this.undoables.add(undoable);
26
public void redo() throws CannotRedoException {
27
int count = this.undoables.size();
28
for(int i = 0;i < count;i++){
29
UndoableEdit undoable = (UndoableEdit)this.undoables.get(i);
32
this.redoCaret.update();
33
this.doAction = UNDO_ACTION;
36
public void undo() throws CannotUndoException {
37
int count = this.undoables.size();
38
for(int i = (count - 1);i >= 0;i--){
39
UndoableEdit undoable = (UndoableEdit)this.undoables.get(i);
42
this.undoCaret.update();
43
this.doAction = REDO_ACTION;
46
public boolean canRedo() {
47
return (this.doAction == REDO_ACTION);
50
public boolean canUndo() {
51
return (this.doAction == UNDO_ACTION);
54
public UndoableJoined endUndo(){
55
this.redoCaret = new UndoableCaretHelper();