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 MapDataProviderBeanInfoBase 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: MapDataProviderBeanInfoBase.class.getClassLoader());
072:
073: /**
074: * <p>Construct a new <code>MapDataProviderBeanInfoBase</code>.</p>
075: */
076: public MapDataProviderBeanInfoBase() {
077:
078: beanClass = com.sun.data.provider.impl.MapDataProvider.class;
079: iconFileName_C16 = "/org/netbeans/modules/visualweb/dataprovider/designtime/impl/MapDataProvider_C16";
080: iconFileName_C32 = "/org/netbeans/modules/visualweb/dataprovider/designtime/impl/MapDataProvider_C32";
081: iconFileName_M16 = "/org/netbeans/modules/visualweb/dataprovider/designtime/impl/MapDataProvider_M16";
082: iconFileName_M32 = "/org/netbeans/modules/visualweb/dataprovider/designtime/impl/MapDataProvider_M32";
083:
084: }
085:
086: /**
087: * <p>The bean class that this BeanInfo represents.
088: */
089: protected Class beanClass;
090:
091: /**
092: * <p>The cached BeanDescriptor.</p>
093: */
094: protected BeanDescriptor beanDescriptor;
095:
096: /**
097: * <p>The index of the default property.</p>
098: */
099: protected int defaultPropertyIndex = -2;
100:
101: /**
102: * <p>The name of the default property.</p>
103: */
104: protected String defaultPropertyName;
105:
106: /**
107: * <p>The 16x16 color icon.</p>
108: */
109: protected String iconFileName_C16;
110:
111: /**
112: * <p>The 32x32 color icon.</p>
113: */
114: protected String iconFileName_C32;
115:
116: /**
117: * <p>The 16x16 monochrome icon.</p>
118: */
119: protected String iconFileName_M16;
120:
121: /**
122: * <p>The 32x32 monochrome icon.</p>
123: */
124: protected String iconFileName_M32;
125:
126: /**
127: * <p>The cached property descriptors.</p>
128: */
129: protected PropertyDescriptor[] propDescriptors;
130:
131: /**
132: * <p>Return the <code>BeanDescriptor</code> for this bean.</p>
133: */
134: public BeanDescriptor getBeanDescriptor() {
135:
136: if (beanDescriptor != null) {
137: return beanDescriptor;
138: }
139:
140: beanDescriptor = new BeanDescriptor(beanClass);
141: beanDescriptor.setDisplayName(resources
142: .getString("MapDataProvider_DisplayName"));
143: beanDescriptor.setShortDescription(resources
144: .getString("MapDataProvider_Description"));
145: beanDescriptor.setExpert(false);
146: beanDescriptor.setHidden(false);
147: beanDescriptor.setPreferred(false);
148: beanDescriptor.setValue(
149: Constants.BeanDescriptor.FACET_DESCRIPTORS,
150: getFacetDescriptors());
151: beanDescriptor.setValue(Constants.BeanDescriptor.INSTANCE_NAME,
152: "mapDataProvider");
153: beanDescriptor.setValue(Constants.BeanDescriptor.IS_CONTAINER,
154: Boolean.TRUE);
155: beanDescriptor.setValue(
156: Constants.BeanDescriptor.PROPERTY_CATEGORIES,
157: getCategoryDescriptors());
158:
159: return beanDescriptor;
160:
161: }
162:
163: /**
164: * <p>Return the <code>CategoryDescriptor</code> array for the property categories of this component.</p>
165: */
166: private CategoryDescriptor[] getCategoryDescriptors() {
167:
168: return com.sun.rave.designtime.base.CategoryDescriptors
169: .getDefaultCategoryDescriptors();
170:
171: }
172:
173: /**
174: * <p>Return the index of the default property, or
175: * -1 if there is no default property.</p>
176: */
177: public int getDefaultPropertyIndex() {
178:
179: if (defaultPropertyIndex > -2) {
180: return defaultPropertyIndex;
181: } else {
182: if (defaultPropertyName == null) {
183: defaultPropertyIndex = -1;
184: } else {
185: PropertyDescriptor pd[] = getPropertyDescriptors();
186: for (int i = 0; i < pd.length; i++) {
187: if (defaultPropertyName.equals(pd[i].getName())) {
188: defaultPropertyIndex = i;
189: break;
190: }
191: }
192: }
193: }
194: return defaultPropertyIndex;
195: }
196:
197: /**
198: * <p>The cached facet descriptors.</p>
199: */
200: protected FacetDescriptor[] facetDescriptors;
201:
202: /**
203: * <p>Return the <code>FacetDescriptor</code>s for this bean.</p>
204: */
205: public FacetDescriptor[] getFacetDescriptors() {
206:
207: if (facetDescriptors != null) {
208: return facetDescriptors;
209: }
210: facetDescriptors = new FacetDescriptor[] {};
211: return facetDescriptors;
212:
213: }
214:
215: /**
216: * <p>Return the specified image (if any)
217: * for this component class.</p>
218: */
219: public Image getIcon(int kind) {
220:
221: String name;
222: switch (kind) {
223: case ICON_COLOR_16x16:
224: name = iconFileName_C16;
225: break;
226: case ICON_COLOR_32x32:
227: name = iconFileName_C32;
228: break;
229: case ICON_MONO_16x16:
230: name = iconFileName_M16;
231: break;
232: case ICON_MONO_32x32:
233: name = iconFileName_M32;
234: break;
235: default:
236: name = null;
237: break;
238: }
239: if (name == null) {
240: return null;
241: }
242:
243: Image image = loadImage(name + ".png");
244: if (image == null) {
245: image = loadImage(name + ".gif");
246: }
247: return image;
248:
249: }
250:
251: /**
252: * <p>Return a class loaded by name via the class loader that loaded this class.</p>
253: */
254: private java.lang.Class loadClass(java.lang.String name) {
255:
256: try {
257: return Class.forName(name);
258: } catch (ClassNotFoundException e) {
259: throw new RuntimeException(e);
260: }
261:
262: }
263:
264: /**
265: * <p>Return the <code>PropertyDescriptor</code>s for this bean.</p>
266: */
267: public PropertyDescriptor[] getPropertyDescriptors() {
268:
269: if (propDescriptors != null) {
270: return propDescriptors;
271: }
272: AttributeDescriptor attrib = null;
273:
274: try {
275:
276: PropertyDescriptor prop_class = new PropertyDescriptor(
277: "class", beanClass, "getClass", null);
278: prop_class.setDisplayName(resources
279: .getString("MapDataProvider_class_DisplayName"));
280: prop_class.setShortDescription(resources
281: .getString("MapDataProvider_class_Description"));
282: prop_class.setExpert(false);
283: prop_class.setHidden(true);
284: prop_class.setPreferred(false);
285: prop_class
286: .setValue(
287: Constants.PropertyDescriptor.CATEGORY,
288: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
289:
290: PropertyDescriptor prop_dataListeners = new PropertyDescriptor(
291: "dataListeners", beanClass, "getDataListeners",
292: null);
293: prop_dataListeners
294: .setDisplayName(resources
295: .getString("MapDataProvider_dataListeners_DisplayName"));
296: prop_dataListeners
297: .setShortDescription(resources
298: .getString("MapDataProvider_dataListeners_Description"));
299: prop_dataListeners.setExpert(false);
300: prop_dataListeners.setHidden(true);
301: prop_dataListeners.setPreferred(false);
302: prop_dataListeners
303: .setValue(
304: Constants.PropertyDescriptor.CATEGORY,
305: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
306:
307: PropertyDescriptor prop_fieldKeys = new PropertyDescriptor(
308: "fieldKeys", beanClass, "getFieldKeys", null);
309: prop_fieldKeys
310: .setDisplayName(resources
311: .getString("MapDataProvider_fieldKeys_DisplayName"));
312: prop_fieldKeys
313: .setShortDescription(resources
314: .getString("MapDataProvider_fieldKeys_Description"));
315: prop_fieldKeys.setExpert(false);
316: prop_fieldKeys.setHidden(true);
317: prop_fieldKeys.setPreferred(false);
318: prop_fieldKeys
319: .setValue(
320: Constants.PropertyDescriptor.CATEGORY,
321: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
322:
323: PropertyDescriptor prop_map = new PropertyDescriptor("map",
324: beanClass, "getMap", "setMap");
325: prop_map.setDisplayName(resources
326: .getString("MapDataProvider_map_DisplayName"));
327: prop_map.setShortDescription(resources
328: .getString("MapDataProvider_map_Description"));
329: prop_map
330: .setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.SelectOneDomainEditor"));
331: prop_map.setExpert(false);
332: prop_map.setHidden(false);
333: prop_map.setPreferred(false);
334: prop_map
335: .setValue(
336: Constants.PropertyDescriptor.CATEGORY,
337: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
338: prop_map
339: .setValue(
340: "com.sun.rave.propertyeditors.DOMAIN_CLASS",
341: loadClass("com.sun.rave.propertyeditors.domains.InstanceVariableDomain"));
342:
343: propDescriptors = new PropertyDescriptor[] { prop_class,
344: prop_dataListeners, prop_fieldKeys, prop_map, };
345: return propDescriptors;
346:
347: } catch (IntrospectionException e) {
348: e.printStackTrace();
349: return null;
350: }
351:
352: }
353:
354: }
355: //GEN-END:BeanInfo
|