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_2.component.html;
043:
044: import org.netbeans.modules.visualweb.faces.dt_1_2.component.UICommandBeanInfoBase;
045: import java.beans.BeanDescriptor;
046: import java.beans.IntrospectionException;
047: import java.beans.PropertyDescriptor;
048: import java.util.Locale;
049: import java.util.List;
050: import java.util.ArrayList;
051: import java.util.Arrays;
052: import java.util.ResourceBundle;
053: import com.sun.rave.designtime.Constants;
054: import com.sun.rave.designtime.markup.AttributeDescriptor;
055: import org.netbeans.modules.visualweb.faces.dt.BeanDescriptorBase;
056: import org.netbeans.modules.visualweb.faces.dt.PropertyDescriptorBase;
057:
058: /**
059: * The HtmlCommandButtonBeanInfo class provides design-time meta data
060: * for the HtmlCommandButton component for use in a visual design tool.
061: */
062: public class HtmlCommandButtonBeanInfo extends UICommandBeanInfoBase {
063:
064: protected static ResourceBundle resources = ResourceBundle
065: .getBundle(
066: "org.netbeans.modules.visualweb.faces.dt_1_2.component.html.Bundle-JSF",
067: Locale.getDefault(),
068: HtmlCommandButtonBeanInfo.class.getClassLoader());
069:
070: public HtmlCommandButtonBeanInfo() {
071: beanClass = javax.faces.component.html.HtmlCommandButton.class;
072: defaultPropertyName = "value";
073: iconFileName_C16 = "/org/netbeans/modules/visualweb/faces/dt_1_2/component/html/HtmlCommandButton_C16";
074: iconFileName_C32 = "/org/netbeans/modules/visualweb/faces/dt_1_2/component/html/HtmlCommandButton_C32";
075: iconFileName_M16 = "/org/netbeans/modules/visualweb/faces/dt_1_2/component/html/HtmlCommandButton_M16";
076: iconFileName_M32 = "/org/netbeans/modules/visualweb/faces/dt_1_2/component/html/HtmlCommandButton_M32";
077: }
078:
079: private BeanDescriptor beanDescriptor;
080:
081: /**
082: * <p>Return the <code>BeanDescriptor</code> for this bean.</p>
083: */
084: public BeanDescriptor getBeanDescriptor() {
085:
086: if (beanDescriptor != null) {
087: return beanDescriptor;
088: }
089: beanDescriptor = new BeanDescriptorBase(beanClass);
090: beanDescriptor.setDisplayName(resources
091: .getString("HtmlCommandButton_DisplayName"));
092: beanDescriptor.setShortDescription(resources
093: .getString("HtmlCommandButton_Description"));
094: beanDescriptor.setExpert(false);
095: beanDescriptor.setHidden(false);
096: beanDescriptor.setPreferred(false);
097: beanDescriptor.setValue(
098: Constants.BeanDescriptor.FACET_DESCRIPTORS,
099: getFacetDescriptors());
100: beanDescriptor.setValue(Constants.BeanDescriptor.HELP_KEY,
101: "projrave_ui_elements_palette_jsfstd_button");
102: beanDescriptor.setValue(
103: Constants.BeanDescriptor.INLINE_EDITABLE_PROPERTIES,
104: new String[] { "*value://input" }); // NOI18N
105: beanDescriptor.setValue(Constants.BeanDescriptor.INSTANCE_NAME,
106: "button");
107: beanDescriptor.setValue(Constants.BeanDescriptor.IS_CONTAINER,
108: Boolean.FALSE);
109: beanDescriptor.setValue(
110: Constants.BeanDescriptor.PROPERTIES_HELP_KEY,
111: "projrave_ui_elements_propsheets_jsfstd_button_props");
112: beanDescriptor.setValue(
113: Constants.BeanDescriptor.PROPERTY_CATEGORIES,
114: getCategoryDescriptors());
115: beanDescriptor.setValue(Constants.BeanDescriptor.TAG_NAME,
116: "commandButton");
117: beanDescriptor.setValue(Constants.BeanDescriptor.TAGLIB_PREFIX,
118: "h");
119: beanDescriptor.setValue(Constants.BeanDescriptor.TAGLIB_URI,
120: "http://java.sun.com/jsf/html");
121:
122: return beanDescriptor;
123: }
124:
125: private PropertyDescriptor[] propertyDescriptors;
126:
127: /**
128: * <p>Return the <code>PropertyDescriptor</code>s for this bean.</p>
129: */
130: public PropertyDescriptor[] getPropertyDescriptors() {
131:
132: if (propertyDescriptors != null) {
133: return propertyDescriptors;
134: }
135: AttributeDescriptor attrib = null;
136:
137: try {
138:
139: PropertyDescriptor prop_accesskey = new PropertyDescriptorBase(
140: "accesskey", beanClass, "getAccesskey",
141: "setAccesskey");
142: prop_accesskey
143: .setDisplayName(resources
144: .getString("HtmlCommandButton_accesskey_DisplayName"));
145: prop_accesskey
146: .setShortDescription(resources
147: .getString("HtmlCommandButton_accesskey_Description"));
148: prop_accesskey.setExpert(false);
149: prop_accesskey.setHidden(false);
150: prop_accesskey.setPreferred(false);
151: attrib = new AttributeDescriptor("accesskey", false, null,
152: true);
153: prop_accesskey.setValue(
154: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
155: attrib);
156: prop_accesskey
157: .setValue(
158: Constants.PropertyDescriptor.CATEGORY,
159: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
160:
161: PropertyDescriptor prop_alt = new PropertyDescriptorBase(
162: "alt", beanClass, "getAlt", "setAlt");
163: prop_alt.setDisplayName(resources
164: .getString("HtmlCommandButton_alt_DisplayName"));
165: prop_alt.setShortDescription(resources
166: .getString("HtmlCommandButton_alt_Description"));
167: prop_alt.setExpert(false);
168: prop_alt.setHidden(false);
169: prop_alt.setPreferred(false);
170: attrib = new AttributeDescriptor("alt", false, null, true);
171: prop_alt.setValue(
172: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
173: attrib);
174: prop_alt
175: .setValue(
176: Constants.PropertyDescriptor.CATEGORY,
177: com.sun.rave.designtime.base.CategoryDescriptors.APPEARANCE);
178:
179: PropertyDescriptor prop_dir = new PropertyDescriptorBase(
180: "dir", beanClass, "getDir", "setDir");
181: prop_dir.setDisplayName(resources
182: .getString("HtmlCommandButton_dir_DisplayName"));
183: prop_dir.setShortDescription(resources
184: .getString("HtmlCommandButton_dir_Description"));
185: prop_dir
186: .setPropertyEditorClass(com.sun.rave.propertyeditors.SelectOneDomainEditor.class);
187: prop_dir.setExpert(false);
188: prop_dir.setHidden(false);
189: prop_dir.setPreferred(false);
190: attrib = new AttributeDescriptor("dir", false, null, true);
191: prop_dir.setValue(
192: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
193: attrib);
194: prop_dir
195: .setValue(
196: Constants.PropertyDescriptor.CATEGORY,
197: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
198: prop_dir
199: .setValue(
200: com.sun.rave.propertyeditors.DomainPropertyEditor.DOMAIN_CLASS,
201: com.sun.rave.propertyeditors.domains.TextDirectionDomain.class);
202:
203: PropertyDescriptor prop_disabled = new PropertyDescriptorBase(
204: "disabled", beanClass, "isDisabled", "setDisabled");
205: prop_disabled
206: .setDisplayName(resources
207: .getString("HtmlCommandButton_disabled_DisplayName"));
208: prop_disabled
209: .setShortDescription(resources
210: .getString("HtmlCommandButton_disabled_Description"));
211: prop_disabled.setExpert(false);
212: prop_disabled.setHidden(false);
213: prop_disabled.setPreferred(false);
214: attrib = new AttributeDescriptor("disabled", false, null,
215: true);
216: prop_disabled.setValue(
217: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
218: attrib);
219: prop_disabled
220: .setValue(
221: Constants.PropertyDescriptor.CATEGORY,
222: com.sun.rave.designtime.base.CategoryDescriptors.APPEARANCE);
223:
224: PropertyDescriptor prop_image = new PropertyDescriptorBase(
225: "image", beanClass, "getImage", "setImage");
226: prop_image.setDisplayName(resources
227: .getString("HtmlCommandButton_image_DisplayName"));
228: prop_image.setShortDescription(resources
229: .getString("HtmlCommandButton_image_Description"));
230: prop_image
231: .setPropertyEditorClass(com.sun.rave.propertyeditors.UrlPropertyEditor.class);
232: prop_image.setExpert(false);
233: prop_image.setHidden(false);
234: prop_image.setPreferred(false);
235: attrib = new AttributeDescriptor("image", false, null, true);
236: prop_image.setValue(
237: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
238: attrib);
239: prop_image
240: .setValue(
241: Constants.PropertyDescriptor.CATEGORY,
242: com.sun.rave.designtime.base.CategoryDescriptors.APPEARANCE);
243:
244: PropertyDescriptor prop_lang = new PropertyDescriptorBase(
245: "lang", beanClass, "getLang", "setLang");
246: prop_lang.setDisplayName(resources
247: .getString("HtmlCommandButton_lang_DisplayName"));
248: prop_lang.setShortDescription(resources
249: .getString("HtmlCommandButton_lang_Description"));
250: prop_lang
251: .setPropertyEditorClass(com.sun.rave.propertyeditors.SelectOneDomainEditor.class);
252: prop_lang.setExpert(false);
253: prop_lang.setHidden(false);
254: prop_lang.setPreferred(false);
255: attrib = new AttributeDescriptor("lang", false, null, true);
256: prop_lang.setValue(
257: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
258: attrib);
259: prop_lang
260: .setValue(
261: Constants.PropertyDescriptor.CATEGORY,
262: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
263: prop_lang
264: .setValue(
265: "com.sun.rave.propertyeditors.DOMAIN_CLASS",
266: com.sun.rave.propertyeditors.domains.LanguagesDomain.class);
267:
268: PropertyDescriptor prop_readonly = new PropertyDescriptorBase(
269: "readonly", beanClass, "isReadonly", "setReadonly");
270: prop_readonly
271: .setDisplayName(resources
272: .getString("HtmlCommandButton_readonly_DisplayName"));
273: prop_readonly
274: .setShortDescription(resources
275: .getString("HtmlCommandButton_readonly_Description"));
276: prop_readonly.setExpert(false);
277: prop_readonly.setHidden(false);
278: prop_readonly.setPreferred(false);
279: attrib = new AttributeDescriptor("readonly", false, null,
280: true);
281: prop_readonly.setValue(
282: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
283: attrib);
284: prop_readonly
285: .setValue(
286: Constants.PropertyDescriptor.CATEGORY,
287: com.sun.rave.designtime.base.CategoryDescriptors.APPEARANCE);
288:
289: PropertyDescriptor prop_tabindex = new PropertyDescriptorBase(
290: "tabindex", beanClass, "getTabindex", "setTabindex");
291: prop_tabindex
292: .setDisplayName(resources
293: .getString("HtmlCommandButton_tabindex_DisplayName"));
294: prop_tabindex
295: .setShortDescription(resources
296: .getString("HtmlCommandButton_tabindex_Description"));
297: prop_tabindex
298: .setPropertyEditorClass(com.sun.rave.propertyeditors.IntegerPropertyEditor.class);
299: prop_tabindex.setExpert(false);
300: prop_tabindex.setHidden(false);
301: prop_tabindex.setPreferred(false);
302: attrib = new AttributeDescriptor("tabindex", false, null,
303: true);
304: prop_tabindex.setValue(
305: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
306: attrib);
307: prop_tabindex
308: .setValue(
309: Constants.PropertyDescriptor.CATEGORY,
310: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
311: prop_tabindex.setValue("maxValue", new Integer(
312: Short.MAX_VALUE));
313: prop_tabindex.setValue("minValue", new Integer(0));
314:
315: PropertyDescriptor prop_type = new PropertyDescriptorBase(
316: "type", beanClass, "getType", "setType");
317: prop_type.setDisplayName(resources
318: .getString("HtmlCommandButton_type_DisplayName"));
319: prop_type.setShortDescription(resources
320: .getString("HtmlCommandButton_type_Description"));
321: prop_type
322: .setPropertyEditorClass(com.sun.rave.propertyeditors.SelectOneDomainEditor.class);
323: prop_type.setExpert(false);
324: prop_type.setHidden(false);
325: prop_type.setPreferred(false);
326: attrib = new AttributeDescriptor("type", false,
327: "\"submit\"", true);
328: prop_type.setValue(
329: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
330: attrib);
331: prop_type
332: .setValue(
333: Constants.PropertyDescriptor.CATEGORY,
334: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
335: prop_type
336: .setValue(
337: com.sun.rave.propertyeditors.DomainPropertyEditor.DOMAIN_CLASS,
338: HtmlCommandButtonTypesDomain.class);
339:
340: List<PropertyDescriptor> propertyDescriptorList = new ArrayList<PropertyDescriptor>();
341: propertyDescriptorList.add(prop_accesskey);
342: propertyDescriptorList.add(prop_alt);
343: propertyDescriptorList.add(prop_dir);
344: propertyDescriptorList.add(prop_disabled);
345: propertyDescriptorList.add(prop_image);
346: propertyDescriptorList.add(prop_lang);
347: propertyDescriptorList.add(prop_readonly);
348: propertyDescriptorList.add(prop_tabindex);
349: propertyDescriptorList.add(prop_type);
350:
351: propertyDescriptorList.addAll(Properties
352: .getVisualPropertyList(beanClass));
353: propertyDescriptorList.addAll(Properties
354: .getKeyEventPropertyList(beanClass));
355: propertyDescriptorList.addAll(Properties
356: .getMouseEventPropertyList(beanClass));
357: propertyDescriptorList.addAll(Properties
358: .getClickEventPropertyList(beanClass));
359: propertyDescriptorList.addAll(Properties
360: .getFocusEventPropertyList(beanClass));
361: propertyDescriptorList.addAll(Properties
362: .getSelectEventPropertyList(beanClass));
363: propertyDescriptorList.addAll(Properties
364: .getChangeEventPropertyList(beanClass));
365: propertyDescriptorList.addAll(Arrays.asList(super
366: .getPropertyDescriptors()));
367: propertyDescriptors = propertyDescriptorList
368: .toArray(new PropertyDescriptor[propertyDescriptorList
369: .size()]);
370: return propertyDescriptors;
371:
372: } catch (IntrospectionException e) {
373: e.printStackTrace();
374: return null;
375: }
376:
377: }
378:
379: }
|