1 19 20 package org.netbeans.editor; 21 22 import javax.swing.event.DocumentEvent ; 23 import javax.swing.text.BadLocationException ; 24 import javax.swing.undo.CannotUndoException ; 25 import javax.swing.undo.CannotRedoException ; 26 27 33 34 public class GuardedDocumentEvent extends BaseDocumentEvent { 35 36 static final long serialVersionUID =-9204897347010955248L; 37 38 public GuardedDocumentEvent(GuardedDocument doc, int offset, int length, 39 DocumentEvent.EventType type) { 40 super(doc, offset, length, type); 41 } 42 43 public void undo() throws CannotUndoException { 44 GuardedDocument gdoc = (GuardedDocument)getDocument(); 45 boolean origBreak = gdoc.breakGuarded; 46 gdoc.breakGuarded = true; 47 super.undo(); 48 if (!origBreak) { 49 gdoc.breakGuarded = false; 50 } 51 } 52 53 public void redo() throws CannotRedoException { 54 GuardedDocument gdoc = (GuardedDocument)getDocument(); 55 boolean origBreak = gdoc.breakGuarded; 56 super.redo(); 57 if (!origBreak) { 58 gdoc.breakGuarded = false; 59 } 60 } 61 62 } 63 | Popular Tags |