001: //GEN-BEGIN:BeanInfo
002: /*
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
004: *
005: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
006: *
007: * The contents of this file are subject to the terms of either the GNU
008: * General Public License Version 2 only ("GPL") or the Common
009: * Development and Distribution License("CDDL") (collectively, the
010: * "License"). You may not use this file except in compliance with the
011: * License. You can obtain a copy of the License at
012: * http://www.netbeans.org/cddl-gplv2.html
013: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
014: * specific language governing permissions and limitations under the
015: * License. When distributing the software, include this License Header
016: * Notice in each file and include the License file at
017: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
018: * particular file as subject to the "Classpath" exception as provided
019: * by Sun in the GPL Version 2 section of the License file that
020: * accompanied this code. If applicable, add the following below the
021: * License Header, with the fields enclosed by brackets [] replaced by
022: * your own identifying information:
023: * "Portions Copyrighted [year] [name of copyright owner]"
024: *
025: * Contributor(s):
026: *
027: * The Original Software is NetBeans. The Initial Developer of the Original
028: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
029: * Microsystems, Inc. All Rights Reserved.
030: *
031: * If you wish your version of this file to be governed by only the CDDL
032: * or only the GPL Version 2, indicate your decision by adding
033: * "[Contributor] elects to include this software in this distribution
034: * under the [CDDL or GPL Version 2] license." If you do not indicate a
035: * single choice of license, a recipient has the option to distribute
036: * your version of this file under either the CDDL, the GPL Version 2 or
037: * to extend the choice of license to its licensees as provided above.
038: * However, if you add GPL Version 2 code and therefore, elected the GPL
039: * Version 2 license, then the option applies only if the new code is
040: * made subject to such option by the copyright holder.
041: */
042: package org.netbeans.modules.visualweb.dataprovider.designtime.impl;
043:
044: import java.awt.Image;
045: import java.beans.BeanDescriptor;
046: import java.beans.BeanInfo;
047: import java.beans.IntrospectionException;
048: import java.beans.PropertyDescriptor;
049: import java.util.Locale;
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 java.beans.SimpleBeanInfo;
058:
059: /**
060: * <p>Auto-generated design time metadata class.
061: * Do <strong>NOT</strong> modify; all changes
062: * <strong>will</strong> be lost!</p>
063: */
064:
065: abstract class ObjectDataProviderBeanInfoBase extends SimpleBeanInfo {
066:
067: protected static ResourceBundle resources = ResourceBundle
068: .getBundle(
069: "org.netbeans.modules.visualweb.dataprovider.designtime.impl.Bundle-JSF",
070: Locale.getDefault(),
071: ObjectDataProviderBeanInfoBase.class
072: .getClassLoader());
073:
074: /**
075: * <p>Construct a new <code>ObjectDataProviderBeanInfoBase</code>.</p>
076: */
077: public ObjectDataProviderBeanInfoBase() {
078:
079: beanClass = com.sun.data.provider.impl.ObjectDataProvider.class;
080: iconFileName_C16 = "/org/netbeans/modules/visualweb/dataprovider/designtime/impl/ObjectDataProvider_C16";
081: iconFileName_C32 = "/org/netbeans/modules/visualweb/dataprovider/designtime/impl/ObjectDataProvider_C32";
082: iconFileName_M16 = "/org/netbeans/modules/visualweb/dataprovider/designtime/impl/ObjectDataProvider_M16";
083: iconFileName_M32 = "/org/netbeans/modules/visualweb/dataprovider/designtime/impl/ObjectDataProvider_M32";
084:
085: }
086:
087: /**
088: * <p>The bean class that this BeanInfo represents.
089: */
090: protected Class beanClass;
091:
092: /**
093: * <p>The cached BeanDescriptor.</p>
094: */
095: protected BeanDescriptor beanDescriptor;
096:
097: /**
098: * <p>The index of the default property.</p>
099: */
100: protected int defaultPropertyIndex = -2;
101:
102: /**
103: * <p>The name of the default property.</p>
104: */
105: protected String defaultPropertyName;
106:
107: /**
108: * <p>The 16x16 color icon.</p>
109: */
110: protected String iconFileName_C16;
111:
112: /**
113: * <p>The 32x32 color icon.</p>
114: */
115: protected String iconFileName_C32;
116:
117: /**
118: * <p>The 16x16 monochrome icon.</p>
119: */
120: protected String iconFileName_M16;
121:
122: /**
123: * <p>The 32x32 monochrome icon.</p>
124: */
125: protected String iconFileName_M32;
126:
127: /**
128: * <p>The cached property descriptors.</p>
129: */
130: protected PropertyDescriptor[] propDescriptors;
131:
132: /**
133: * <p>Return the <code>BeanDescriptor</code> for this bean.</p>
134: */
135: public BeanDescriptor getBeanDescriptor() {
136:
137: if (beanDescriptor != null) {
138: return beanDescriptor;
139: }
140:
141: beanDescriptor = new BeanDescriptor(beanClass);
142: beanDescriptor.setDisplayName(resources
143: .getString("ObjectDataProvider_DisplayName"));
144: beanDescriptor.setShortDescription(resources
145: .getString("ObjectDataProvider_Description"));
146: beanDescriptor.setExpert(false);
147: beanDescriptor.setHidden(false);
148: beanDescriptor.setPreferred(false);
149: beanDescriptor.setValue(
150: Constants.BeanDescriptor.FACET_DESCRIPTORS,
151: getFacetDescriptors());
152: beanDescriptor.setValue(Constants.BeanDescriptor.INSTANCE_NAME,
153: "objectDataProvider");
154: beanDescriptor.setValue(Constants.BeanDescriptor.IS_CONTAINER,
155: Boolean.TRUE);
156: beanDescriptor.setValue(
157: Constants.BeanDescriptor.PROPERTY_CATEGORIES,
158: getCategoryDescriptors());
159:
160: return beanDescriptor;
161:
162: }
163:
164: /**
165: * <p>Return the <code>CategoryDescriptor</code> array for the property categories of this component.</p>
166: */
167: private CategoryDescriptor[] getCategoryDescriptors() {
168:
169: return com.sun.rave.designtime.base.CategoryDescriptors
170: .getDefaultCategoryDescriptors();
171:
172: }
173:
174: /**
175: * <p>Return the index of the default property, or
176: * -1 if there is no default property.</p>
177: */
178: public int getDefaultPropertyIndex() {
179:
180: if (defaultPropertyIndex > -2) {
181: return defaultPropertyIndex;
182: } else {
183: if (defaultPropertyName == null) {
184: defaultPropertyIndex = -1;
185: } else {
186: PropertyDescriptor pd[] = getPropertyDescriptors();
187: for (int i = 0; i < pd.length; i++) {
188: if (defaultPropertyName.equals(pd[i].getName())) {
189: defaultPropertyIndex = i;
190: break;
191: }
192: }
193: }
194: }
195: return defaultPropertyIndex;
196: }
197:
198: /**
199: * <p>The cached facet descriptors.</p>
200: */
201: protected FacetDescriptor[] facetDescriptors;
202:
203: /**
204: * <p>Return the <code>FacetDescriptor</code>s for this bean.</p>
205: */
206: public FacetDescriptor[] getFacetDescriptors() {
207:
208: if (facetDescriptors != null) {
209: return facetDescriptors;
210: }
211: facetDescriptors = new FacetDescriptor[] {};
212: return facetDescriptors;
213:
214: }
215:
216: /**
217: * <p>Return the specified image (if any)
218: * for this component class.</p>
219: */
220: public Image getIcon(int kind) {
221:
222: String name;
223: switch (kind) {
224: case ICON_COLOR_16x16:
225: name = iconFileName_C16;
226: break;
227: case ICON_COLOR_32x32:
228: name = iconFileName_C32;
229: break;
230: case ICON_MONO_16x16:
231: name = iconFileName_M16;
232: break;
233: case ICON_MONO_32x32:
234: name = iconFileName_M32;
235: break;
236: default:
237: name = null;
238: break;
239: }
240: if (name == null) {
241: return null;
242: }
243:
244: Image image = loadImage(name + ".png");
245: if (image == null) {
246: image = loadImage(name + ".gif");
247: }
248: return image;
249:
250: }
251:
252: /**
253: * <p>Return a class loaded by name via the class loader that loaded this class.</p>
254: */
255: private java.lang.Class loadClass(java.lang.String name) {
256:
257: try {
258: return Class.forName(name);
259: } catch (ClassNotFoundException e) {
260: throw new RuntimeException(e);
261: }
262:
263: }
264:
265: /**
266: * <p>Return the <code>PropertyDescriptor</code>s for this bean.</p>
267: */
268: public PropertyDescriptor[] getPropertyDescriptors() {
269:
270: if (propDescriptors != null) {
271: return propDescriptors;
272: }
273: AttributeDescriptor attrib = null;
274:
275: try {
276:
277: PropertyDescriptor prop_class = new PropertyDescriptor(
278: "class", beanClass, "getClass", null);
279: prop_class.setDisplayName(resources
280: .getString("ObjectDataProvider_class_DisplayName"));
281: prop_class.setShortDescription(resources
282: .getString("ObjectDataProvider_class_Description"));
283: prop_class.setExpert(false);
284: prop_class.setHidden(true);
285: prop_class.setPreferred(false);
286: prop_class
287: .setValue(
288: Constants.PropertyDescriptor.CATEGORY,
289: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
290:
291: PropertyDescriptor prop_dataListeners = new PropertyDescriptor(
292: "dataListeners", beanClass, "getDataListeners",
293: null);
294: prop_dataListeners
295: .setDisplayName(resources
296: .getString("ObjectDataProvider_dataListeners_DisplayName"));
297: prop_dataListeners
298: .setShortDescription(resources
299: .getString("ObjectDataProvider_dataListeners_Description"));
300: prop_dataListeners.setExpert(false);
301: prop_dataListeners.setHidden(true);
302: prop_dataListeners.setPreferred(false);
303: prop_dataListeners
304: .setValue(
305: Constants.PropertyDescriptor.CATEGORY,
306: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
307:
308: PropertyDescriptor prop_fieldKeys = new PropertyDescriptor(
309: "fieldKeys", beanClass, "getFieldKeys", null);
310: prop_fieldKeys
311: .setDisplayName(resources
312: .getString("ObjectDataProvider_fieldKeys_DisplayName"));
313: prop_fieldKeys
314: .setShortDescription(resources
315: .getString("ObjectDataProvider_fieldKeys_Description"));
316: prop_fieldKeys.setExpert(false);
317: prop_fieldKeys.setHidden(true);
318: prop_fieldKeys.setPreferred(false);
319: prop_fieldKeys
320: .setValue(
321: Constants.PropertyDescriptor.CATEGORY,
322: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
323:
324: PropertyDescriptor prop_includeFields = new PropertyDescriptor(
325: "includeFields", beanClass, "isIncludeFields",
326: "setIncludeFields");
327: prop_includeFields
328: .setDisplayName(resources
329: .getString("ObjectDataProvider_includeFields_DisplayName"));
330: prop_includeFields
331: .setShortDescription(resources
332: .getString("ObjectDataProvider_includeFields_Description"));
333: prop_includeFields.setExpert(false);
334: prop_includeFields.setHidden(false);
335: prop_includeFields.setPreferred(false);
336: prop_includeFields
337: .setValue(
338: Constants.PropertyDescriptor.CATEGORY,
339: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
340:
341: PropertyDescriptor prop_object = new PropertyDescriptor(
342: "object", beanClass, "getObject", "setObject");
343: prop_object
344: .setDisplayName(resources
345: .getString("ObjectDataProvider_object_DisplayName"));
346: prop_object
347: .setShortDescription(resources
348: .getString("ObjectDataProvider_object_Description"));
349: prop_object
350: .setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.SelectOneDomainEditor"));
351: prop_object.setExpert(false);
352: prop_object.setHidden(false);
353: prop_object.setPreferred(false);
354: prop_object
355: .setValue(
356: Constants.PropertyDescriptor.CATEGORY,
357: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
358: prop_object
359: .setValue(
360: "com.sun.rave.propertyeditors.DOMAIN_CLASS",
361: loadClass("com.sun.rave.propertyeditors.domains.InstanceVariableDomain"));
362:
363: propDescriptors = new PropertyDescriptor[] { prop_class,
364: prop_dataListeners, prop_fieldKeys,
365: prop_includeFields, prop_object, };
366: return propDescriptors;
367:
368: } catch (IntrospectionException e) {
369: e.printStackTrace();
370: return null;
371: }
372:
373: }
374:
375: }
376: //GEN-END:BeanInfo
|