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 org.netbeans.modules.xml.axi.AXIComponent;
045: import org.netbeans.modules.xml.axi.AXIComponent.ComponentType;
046: import org.netbeans.modules.xml.axi.AXIModel;
047: import org.netbeans.modules.xml.axi.AXIType;
048: import org.netbeans.modules.xml.axi.Attribute;
049: import org.netbeans.modules.xml.schema.model.Attribute.Use;
050: import org.netbeans.modules.xml.schema.model.Form;
051:
052: /**
053: * Proxy attribute, acts on behalf of an Attribute.
054: * Delegates all calls to the original attribute.
055: *
056: * @author Samaresh (Samaresh.Panda@Sun.Com)
057: */
058: public class AttributeProxy extends Attribute implements
059: AXIComponentProxy {
060:
061: /**
062: * Creates a new instance of AttributeProxy
063: */
064: public AttributeProxy(AXIModel model, AXIComponent sharedComponent) {
065: super (model, sharedComponent);
066: }
067:
068: private Attribute getShared() {
069: return (Attribute) getSharedComponent();
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 Attribute 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 type. This is expensive, since it uses a visitor
111: * to traverse to obtain the type information.
112: */
113: public AXIType getType() {
114: return getShared().getType();
115: }
116:
117: /**
118: * Sets the type.
119: */
120: public void setType(AXIType datatype) {
121: getShared().setType(datatype);
122: }
123:
124: /**
125: * Returns the form.
126: */
127: public Form getForm() {
128: return getShared().getForm();
129: }
130:
131: /**
132: * Sets the form.
133: */
134: public void setForm(Form form) {
135: getShared().setForm(form);
136: }
137:
138: /**
139: * Returns the fixed value.
140: */
141: public String getFixed() {
142: return getShared().getFixed();
143: }
144:
145: /**
146: * Sets the fixed value.
147: */
148: public void setFixed(String value) {
149: getShared().setFixed(value);
150: }
151:
152: /**
153: * Returns the default value.
154: */
155: public String getDefault() {
156: return getShared().getDefault();
157: }
158:
159: /**
160: * Sets the default value.
161: */
162: public void setDefault(String value) {
163: getShared().setDefault(value);
164: }
165:
166: /**
167: * Returns the use.
168: */
169: public Use getUse() {
170: return getShared().getUse();
171: }
172:
173: /**
174: * Sets the use.
175: */
176: public void setUse(Use value) {
177: getShared().setUse(value);
178: }
179:
180: /**
181: * Proxy doesn't get refreshed in the UI. We must notify.
182: */
183: void forceFireEvent() {
184: firePropertyChangeEvent(Attribute.PROP_NAME, null, getName());
185: }
186: }
|