1 21 22 package org.armedbear.j; 23 24 import javax.swing.undo.CompoundEdit ; 25 import javax.swing.undo.UndoableEdit ; 26 27 public final class UndoManager extends javax.swing.undo.UndoManager 28 { 29 public synchronized void undo() 30 { 31 UndoableEdit edit = editToBeUndone(); 32 super.undo(); 33 if (edit instanceof UndoBoundary) 34 super.undo(); 35 } 36 37 public synchronized void redo() 38 { 39 UndoableEdit edit = editToBeRedone(); 40 super.redo(); 41 if (edit instanceof UndoBoundary) 42 super.redo(); 43 } 44 45 public void appendUndoFold(Editor editor) 46 { 47 if (edits.size() > 0) { 48 UndoFold undoFold = new UndoFold(editor); 49 UndoableEdit lastEdit = (UndoableEdit ) edits.remove(edits.size()-1); 50 CompoundEdit compoundEdit = new CompoundEdit (); 51 compoundEdit.addEdit(lastEdit); 52 compoundEdit.addEdit(undoFold); 53 compoundEdit.end(); 54 edits.add(compoundEdit); 55 } 56 } 57 } 58 | Popular Tags |