KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > ui > nodes > SchemaModelFlushWrapper


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
21 package org.netbeans.modules.xml.schema.ui.nodes;
22
23 import java.io.IOException JavaDoc;
24 import java.lang.reflect.InvocationTargetException JavaDoc;
25 import java.util.Enumeration JavaDoc;
26 import org.netbeans.modules.xml.schema.model.SchemaComponent;
27 import org.netbeans.modules.xml.schema.model.SchemaModel;
28 import org.openide.ErrorManager;
29 import org.openide.nodes.Node;
30
31
32 /**
33  * This class provides a wrapper which invokes flush on the schema model
34  * when setValue has been invoked.
35  * @author Chris Webster
36  */

37 public class SchemaModelFlushWrapper extends Node.Property {
38     private Node.Property delegate;
39     private SchemaModel model;
40     
41     public SchemaModelFlushWrapper(SchemaComponent sc, Node.Property delegate) {
42         super(delegate.getValueType());
43         model = sc.getModel();
44         this.delegate = delegate;
45     }
46     
47     @Override JavaDoc
48     public void setValue(Object JavaDoc object) throws IllegalAccessException JavaDoc,
49     IllegalArgumentException JavaDoc, InvocationTargetException JavaDoc {
50         try {
51         model.startTransaction();
52         delegate.setValue(object);
53         }
54         finally {
55             model.endTransaction();
56         }
57     }
58
59     @Override JavaDoc
60     public void restoreDefaultValue() throws IllegalAccessException JavaDoc,
61     InvocationTargetException JavaDoc {
62         try {
63         model.startTransaction();
64         delegate.restoreDefaultValue();
65         }
66         finally {
67             model.endTransaction();
68         }
69     }
70     
71     @Override JavaDoc
72     public boolean equals(Object JavaDoc object) {
73         return delegate.equals(object);
74     }
75
76     @Override JavaDoc
77     public void setExpert(boolean expert) {
78         delegate.setExpert(expert);
79     }
80
81     @Override JavaDoc
82     public void setHidden(boolean hidden) {
83         delegate.setHidden(hidden);
84     }
85
86     @Override JavaDoc
87     public void setPreferred(boolean preferred) {
88         delegate.setPreferred(preferred);
89     }
90
91     @Override JavaDoc
92     public void setShortDescription(String JavaDoc text) {
93         delegate.setShortDescription(text);
94     }
95
96     @Override JavaDoc
97     public Object JavaDoc getValue(String JavaDoc attributeName) {
98         return delegate.getValue(attributeName);
99     }
100
101     @Override JavaDoc
102     public void setDisplayName(String JavaDoc displayName) {
103         delegate.setDisplayName(displayName);
104     }
105
106     @Override JavaDoc
107     public void setName(String JavaDoc name) {
108         delegate.setName(name);
109     }
110
111     @Override JavaDoc
112     public void setValue(String JavaDoc attributeName, Object JavaDoc value) {
113         delegate.setValue(attributeName, value);
114     }
115
116     @Override JavaDoc
117     public String JavaDoc toString() {
118         return delegate.toString();
119     }
120
121     @Override JavaDoc
122     public boolean supportsDefaultValue() {
123         return delegate.supportsDefaultValue();
124     }
125
126     @Override JavaDoc
127     public Object JavaDoc getValue() throws IllegalAccessException JavaDoc,
128     InvocationTargetException JavaDoc {
129         return delegate.getValue();
130     }
131
132     @Override JavaDoc
133     public String JavaDoc getShortDescription() {
134         return delegate.getShortDescription();
135     }
136
137     @Override JavaDoc
138     public java.beans.PropertyEditor JavaDoc getPropertyEditor() {
139         return delegate.getPropertyEditor();
140     }
141
142     @Override JavaDoc
143     public String JavaDoc getName() {
144         return delegate.getName();
145     }
146
147     @Override JavaDoc
148     public String JavaDoc getHtmlDisplayName() {
149         return delegate.getHtmlDisplayName();
150     }
151
152     @Override JavaDoc
153     public String JavaDoc getDisplayName() {
154         return delegate.getDisplayName();
155     }
156     
157     @Override JavaDoc
158     public boolean canWrite() {
159         return delegate.canWrite();
160     }
161
162     @Override JavaDoc
163     public boolean canRead() {
164         return delegate.canRead();
165     }
166
167     @Override JavaDoc
168     public Enumeration JavaDoc<String JavaDoc> attributeNames() {
169         return delegate.attributeNames();
170     }
171    
172     @Override JavaDoc
173     public Class JavaDoc getValueType() {
174         return delegate.getValueType();
175     }
176    
177     @Override JavaDoc
178     public int hashCode() {
179         return delegate.hashCode();
180     }
181
182     @Override JavaDoc
183     public boolean isDefaultValue() {
184         return delegate.isDefaultValue();
185     }
186     
187     @Override JavaDoc
188     public boolean isExpert() {
189         return delegate.isExpert();
190     }
191
192     @Override JavaDoc
193     public boolean isHidden() {
194         return delegate.isHidden();
195     }
196
197     @Override JavaDoc
198     public boolean isPreferred() {
199         return delegate.isPreferred();
200     }
201
202     
203 }
204
Popular Tags