KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xam > ui > undo > FilterUndoableEdit


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.xam.ui.undo;
21
22 import javax.swing.undo.CannotRedoException JavaDoc;
23 import javax.swing.undo.CannotUndoException JavaDoc;
24 import javax.swing.undo.UndoableEdit JavaDoc;
25
26 /**
27  * Generic undoable edit that delegates to the given undoable edit.
28  */

29 public class FilterUndoableEdit implements UndoableEdit JavaDoc {
30     protected UndoableEdit JavaDoc delegate;
31
32     // Copied from CloneableEditorSupport in openide/text
33

34     FilterUndoableEdit() {
35     }
36
37     public void undo() throws CannotUndoException JavaDoc {
38         if (delegate != null) {
39             delegate.undo();
40         }
41     }
42
43     public boolean canUndo() {
44         if (delegate != null) {
45             return delegate.canUndo();
46         } else {
47             return false;
48         }
49     }
50
51     public void redo() throws CannotRedoException JavaDoc {
52         if (delegate != null) {
53             delegate.redo();
54         }
55     }
56
57     public boolean canRedo() {
58         if (delegate != null) {
59             return delegate.canRedo();
60         } else {
61             return false;
62         }
63     }
64
65     public void die() {
66         if (delegate != null) {
67             delegate.die();
68         }
69     }
70
71     public boolean addEdit(UndoableEdit JavaDoc anEdit) {
72         if (delegate != null) {
73             return delegate.addEdit(anEdit);
74         } else {
75             return false;
76         }
77     }
78
79     public boolean replaceEdit(UndoableEdit JavaDoc anEdit) {
80         if (delegate != null) {
81             return delegate.replaceEdit(anEdit);
82         } else {
83             return false;
84         }
85     }
86
87     public boolean isSignificant() {
88         if (delegate != null) {
89             return delegate.isSignificant();
90         } else {
91             return true;
92         }
93     }
94
95     public String JavaDoc getPresentationName() {
96         if (delegate != null) {
97             return delegate.getPresentationName();
98         } else {
99             return ""; // NOI18N
100
}
101     }
102
103     public String JavaDoc getUndoPresentationName() {
104         if (delegate != null) {
105             return delegate.getUndoPresentationName();
106         } else {
107             return ""; // NOI18N
108
}
109     }
110
111     public String JavaDoc getRedoPresentationName() {
112         if (delegate != null) {
113             return delegate.getRedoPresentationName();
114         } else {
115             return ""; // NOI18N
116
}
117     }
118 }
119
Popular Tags