01: /*
02: * Sun Public License Notice
03: *
04: * The contents of this file are subject to the Sun Public License
05: * Version 1.0 (the "License"). You may not use this file except in
06: * compliance with the License. A copy of the License is available at
07: * http://www.sun.com/
08: *
09: * The Original Code is NetBeans. The Initial Developer of the Original
10: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
11: * Microsystems, Inc. All Rights Reserved.
12: */
13:
14: package org.netbeans.editor;
15:
16: import javax.swing.event.DocumentEvent;
17: import javax.swing.undo.CannotRedoException;
18: import javax.swing.undo.CannotUndoException;
19:
20: /**
21: * Attempt to insert or remove from the guarded block has been done.
22: *
23: * @version 1.0
24: * @author Miloslav Metelka
25: */
26:
27: public class GuardedDocumentEvent extends BaseDocumentEvent {
28:
29: static final long serialVersionUID = -9204897347010955248L;
30:
31: public GuardedDocumentEvent(GuardedDocument doc, int offset,
32: int length, DocumentEvent.EventType type) {
33: super (doc, offset, length, type);
34: }
35:
36: public void undo() throws CannotUndoException {
37: GuardedDocument gdoc = (GuardedDocument) getDocument();
38: boolean origBreak = gdoc.breakGuarded;
39: gdoc.breakGuarded = true;
40: super .undo();
41: if (!origBreak) {
42: gdoc.breakGuarded = false;
43: }
44: }
45:
46: public void redo() throws CannotRedoException {
47: GuardedDocument gdoc = (GuardedDocument) getDocument();
48: boolean origBreak = gdoc.breakGuarded;
49: super .redo();
50: if (!origBreak) {
51: gdoc.breakGuarded = false;
52: }
53: }
54:
55: }
|