1 15 16 package swingwtx.swing.undo; 17 18 24 public class AbstractUndoableEdit implements UndoableEdit 25 { 26 27 private boolean alive = true; 28 29 private boolean completed = true; 30 31 public AbstractUndoableEdit() 32 { 33 super(); 34 } 35 36 public void undo() throws CannotUndoException 37 { 38 if (!canUndo()) 39 throw new CannotUndoException(); 40 completed = false; 41 } 42 public void redo() throws CannotRedoException 43 { 44 if (!canRedo()) 45 throw new CannotRedoException(); 46 completed = true; 47 } 48 49 50 public void die() 51 { 52 alive = false; 53 } 54 55 public boolean canUndo() 56 { 57 return completed && alive; 58 } 59 60 public boolean canRedo() 61 { 62 return !completed && alive; 63 } 64 65 protected static final String UndoName = "Undo"; 66 protected static final String RedoName = "Redo"; 67 68 public String getUndoPresentationName() 69 { 70 return UndoName; 71 } 72 73 public String getRedoPresentationName() 74 { 75 return RedoName; 76 } 77 78 79 public boolean addEdit(UndoableEdit anEdit) { return false; } 80 public boolean replaceEdit(UndoableEdit anEdit) { return false; } 81 public boolean isSignificant() { return false; } 82 public String getPresentationName() { return ""; } 83 } 84 | Popular Tags |