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