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.visualweb.faces.dt_1_1.component;
043:
044: import java.beans.IntrospectionException;
045: import java.beans.PropertyDescriptor;
046: import java.util.Locale;
047: import java.util.List;
048: import java.util.ArrayList;
049: import java.util.Arrays;
050: import java.util.ResourceBundle;
051:
052: import com.sun.rave.designtime.CategoryDescriptor;
053: import com.sun.rave.designtime.Constants;
054: import com.sun.rave.designtime.faces.FacetDescriptor;
055: import com.sun.rave.designtime.markup.AttributeDescriptor;
056:
057: import org.netbeans.modules.visualweb.faces.dt.HtmlBeanInfoBase;
058: import org.netbeans.modules.visualweb.faces.dt.PropertyDescriptorBase;
059:
060: public abstract class UIComponentBeanInfoBase extends HtmlBeanInfoBase {
061:
062: protected static ResourceBundle resources = ResourceBundle
063: .getBundle(
064: "org.netbeans.modules.visualweb.faces.dt_1_1.component.Bundle",
065: Locale.getDefault(), UIComponentBeanInfoBase.class
066: .getClassLoader());
067:
068: protected CategoryDescriptor[] getCategoryDescriptors() {
069: return com.sun.rave.designtime.base.CategoryDescriptors
070: .getDefaultCategoryDescriptors();
071: }
072:
073: protected FacetDescriptor[] facetDescriptors;
074:
075: public FacetDescriptor[] getFacetDescriptors() {
076: if (facetDescriptors != null)
077: return facetDescriptors;
078: facetDescriptors = new FacetDescriptor[0];
079: return facetDescriptors;
080: }
081:
082: private PropertyDescriptor[] propertyDescriptors;
083:
084: public PropertyDescriptor[] getPropertyDescriptors() {
085: if (propertyDescriptors != null) {
086: return propertyDescriptors;
087: }
088: AttributeDescriptor attrib = null;
089:
090: try {
091:
092: PropertyDescriptor prop_attributes = new PropertyDescriptorBase(
093: "attributes", beanClass, "getAttributes", null);
094: prop_attributes.setDisplayName(resources
095: .getString("UIComponent_attributes_DisplayName"));
096: prop_attributes.setShortDescription(resources
097: .getString("UIComponent_attributes_Description"));
098: prop_attributes.setExpert(false);
099: prop_attributes.setHidden(true);
100: prop_attributes.setPreferred(false);
101: prop_attributes
102: .setValue(
103: Constants.PropertyDescriptor.CATEGORY,
104: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
105:
106: PropertyDescriptor prop_childCount = new PropertyDescriptorBase(
107: "childCount", beanClass, "getChildCount", null);
108: prop_childCount.setDisplayName(resources
109: .getString("UIComponent_childCount_DisplayName"));
110: prop_childCount.setShortDescription(resources
111: .getString("UIComponent_childCount_Description"));
112: prop_childCount.setExpert(false);
113: prop_childCount.setHidden(true);
114: prop_childCount.setPreferred(false);
115: prop_childCount
116: .setValue(
117: Constants.PropertyDescriptor.CATEGORY,
118: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
119:
120: PropertyDescriptor prop_children = new PropertyDescriptorBase(
121: "children", beanClass, "getChildren", null);
122: prop_children.setDisplayName(resources
123: .getString("UIComponent_children_DisplayName"));
124: prop_children.setShortDescription(resources
125: .getString("UIComponent_children_Description"));
126: prop_children.setExpert(false);
127: prop_children.setHidden(true);
128: prop_children.setPreferred(false);
129: prop_children
130: .setValue(
131: Constants.PropertyDescriptor.CATEGORY,
132: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
133:
134: PropertyDescriptor prop_facets = new PropertyDescriptorBase(
135: "facets", beanClass, "getFacets", null);
136: prop_facets.setDisplayName(resources
137: .getString("UIComponent_facets_DisplayName"));
138: prop_facets.setShortDescription(resources
139: .getString("UIComponent_facets_Description"));
140: prop_facets.setExpert(false);
141: prop_facets.setHidden(true);
142: prop_facets.setPreferred(false);
143: prop_facets
144: .setValue(
145: Constants.PropertyDescriptor.CATEGORY,
146: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
147:
148: PropertyDescriptor prop_family = new PropertyDescriptorBase(
149: "family", beanClass, "getFamily", null);
150: prop_family.setDisplayName(resources
151: .getString("UIComponent_family_DisplayName"));
152: prop_family.setShortDescription(resources
153: .getString("UIComponent_family_Description"));
154: prop_family.setExpert(false);
155: prop_family.setHidden(true);
156: prop_family.setPreferred(false);
157: prop_family
158: .setValue(
159: Constants.PropertyDescriptor.CATEGORY,
160: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
161:
162: PropertyDescriptor prop_id = new PropertyDescriptorBase(
163: "id", beanClass, "getId", "setId");
164: prop_id.setDisplayName(resources
165: .getString("UIComponent_id_DisplayName"));
166: prop_id.setShortDescription(resources
167: .getString("UIComponent_id_Description"));
168: prop_id.setExpert(false);
169: prop_id.setHidden(true);
170: prop_id.setPreferred(false);
171: attrib = new AttributeDescriptor("id", false, null, true);
172: prop_id.setValue(
173: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
174: attrib);
175: prop_id
176: .setValue(
177: Constants.PropertyDescriptor.CATEGORY,
178: com.sun.rave.designtime.base.CategoryDescriptors.GENERAL);
179:
180: PropertyDescriptor prop_parent = new PropertyDescriptorBase(
181: "parent", beanClass, "getParent", null);
182: prop_parent.setDisplayName(resources
183: .getString("UIComponent_parent_DisplayName"));
184: prop_parent.setShortDescription(resources
185: .getString("UIComponent_parent_Description"));
186: prop_parent.setExpert(false);
187: prop_parent.setHidden(true);
188: prop_parent.setPreferred(false);
189: prop_parent
190: .setValue(
191: Constants.PropertyDescriptor.CATEGORY,
192: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
193:
194: PropertyDescriptor prop_rendered = new PropertyDescriptorBase(
195: "rendered", beanClass, "isRendered", "setRendered");
196: prop_rendered.setDisplayName(resources
197: .getString("UIComponent_rendered_DisplayName"));
198: prop_rendered.setShortDescription(resources
199: .getString("UIComponent_rendered_Description"));
200: prop_rendered.setExpert(false);
201: prop_rendered.setHidden(false);
202: prop_rendered.setPreferred(false);
203: attrib = new AttributeDescriptor("rendered", false, null,
204: true);
205: prop_rendered.setValue(
206: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
207: attrib);
208: prop_rendered
209: .setValue(
210: Constants.PropertyDescriptor.CATEGORY,
211: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
212:
213: PropertyDescriptor prop_rendererType = new PropertyDescriptorBase(
214: "rendererType", beanClass, "getRendererType",
215: "setRendererType");
216: prop_rendererType.setDisplayName(resources
217: .getString("UIComponent_rendererType_DisplayName"));
218: prop_rendererType.setShortDescription(resources
219: .getString("UIComponent_rendererType_Description"));
220: prop_rendererType.setExpert(false);
221: prop_rendererType.setHidden(true);
222: prop_rendererType.setPreferred(false);
223: prop_rendererType
224: .setValue(
225: Constants.PropertyDescriptor.CATEGORY,
226: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
227:
228: PropertyDescriptor prop_rendersChildren = new PropertyDescriptorBase(
229: "rendersChildren", beanClass, "getRendersChildren",
230: null);
231: prop_rendersChildren
232: .setDisplayName(resources
233: .getString("UIComponent_rendersChildren_DisplayName"));
234: prop_rendersChildren
235: .setShortDescription(resources
236: .getString("UIComponent_rendersChildren_Description"));
237: prop_rendersChildren.setExpert(false);
238: prop_rendersChildren.setHidden(true);
239: prop_rendersChildren.setPreferred(false);
240: prop_rendersChildren
241: .setValue(
242: Constants.PropertyDescriptor.CATEGORY,
243: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
244:
245: List<PropertyDescriptor> propertyDescriptorList = new ArrayList<PropertyDescriptor>();
246: propertyDescriptorList.add(prop_attributes);
247: propertyDescriptorList.add(prop_childCount);
248: propertyDescriptorList.add(prop_children);
249: propertyDescriptorList.add(prop_facets);
250: propertyDescriptorList.add(prop_family);
251: propertyDescriptorList.add(prop_id);
252: propertyDescriptorList.add(prop_parent);
253: propertyDescriptorList.add(prop_rendered);
254: propertyDescriptorList.add(prop_rendererType);
255: propertyDescriptorList.add(prop_rendersChildren);
256:
257: propertyDescriptorList.addAll(Arrays.asList(super
258: .getPropertyDescriptors()));
259: propertyDescriptors = propertyDescriptorList
260: .toArray(new PropertyDescriptor[propertyDescriptorList
261: .size()]);
262: return propertyDescriptors;
263:
264: } catch (IntrospectionException e) {
265: e.printStackTrace();
266: return null;
267: }
268:
269: }
270:
271: }
|