001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.xml.axi.impl;
043:
044: import java.util.List;
045: import org.netbeans.modules.xml.axi.AXIComponent;
046: import org.netbeans.modules.xml.axi.AXIComponent.ComponentType;
047: import org.netbeans.modules.xml.axi.AXIModel;
048: import org.netbeans.modules.xml.axi.AXIType;
049: import org.netbeans.modules.xml.axi.AbstractAttribute;
050: import org.netbeans.modules.xml.axi.AbstractElement;
051: import org.netbeans.modules.xml.axi.Compositor;
052: import org.netbeans.modules.xml.axi.ContentModel;
053: import org.netbeans.modules.xml.axi.Element;
054: import org.netbeans.modules.xml.axi.datatype.Datatype;
055: import org.netbeans.modules.xml.schema.model.Form;
056:
057: /**
058: * Proxy element, acts on behalf of an Element.
059: * Delegates all calls to the original element.
060: *
061: * @author Samaresh (Samaresh.Panda@Sun.Com)
062: */
063: public class ElementProxy extends Element implements AXIComponentProxy {
064:
065: /**
066: * Creates a new instance of ElementProxy
067: */
068: public ElementProxy(AXIModel model, AXIComponent sharedComponent) {
069: super (model, sharedComponent);
070: }
071:
072: /**
073: * Returns the type of this component,
074: * may be local, shared, proxy or reference.
075: * @see ComponentType.
076: */
077: public ComponentType getComponentType() {
078: return ComponentType.PROXY;
079: }
080:
081: /**
082: * Returns true if it is a reference, false otherwise.
083: */
084: public boolean isReference() {
085: return getShared().isReference();
086: }
087:
088: /**
089: * Returns the referent if isReference() is true.
090: */
091: public Element getReferent() {
092: return getShared().getReferent();
093: }
094:
095: /**
096: * Returns the name.
097: */
098: public String getName() {
099: return getShared().getName();
100: }
101:
102: /**
103: * Sets the name.
104: */
105: public void setName(String name) {
106: getShared().setName(name);
107: }
108:
109: /**
110: * Returns the MinOccurs.
111: */
112: public String getMinOccurs() {
113: return getShared().getMinOccurs();
114: }
115:
116: /**
117: * Sets the MinOccurs.
118: */
119: public void setMinOccurs(String value) {
120: getShared().setMinOccurs(value);
121: }
122:
123: /**
124: * Returns the MaxOccurs.
125: */
126: public String getMaxOccurs() {
127: return getShared().getMaxOccurs();
128: }
129:
130: /**
131: * Sets the MaxOccurs.
132: */
133: public void setMaxOccurs(String value) {
134: getShared().setMaxOccurs(value);
135: }
136:
137: /**
138: * Returns abstract property.
139: */
140: public boolean getAbstract() {
141: return getShared().getAbstract();
142: }
143:
144: /**
145: * Sets the abstract property.
146: */
147: public void setAbstract(boolean value) {
148: getShared().setAbstract(value);
149: }
150:
151: /**
152: * Returns the block.
153: */
154: public String getBlock() {
155: return getShared().getBlock();
156: }
157:
158: /**
159: * Sets the block property.
160: */
161: public void setBlock(String value) {
162: getShared().setBlock(value);
163: }
164:
165: /**
166: * Returns the final property.
167: */
168: public String getFinal() {
169: return getShared().getFinal();
170: }
171:
172: /**
173: * Sets the final property.
174: */
175: public void setFinal(String value) {
176: getShared().setFinal(value);
177: }
178:
179: /**
180: * Returns the fixed value.
181: */
182: public String getFixed() {
183: return getShared().getFixed();
184: }
185:
186: /**
187: * Sets the fixed value.
188: */
189: public void setFixed(String value) {
190: getShared().setFixed(value);
191: }
192:
193: /**
194: * Returns the default value.
195: */
196: public String getDefault() {
197: return getShared().getDefault();
198: }
199:
200: /**
201: * Sets the default value.
202: */
203: public void setDefault(String value) {
204: getShared().setDefault(value);
205: }
206:
207: /**
208: * Returns the form.
209: */
210: public Form getForm() {
211: return getShared().getForm();
212: }
213:
214: /**
215: * Sets the form.
216: */
217: public void setForm(Form value) {
218: getShared().setForm(value);
219: }
220:
221: /**
222: * Returns the nillable.
223: */
224: public boolean getNillable() {
225: return getShared().getNillable();
226: }
227:
228: /**
229: * Sets the nillable property.
230: */
231: public void setNillable(boolean value) {
232: getShared().setNillable(value);
233: }
234:
235: /**
236: * Adds a Compositor as its child.
237: * Compositor must always be at the 0th index.
238: */
239: public void addCompositor(Compositor compositor) {
240: getShared().addCompositor(compositor);
241: }
242:
243: /**
244: * Removes a Compositor.
245: */
246: public void removeCompositor(Compositor compositor) {
247: getShared().removeCompositor(compositor);
248: }
249:
250: /**
251: * Adds an Element as its child.
252: * If attributes exist, add the new child before all attributes.
253: * Attributes must always be added at the end of the list.
254: */
255: public void addElement(AbstractElement child) {
256: getShared().addElement(child);
257: }
258:
259: /**
260: * Removes an Element.
261: */
262: public void removeElement(AbstractElement element) {
263: getShared().removeElement(element);
264: }
265:
266: /**
267: * Adds an attribute.
268: */
269: public void addAttribute(AbstractAttribute attribute) {
270: getShared().addAttribute(attribute);
271: }
272:
273: /**
274: * Removes an attribute.
275: */
276: public void removeAttribute(AbstractAttribute attribute) {
277: getShared().removeAttribute(attribute);
278: }
279:
280: /**
281: * gets the type of this element.
282: */
283: public AXIType getType() {
284: return getShared().getType();
285: }
286:
287: /**
288: * sets the type of this element.
289: */
290: public void setType(AXIType type) {
291: getShared().setType(type);
292: }
293:
294: /**
295: * Returns the compositor.
296: */
297: public Compositor getCompositor() {
298: return getShared().getCompositor();
299: }
300:
301: Element getShared() {
302: return (Element) getSharedComponent();
303: }
304:
305: /**
306: * Proxy doesn't get refreshed in the UI. We must notify.
307: */
308: void forceFireEvent() {
309: firePropertyChangeEvent(Element.PROP_NAME, null, getName());
310: }
311: }
|