You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2006/03/01 07:41:07 UTC
svn commit: r381930 [2/3] -
/struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/
Modified: struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/AbstractBeanInfo.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/AbstractBeanInfo.java?rev=381930&r1=381929&r2=381930&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/AbstractBeanInfo.java (original)
+++ struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/AbstractBeanInfo.java Tue Feb 28 22:41:06 2006
@@ -1,934 +1,934 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id$
- */
-
-package org.apache.shale.design;
-
-import com.sun.jsfcl.std.reference.ReferenceDataManager;
-import com.sun.rave.designtime.Constants;
-import com.sun.rave.designtime.faces.FacetDescriptor;
-import com.sun.rave.designtime.markup.AttributeDescriptor;
-import java.awt.Image;
-import java.beans.BeanDescriptor;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/**
- * <p>Convenience base class for <code>BeanInfo</code> implementations for
- * JavaServer Faces components.</p>
- */
-public abstract class AbstractBeanInfo extends SimpleBeanInfo {
-
-
- // ------------------------------------------------------------ Constructors
-
-
- /**
- * <p>Create a new <code>BeanInfo</code> instance for the specified
- * bean class. Default the icon filenames based on the simple class
- * name of the bean class.</p>
- *
- * @param clazz Bean class for which to create a <code>BeanInfo</code>
- */
- public AbstractBeanInfo(Class clazz) {
-
- // Cache the bean class we are describing
- this.beanClass = clazz;
-
- // Calculate default icon image names based on the bean class name
- calculateImageNames();
-
- // Initialize basic descriptor information
- try {
- initBeanDescriptor();
- initMethodDescriptors();
- initPropertyDescriptors();
- initEventSetDescriptors();
- } catch (Exception e) {
- throw new IllegalArgumentException(e.getMessage());
- }
-
- }
-
-
- // ------------------------------------------------------ Instance Variables
-
-
- /**
- * <p>The bean class that this <code>BeanInfo</code> represents.</p>
- */
- protected Class beanClass = null;
-
-
- /**
- * <p>The cached <code>BeanDescriptor</code> for this bean class.</p>
- */
- protected BeanDescriptor beanDescriptor = null;
-
-
- /**
- * <p><code>ResourceBundle</code> containing localized messages for
- * this component library's design time code.</p>
- */
- protected ResourceBundle bundle =
- ResourceBundle.getBundle("org.apache.shale.design.Bundle",
- Locale.getDefault(),
- AbstractBeanInfo.class.getClassLoader());
-
-
- /**
- * <p>The index to the default event for this bean class.</p>
- */
- protected int defaultEventIndex = -1;
-
-
- /**
- * <p>The index to the default property for this bean class.</p>
- */
- protected int defaultPropertyIndex = -1;
-
-
- /**
- * <p>The cached <code>EventSetDescriptor</code>s for this bean class.
- * This value is calculated from the contents of
- * {@link eventDescriptorsList} the first time anyone calls
- * <code>getEventSetDescriptors()</code>.</p>
- */
- protected EventSetDescriptor eventDescriptors[] = null;
-
-
- /**
- * <p>List of <code>EventSetDescriptor</code>s for events of the bean
- * class being described. Base classes (like this one) will typically
- * seed this list with event set descriptors for events of a base class
- * of the bean class, while the <code>initEventSetDescriptors()</code>
- * method can be used to add events specific to an implementation class.</p>
- */
- protected List eventDescriptorsList = new ArrayList();
-
-
- /**
- * <p>The cached <code>FacetDescriptor</code>s for this bean class.</p>
- */
- protected FacetDescriptor facetDescriptors[] = null;
-
-
- /**
- * <p>The 16x16 color icon for this bean class.</p>
- */
- protected String iconFileName_C16 = null;
-
-
- /**
- * <p>The 32x32 color icon for this bean class.</p>
- */
- protected String iconFileName_C32 = null;
-
-
- /**
- * <p>The 16x16 monochrome icon for this bean class.</p>
- */
- protected String iconFileName_M16 = null;
-
-
- /**
- * <p>The 32x32 monochrome icon for this bean class.</p>
- */
- protected String iconFileName_M32 = null;
-
-
- /**
- * <p>The cached <code>MethodDescriptor</code>s for this bean class.</p>
- */
- protected MethodDescriptor methodDescriptors[] = null;
-
-
- /**
- * <p>The cached <code>PropertyDescriptor</code>s for this bean class.
- * This value is calculated from the contents of
- * {@link propDescriptorsList} the first time anyone calls
- * <code>getPropertyDescriptors()</code>.</p>
- */
- protected PropertyDescriptor propDescriptors[] = null;
-
-
- /**
- * <p>List of <code>PropertyDescriptor</code>s for properties of the bean
- * class being described. Base classes (like this one) will typically
- * seed this list with propery descriptors for properties of a base class
- * of the bean class, while the <code>annotatePropertyDescriptors()</code>
- * method can be used to add properties specific to an implementation class.</p>
- */
- protected List propDescriptorsList = new ArrayList();
-
-
- // -------------------------------------------------------- BeanInfo Methods
-
-
- /**
- * <p>Return the <code>BeanDescriptor</code> for this bean class.</p>
- */
- public BeanDescriptor getBeanDescriptor() {
- return this.beanDescriptor;
- }
-
-
- /**
- * <p>Return the zero-relative index of the default event for this
- * bean class, or -1 if there is no default event.</p>
- */
- public int getDefaultEventIndex() {
- return this.defaultEventIndex;
- }
-
-
- /**
- * <p>Return the zero-relative index of the default property for this
- * bean class, or -1 if there is no default property.</p>
- */
- public int getDefaultPropertyIndex() {
- return this.defaultPropertyIndex;
- }
-
-
- /**
- * <p>Return the <code>EventSetDescriptor</code>s for this bean class.</p>
- */
- public EventSetDescriptor[] getEventSetDescriptors() {
- if (this.eventDescriptors == null) {
- this.eventDescriptors = (EventSetDescriptor[])
- eventDescriptorsList.toArray(new EventSetDescriptor[eventDescriptorsList.size()]);
- }
- return this.eventDescriptors;
- }
-
-
- /**
- * <p>Return the image for the specified icon, if any; otherwise
- * (or if there was an error loading the image) return <code>null</code>.</p>
- *
- * @param kind Kind of icon to return
- */
- public Image getIcon(int kind) {
-
- String name = null;
- switch (kind) {
- case ICON_COLOR_16x16:
- name = iconFileName_C16;
- break;
- case ICON_COLOR_32x32:
- name = iconFileName_C32;
- break;
- case ICON_MONO_16x16:
- name = iconFileName_M16;
- break;
- case ICON_MONO_32x32:
- name = iconFileName_M32;
- break;
- default:
- break;
- }
- Image image = null;
- if (name != null) {
- image = loadImage(name + ".png");
- if (image == null) {
- image = loadImage(name + ".gif");
- }
- }
- return image;
-
- }
-
-
- /**
- * <p>Return the <code>MethodDescriptor</code>s for this bean class.</p>
- */
- public MethodDescriptor[] getMethodDescriptors() {
- return this.methodDescriptors;
- }
-
-
- /**
- * <p>Return the <code>PropertyDescriptor</code>s for this bean class.</p>
- */
- public PropertyDescriptor[] getPropertyDescriptors() {
- if (this.propDescriptors == null) {
- this.propDescriptors = (PropertyDescriptor[])
- propDescriptorsList.toArray(new PropertyDescriptor[propDescriptorsList.size()]);
- }
- return this.propDescriptors;
- }
-
-
- // ------------------------------------------------------- Protected Methods
-
-
- /**
- * <p>Calculate and store icon image names for the bean class that is
- * being described.</p>
- */
- protected void calculateImageNames() {
-
- String name = beanClass.getName();
- int period = name.lastIndexOf('.');
- if (period >= 0) {
- name = name.substring(period + 1);
- }
- iconFileName_C16 = name + "_C16";
- iconFileName_C32 = name + "_C32";
- iconFileName_M16 = name + "_M16";
- iconFileName_M32 = name + "_M32";
-
- }
-
-
- /**
- * <p>Look up and return the event set descriptor for the specified event set
- * name, if any; otherwise, return <code>null</code>.</p>
- *
- * @param name Name of the event set to look up
- */
- protected EventSetDescriptor eventSetDescriptor(String name) {
-
- if (eventDescriptors != null) {
- for (int i = 0; i < eventDescriptors.length; i++) {
- if (name.equals(eventDescriptors[i].getName())) {
- return eventDescriptors[i];
- }
- }
- } else if (eventDescriptorsList != null) {
- Iterator items = eventDescriptorsList.iterator();
- while (items.hasNext()) {
- EventSetDescriptor item = (EventSetDescriptor) items.next();
- if (name.equals(item.getName())) {
- return item;
- }
- }
- }
- return null;
-
- }
-
-
- /**
- * <p>Initialize the basic bean descriptor for this bean class.</p>
- */
- protected void initBeanDescriptor() throws Exception {
-
- BeanDescriptor bd = new BeanDescriptor(beanClass);
- String simple = simpleName();
-
- bd.setDisplayName(bundle.getString(simple + ".displayName"));
- bd.setShortDescription(bundle.getString(simple + ".shortDescription"));
- bd.setExpert(false);
- bd.setHidden(false);
- bd.setPreferred(false);
-
- initFacetDescriptors();
- bd.setValue(Constants.BeanDescriptor.FACET_DESCRIPTORS,
- facetDescriptors);
-
- beanDescriptor = bd;
-
- }
-
-
- /**
- * <p>Initialize event set descriptors for the events exposed by
- * <code>javax.faces.component.UIComponent</code>
- * to the list of event set descriptors we are accumulating.</p>
- */
- protected void initEventSetDescriptors() throws Exception {
-
- ; // UIComponent has no events of its own
-
- }
-
- /**
- * <p>Initialize the facet descriptors for this bean class.</p>
- */
- protected void initFacetDescriptors() throws Exception {
-
- facetDescriptors = new FacetDescriptor[0];
-
- }
-
-
- /**
- * <p>Initialize the method descriptors for this bean class.</p>
- */
- protected void initMethodDescriptors() throws Exception {
-
- ; // Null return value means use introspection
-
- }
-
-
- /**
- * <p>Initialize property descriptors for the properties exposed by
- * <code>javax.faces.component.UIComponent</code>
- * to the list of property descriptors we are accumulating. In addition,
- * if the bean class supports the <code>style</code> and <code>styleClass</code>
- * properties (a normal convention), add descriptors for those as well.</p>
- */
- protected void initPropertyDescriptors() throws Exception {
-
- AttributeDescriptor ad = null;
- PropertyDescriptor pd = null;
-
- pd = new PropertyDescriptor("attributes", beanClass, "getAttributes", null);
- pd.setDisplayName(bundle.getString("UIComponent.attributes.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.attributes.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("childCount", beanClass, "getChildCount", null);
- pd.setDisplayName(bundle.getString("UIComponent.childCount.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.childCount.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("children", beanClass, "getChildren", null);
- pd.setDisplayName(bundle.getString("UIComponent.children.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.children.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("facets", beanClass, "getFacets", null);
- pd.setDisplayName(bundle.getString("UIComponent.facets.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.facets.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("family", beanClass, "getFamily", null);
- pd.setDisplayName(bundle.getString("UIComponent.family.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.family.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("id", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.id.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.id.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("id", false, null, false);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.GENERAL);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("parent", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.parent.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.parent.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("rendered", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.rendered.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.rendered.shortDescription"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("rendererType", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.rendererType.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.rendererType.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("rendersChildren", beanClass, "getRendersChildren", null);
- pd.setDisplayName(bundle.getString("UIComponent.rendersChildren.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.rendersChildren.shortDescription"));
- pd.setExpert(true);
- pd.setHidden(true);
- pd.setPreferred(false);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
- propDescriptorsList.add(pd);
-
- try {
- beanClass.getMethod("getStyle", null);
- pd = new PropertyDescriptor("style", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.style.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.style.shortDescription"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.css.CssStylePropertyEditor"));
- ad = new AttributeDescriptor("style", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
- propDescriptorsList.add(pd);
- } catch (NoSuchMethodException e) {
- ; // No such method, so do not add a property descriptor
- }
-
- try {
- beanClass.getMethod("getStyleClass", null);
- pd = new PropertyDescriptor("styleClass", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.styleClass.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.styleClass.shortDescription"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.property.ChooseManyReferenceDataPropertyEditor"));
- pd.setValue("referenceDataDefiner", com.sun.jsfcl.std.reference.ReferenceDataManager.STYLE_CLASSES);
- ad = new AttributeDescriptor("styleClass", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
- propDescriptorsList.add(pd);
- } catch (NoSuchMethodException e) {
- ; // No such method, so do not add a property descriptor
- }
-
- }
-
-
- /**
- * <p>Initialize common property descriptors for JavaScript
- * event handlers.</p>
- */
- protected void initPropertyDescriptorsEvent() throws Exception {
-
- AttributeDescriptor ad = null;
- PropertyDescriptor pd = null;
-
- pd = new PropertyDescriptor("onclick", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onclick.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onclick.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onclick", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("ondblclick", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.ondblclick.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.ondblclick.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("ondblclick", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onkeydown", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onkeydown.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onkeydown.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onkeydown", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onkeypress", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onkeypress.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onkeypress.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onkeypress", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onkeyup", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onkeyup.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onkeyup.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onkeyup", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onmousedown", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onmousedown.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onmousedown.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onmousedown", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onmousemove", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onmousemove.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onmousemove.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onmousemove", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onmouseout", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onmouseout.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onmouseout.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onmouseout", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onmouseover", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onmouseover.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onmouseover.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onmouseover", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onmouseup", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onmouseup.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onmouseup.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onmouseup", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- }
-
-
- /**
- * <p>Initialize common property descriptors for JavaScript
- * event handlers related to gaining and losing focus.</p>
- */
- protected void initPropertyDescriptorsFocus() throws Exception {
-
- AttributeDescriptor ad = null;
- PropertyDescriptor pd = null;
-
- pd = new PropertyDescriptor("accesskey", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.accesskey.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.accesskey.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.StringPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("accesskey", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onblur", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onblur.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onblur.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onblur", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onfocus", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onfocus.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onfocus.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onfocus", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("tabindex", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.tabindex.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.tabindex.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.IntegerPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("tabindex", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
- pd.setValue("minValue", new Integer(0));
- pd.setValue("maxValue", new Integer(Short.MAX_VALUE));
- propDescriptorsList.add(pd);
-
- }
-
-
- /**
- * <p>Initialize common property descriptors for internationalization
- * attributes.</p>
- */
- protected void initPropertyDescriptorsI18n() throws Exception {
-
- AttributeDescriptor ad = null;
- PropertyDescriptor pd = null;
-
- pd = new PropertyDescriptor("dir", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.dir.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.dir.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.property.ChooseOneReferenceDataPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("dir", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
- pd.setValue("referenceDataDefiner", ReferenceDataManager.TEXT_DIRECTIONS);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("lang", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.lang.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.lang.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.property.ChooseOneReferenceDataPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("lang", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
- pd.setValue("referenceDataDefiner", ReferenceDataManager.LANGUAGE_CODES);
- propDescriptorsList.add(pd);
-
- }
-
-
- /**
- * <p>Initialize common property descriptors for input related
- * attributes.</p>
- */
- protected void initPropertyDescriptorsInput() throws Exception {
-
- AttributeDescriptor ad = null;
- PropertyDescriptor pd = null;
-
- pd = new PropertyDescriptor("disabled", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.disabled.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.disabled.shortDescription"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("disabled", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onchange", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onchange.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onchange.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onchange", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("onselect", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.onselect.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.onselect.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("onselect", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("readonly", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.readonly.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.readonly.shortDescription"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("readonly", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
- propDescriptorsList.add(pd);
-
- }
-
-
- /**
- * <p>Initialize common property descriptors for text related
- * attributes.</p>
- */
- protected void initPropertyDescriptorsText() throws Exception {
-
- AttributeDescriptor ad = null;
- PropertyDescriptor pd = null;
-
- pd = new PropertyDescriptor("alt", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.alt.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.alt.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.StringPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("alt", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("maxlength", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.maxlength.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.maxlength.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.IntegerPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("maxlength", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.DATA);
- pd.setValue("minValue", new Integer(0));
- pd.setValue("unsetValue", new Integer(Integer.MIN_VALUE));
- propDescriptorsList.add(pd);
-
- pd = new PropertyDescriptor("size", beanClass);
- pd.setDisplayName(bundle.getString("UIComponent.size.displayName"));
- pd.setShortDescription(bundle.getString("UIComponent.size.shortDescription"));
- pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.IntegerPropertyEditor"));
- pd.setExpert(false);
- pd.setHidden(false);
- pd.setPreferred(false);
- ad = new AttributeDescriptor("size", false, null, true);
- pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
- pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
- pd.setValue("minValue", new Integer(0));
- pd.setValue("unsetValue", new Integer(Integer.MIN_VALUE));
- propDescriptorsList.add(pd);
-
- }
-
-
- /**
- * <p>Load and return the class with the specified fully qualified name,
- * or return <code>null</code> if the class cannot be loaded.</p>
- *
- * @param name Fully qualified class name
- */
- protected Class loadClass(String name) {
- try {
- return Class.forName(name);
- } catch (ClassNotFoundException e) {
- return null;
- }
- }
-
-
- /**
- * <p>Look up and return the property descriptor for the specified property
- * name, if any; otherwise, return <code>null</code>.</p>
- *
- * @param name Name of the property to look up
- */
- protected PropertyDescriptor propertyDescriptor(String name) {
-
- if (propDescriptors != null) {
- for (int i = 0; i < propDescriptors.length; i++) {
- if (name.equals(propDescriptors[i].getName())) {
- return propDescriptors[i];
- }
- }
- } else if (propDescriptorsList != null) {
- Iterator items = propDescriptorsList.iterator();
- while (items.hasNext()) {
- PropertyDescriptor item = (PropertyDescriptor) items.next();
- if (name.equals(item.getName())) {
- return item;
- }
- }
- }
- return null;
-
- }
-
-
- /**
- * <p>Return the simple class name for the bean class we are describing.</p>
- */
- protected String simpleName() {
-
- String name = beanClass.getName();
- int period = name.lastIndexOf('.');
- if (period >= 0) {
- name = name.substring(period + 1);
- }
- return name;
-
- }
-
-
- // --------------------------------------------------------- Private Methods
-
-
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.design;
+
+import com.sun.jsfcl.std.reference.ReferenceDataManager;
+import com.sun.rave.designtime.Constants;
+import com.sun.rave.designtime.faces.FacetDescriptor;
+import com.sun.rave.designtime.markup.AttributeDescriptor;
+import java.awt.Image;
+import java.beans.BeanDescriptor;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * <p>Convenience base class for <code>BeanInfo</code> implementations for
+ * JavaServer Faces components.</p>
+ */
+public abstract class AbstractBeanInfo extends SimpleBeanInfo {
+
+
+ // ------------------------------------------------------------ Constructors
+
+
+ /**
+ * <p>Create a new <code>BeanInfo</code> instance for the specified
+ * bean class. Default the icon filenames based on the simple class
+ * name of the bean class.</p>
+ *
+ * @param clazz Bean class for which to create a <code>BeanInfo</code>
+ */
+ public AbstractBeanInfo(Class clazz) {
+
+ // Cache the bean class we are describing
+ this.beanClass = clazz;
+
+ // Calculate default icon image names based on the bean class name
+ calculateImageNames();
+
+ // Initialize basic descriptor information
+ try {
+ initBeanDescriptor();
+ initMethodDescriptors();
+ initPropertyDescriptors();
+ initEventSetDescriptors();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+
+ }
+
+
+ // ------------------------------------------------------ Instance Variables
+
+
+ /**
+ * <p>The bean class that this <code>BeanInfo</code> represents.</p>
+ */
+ protected Class beanClass = null;
+
+
+ /**
+ * <p>The cached <code>BeanDescriptor</code> for this bean class.</p>
+ */
+ protected BeanDescriptor beanDescriptor = null;
+
+
+ /**
+ * <p><code>ResourceBundle</code> containing localized messages for
+ * this component library's design time code.</p>
+ */
+ protected ResourceBundle bundle =
+ ResourceBundle.getBundle("org.apache.shale.design.Bundle",
+ Locale.getDefault(),
+ AbstractBeanInfo.class.getClassLoader());
+
+
+ /**
+ * <p>The index to the default event for this bean class.</p>
+ */
+ protected int defaultEventIndex = -1;
+
+
+ /**
+ * <p>The index to the default property for this bean class.</p>
+ */
+ protected int defaultPropertyIndex = -1;
+
+
+ /**
+ * <p>The cached <code>EventSetDescriptor</code>s for this bean class.
+ * This value is calculated from the contents of
+ * {@link eventDescriptorsList} the first time anyone calls
+ * <code>getEventSetDescriptors()</code>.</p>
+ */
+ protected EventSetDescriptor eventDescriptors[] = null;
+
+
+ /**
+ * <p>List of <code>EventSetDescriptor</code>s for events of the bean
+ * class being described. Base classes (like this one) will typically
+ * seed this list with event set descriptors for events of a base class
+ * of the bean class, while the <code>initEventSetDescriptors()</code>
+ * method can be used to add events specific to an implementation class.</p>
+ */
+ protected List eventDescriptorsList = new ArrayList();
+
+
+ /**
+ * <p>The cached <code>FacetDescriptor</code>s for this bean class.</p>
+ */
+ protected FacetDescriptor facetDescriptors[] = null;
+
+
+ /**
+ * <p>The 16x16 color icon for this bean class.</p>
+ */
+ protected String iconFileName_C16 = null;
+
+
+ /**
+ * <p>The 32x32 color icon for this bean class.</p>
+ */
+ protected String iconFileName_C32 = null;
+
+
+ /**
+ * <p>The 16x16 monochrome icon for this bean class.</p>
+ */
+ protected String iconFileName_M16 = null;
+
+
+ /**
+ * <p>The 32x32 monochrome icon for this bean class.</p>
+ */
+ protected String iconFileName_M32 = null;
+
+
+ /**
+ * <p>The cached <code>MethodDescriptor</code>s for this bean class.</p>
+ */
+ protected MethodDescriptor methodDescriptors[] = null;
+
+
+ /**
+ * <p>The cached <code>PropertyDescriptor</code>s for this bean class.
+ * This value is calculated from the contents of
+ * {@link propDescriptorsList} the first time anyone calls
+ * <code>getPropertyDescriptors()</code>.</p>
+ */
+ protected PropertyDescriptor propDescriptors[] = null;
+
+
+ /**
+ * <p>List of <code>PropertyDescriptor</code>s for properties of the bean
+ * class being described. Base classes (like this one) will typically
+ * seed this list with propery descriptors for properties of a base class
+ * of the bean class, while the <code>annotatePropertyDescriptors()</code>
+ * method can be used to add properties specific to an implementation class.</p>
+ */
+ protected List propDescriptorsList = new ArrayList();
+
+
+ // -------------------------------------------------------- BeanInfo Methods
+
+
+ /**
+ * <p>Return the <code>BeanDescriptor</code> for this bean class.</p>
+ */
+ public BeanDescriptor getBeanDescriptor() {
+ return this.beanDescriptor;
+ }
+
+
+ /**
+ * <p>Return the zero-relative index of the default event for this
+ * bean class, or -1 if there is no default event.</p>
+ */
+ public int getDefaultEventIndex() {
+ return this.defaultEventIndex;
+ }
+
+
+ /**
+ * <p>Return the zero-relative index of the default property for this
+ * bean class, or -1 if there is no default property.</p>
+ */
+ public int getDefaultPropertyIndex() {
+ return this.defaultPropertyIndex;
+ }
+
+
+ /**
+ * <p>Return the <code>EventSetDescriptor</code>s for this bean class.</p>
+ */
+ public EventSetDescriptor[] getEventSetDescriptors() {
+ if (this.eventDescriptors == null) {
+ this.eventDescriptors = (EventSetDescriptor[])
+ eventDescriptorsList.toArray(new EventSetDescriptor[eventDescriptorsList.size()]);
+ }
+ return this.eventDescriptors;
+ }
+
+
+ /**
+ * <p>Return the image for the specified icon, if any; otherwise
+ * (or if there was an error loading the image) return <code>null</code>.</p>
+ *
+ * @param kind Kind of icon to return
+ */
+ public Image getIcon(int kind) {
+
+ String name = null;
+ switch (kind) {
+ case ICON_COLOR_16x16:
+ name = iconFileName_C16;
+ break;
+ case ICON_COLOR_32x32:
+ name = iconFileName_C32;
+ break;
+ case ICON_MONO_16x16:
+ name = iconFileName_M16;
+ break;
+ case ICON_MONO_32x32:
+ name = iconFileName_M32;
+ break;
+ default:
+ break;
+ }
+ Image image = null;
+ if (name != null) {
+ image = loadImage(name + ".png");
+ if (image == null) {
+ image = loadImage(name + ".gif");
+ }
+ }
+ return image;
+
+ }
+
+
+ /**
+ * <p>Return the <code>MethodDescriptor</code>s for this bean class.</p>
+ */
+ public MethodDescriptor[] getMethodDescriptors() {
+ return this.methodDescriptors;
+ }
+
+
+ /**
+ * <p>Return the <code>PropertyDescriptor</code>s for this bean class.</p>
+ */
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ if (this.propDescriptors == null) {
+ this.propDescriptors = (PropertyDescriptor[])
+ propDescriptorsList.toArray(new PropertyDescriptor[propDescriptorsList.size()]);
+ }
+ return this.propDescriptors;
+ }
+
+
+ // ------------------------------------------------------- Protected Methods
+
+
+ /**
+ * <p>Calculate and store icon image names for the bean class that is
+ * being described.</p>
+ */
+ protected void calculateImageNames() {
+
+ String name = beanClass.getName();
+ int period = name.lastIndexOf('.');
+ if (period >= 0) {
+ name = name.substring(period + 1);
+ }
+ iconFileName_C16 = name + "_C16";
+ iconFileName_C32 = name + "_C32";
+ iconFileName_M16 = name + "_M16";
+ iconFileName_M32 = name + "_M32";
+
+ }
+
+
+ /**
+ * <p>Look up and return the event set descriptor for the specified event set
+ * name, if any; otherwise, return <code>null</code>.</p>
+ *
+ * @param name Name of the event set to look up
+ */
+ protected EventSetDescriptor eventSetDescriptor(String name) {
+
+ if (eventDescriptors != null) {
+ for (int i = 0; i < eventDescriptors.length; i++) {
+ if (name.equals(eventDescriptors[i].getName())) {
+ return eventDescriptors[i];
+ }
+ }
+ } else if (eventDescriptorsList != null) {
+ Iterator items = eventDescriptorsList.iterator();
+ while (items.hasNext()) {
+ EventSetDescriptor item = (EventSetDescriptor) items.next();
+ if (name.equals(item.getName())) {
+ return item;
+ }
+ }
+ }
+ return null;
+
+ }
+
+
+ /**
+ * <p>Initialize the basic bean descriptor for this bean class.</p>
+ */
+ protected void initBeanDescriptor() throws Exception {
+
+ BeanDescriptor bd = new BeanDescriptor(beanClass);
+ String simple = simpleName();
+
+ bd.setDisplayName(bundle.getString(simple + ".displayName"));
+ bd.setShortDescription(bundle.getString(simple + ".shortDescription"));
+ bd.setExpert(false);
+ bd.setHidden(false);
+ bd.setPreferred(false);
+
+ initFacetDescriptors();
+ bd.setValue(Constants.BeanDescriptor.FACET_DESCRIPTORS,
+ facetDescriptors);
+
+ beanDescriptor = bd;
+
+ }
+
+
+ /**
+ * <p>Initialize event set descriptors for the events exposed by
+ * <code>javax.faces.component.UIComponent</code>
+ * to the list of event set descriptors we are accumulating.</p>
+ */
+ protected void initEventSetDescriptors() throws Exception {
+
+ ; // UIComponent has no events of its own
+
+ }
+
+ /**
+ * <p>Initialize the facet descriptors for this bean class.</p>
+ */
+ protected void initFacetDescriptors() throws Exception {
+
+ facetDescriptors = new FacetDescriptor[0];
+
+ }
+
+
+ /**
+ * <p>Initialize the method descriptors for this bean class.</p>
+ */
+ protected void initMethodDescriptors() throws Exception {
+
+ ; // Null return value means use introspection
+
+ }
+
+
+ /**
+ * <p>Initialize property descriptors for the properties exposed by
+ * <code>javax.faces.component.UIComponent</code>
+ * to the list of property descriptors we are accumulating. In addition,
+ * if the bean class supports the <code>style</code> and <code>styleClass</code>
+ * properties (a normal convention), add descriptors for those as well.</p>
+ */
+ protected void initPropertyDescriptors() throws Exception {
+
+ AttributeDescriptor ad = null;
+ PropertyDescriptor pd = null;
+
+ pd = new PropertyDescriptor("attributes", beanClass, "getAttributes", null);
+ pd.setDisplayName(bundle.getString("UIComponent.attributes.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.attributes.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("childCount", beanClass, "getChildCount", null);
+ pd.setDisplayName(bundle.getString("UIComponent.childCount.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.childCount.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("children", beanClass, "getChildren", null);
+ pd.setDisplayName(bundle.getString("UIComponent.children.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.children.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("facets", beanClass, "getFacets", null);
+ pd.setDisplayName(bundle.getString("UIComponent.facets.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.facets.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("family", beanClass, "getFamily", null);
+ pd.setDisplayName(bundle.getString("UIComponent.family.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.family.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("id", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.id.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.id.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("id", false, null, false);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.GENERAL);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("parent", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.parent.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.parent.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("rendered", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.rendered.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.rendered.shortDescription"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("rendererType", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.rendererType.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.rendererType.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("rendersChildren", beanClass, "getRendersChildren", null);
+ pd.setDisplayName(bundle.getString("UIComponent.rendersChildren.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.rendersChildren.shortDescription"));
+ pd.setExpert(true);
+ pd.setHidden(true);
+ pd.setPreferred(false);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.INTERNAL);
+ propDescriptorsList.add(pd);
+
+ try {
+ beanClass.getMethod("getStyle", null);
+ pd = new PropertyDescriptor("style", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.style.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.style.shortDescription"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.css.CssStylePropertyEditor"));
+ ad = new AttributeDescriptor("style", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
+ propDescriptorsList.add(pd);
+ } catch (NoSuchMethodException e) {
+ ; // No such method, so do not add a property descriptor
+ }
+
+ try {
+ beanClass.getMethod("getStyleClass", null);
+ pd = new PropertyDescriptor("styleClass", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.styleClass.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.styleClass.shortDescription"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.property.ChooseManyReferenceDataPropertyEditor"));
+ pd.setValue("referenceDataDefiner", com.sun.jsfcl.std.reference.ReferenceDataManager.STYLE_CLASSES);
+ ad = new AttributeDescriptor("styleClass", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
+ propDescriptorsList.add(pd);
+ } catch (NoSuchMethodException e) {
+ ; // No such method, so do not add a property descriptor
+ }
+
+ }
+
+
+ /**
+ * <p>Initialize common property descriptors for JavaScript
+ * event handlers.</p>
+ */
+ protected void initPropertyDescriptorsEvent() throws Exception {
+
+ AttributeDescriptor ad = null;
+ PropertyDescriptor pd = null;
+
+ pd = new PropertyDescriptor("onclick", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onclick.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onclick.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onclick", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("ondblclick", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.ondblclick.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.ondblclick.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("ondblclick", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onkeydown", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onkeydown.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onkeydown.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onkeydown", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onkeypress", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onkeypress.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onkeypress.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onkeypress", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onkeyup", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onkeyup.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onkeyup.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onkeyup", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onmousedown", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onmousedown.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onmousedown.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onmousedown", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onmousemove", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onmousemove.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onmousemove.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onmousemove", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onmouseout", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onmouseout.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onmouseout.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onmouseout", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onmouseover", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onmouseover.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onmouseover.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onmouseover", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onmouseup", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onmouseup.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onmouseup.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onmouseup", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ }
+
+
+ /**
+ * <p>Initialize common property descriptors for JavaScript
+ * event handlers related to gaining and losing focus.</p>
+ */
+ protected void initPropertyDescriptorsFocus() throws Exception {
+
+ AttributeDescriptor ad = null;
+ PropertyDescriptor pd = null;
+
+ pd = new PropertyDescriptor("accesskey", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.accesskey.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.accesskey.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.StringPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("accesskey", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onblur", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onblur.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onblur.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onblur", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onfocus", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onfocus.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onfocus.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onfocus", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("tabindex", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.tabindex.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.tabindex.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.IntegerPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("tabindex", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
+ pd.setValue("minValue", new Integer(0));
+ pd.setValue("maxValue", new Integer(Short.MAX_VALUE));
+ propDescriptorsList.add(pd);
+
+ }
+
+
+ /**
+ * <p>Initialize common property descriptors for internationalization
+ * attributes.</p>
+ */
+ protected void initPropertyDescriptorsI18n() throws Exception {
+
+ AttributeDescriptor ad = null;
+ PropertyDescriptor pd = null;
+
+ pd = new PropertyDescriptor("dir", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.dir.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.dir.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.property.ChooseOneReferenceDataPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("dir", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
+ pd.setValue("referenceDataDefiner", ReferenceDataManager.TEXT_DIRECTIONS);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("lang", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.lang.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.lang.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.property.ChooseOneReferenceDataPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("lang", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.ADVANCED);
+ pd.setValue("referenceDataDefiner", ReferenceDataManager.LANGUAGE_CODES);
+ propDescriptorsList.add(pd);
+
+ }
+
+
+ /**
+ * <p>Initialize common property descriptors for input related
+ * attributes.</p>
+ */
+ protected void initPropertyDescriptorsInput() throws Exception {
+
+ AttributeDescriptor ad = null;
+ PropertyDescriptor pd = null;
+
+ pd = new PropertyDescriptor("disabled", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.disabled.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.disabled.shortDescription"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("disabled", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onchange", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onchange.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onchange.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onchange", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("onselect", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.onselect.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.onselect.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.jsfcl.std.JavaScriptPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("onselect", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.JAVASCRIPT);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("readonly", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.readonly.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.readonly.shortDescription"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("readonly", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
+ propDescriptorsList.add(pd);
+
+ }
+
+
+ /**
+ * <p>Initialize common property descriptors for text related
+ * attributes.</p>
+ */
+ protected void initPropertyDescriptorsText() throws Exception {
+
+ AttributeDescriptor ad = null;
+ PropertyDescriptor pd = null;
+
+ pd = new PropertyDescriptor("alt", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.alt.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.alt.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.StringPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("alt", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("maxlength", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.maxlength.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.maxlength.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.IntegerPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("maxlength", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.DATA);
+ pd.setValue("minValue", new Integer(0));
+ pd.setValue("unsetValue", new Integer(Integer.MIN_VALUE));
+ propDescriptorsList.add(pd);
+
+ pd = new PropertyDescriptor("size", beanClass);
+ pd.setDisplayName(bundle.getString("UIComponent.size.displayName"));
+ pd.setShortDescription(bundle.getString("UIComponent.size.shortDescription"));
+ pd.setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.IntegerPropertyEditor"));
+ pd.setExpert(false);
+ pd.setHidden(false);
+ pd.setPreferred(false);
+ ad = new AttributeDescriptor("size", false, null, true);
+ pd.setValue(Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR, ad);
+ pd.setValue(Constants.PropertyDescriptor.CATEGORY, Categories.APPEARANCE);
+ pd.setValue("minValue", new Integer(0));
+ pd.setValue("unsetValue", new Integer(Integer.MIN_VALUE));
+ propDescriptorsList.add(pd);
+
+ }
+
+
+ /**
+ * <p>Load and return the class with the specified fully qualified name,
+ * or return <code>null</code> if the class cannot be loaded.</p>
+ *
+ * @param name Fully qualified class name
+ */
+ protected Class loadClass(String name) {
+ try {
+ return Class.forName(name);
+ } catch (ClassNotFoundException e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * <p>Look up and return the property descriptor for the specified property
+ * name, if any; otherwise, return <code>null</code>.</p>
+ *
+ * @param name Name of the property to look up
+ */
+ protected PropertyDescriptor propertyDescriptor(String name) {
+
+ if (propDescriptors != null) {
+ for (int i = 0; i < propDescriptors.length; i++) {
+ if (name.equals(propDescriptors[i].getName())) {
+ return propDescriptors[i];
+ }
+ }
+ } else if (propDescriptorsList != null) {
+ Iterator items = propDescriptorsList.iterator();
+ while (items.hasNext()) {
+ PropertyDescriptor item = (PropertyDescriptor) items.next();
+ if (name.equals(item.getName())) {
+ return item;
+ }
+ }
+ }
+ return null;
+
+ }
+
+
+ /**
+ * <p>Return the simple class name for the bean class we are describing.</p>
+ */
+ protected String simpleName() {
+
+ String name = beanClass.getName();
+ int period = name.lastIndexOf('.');
+ if (period >= 0) {
+ name = name.substring(period + 1);
+ }
+ return name;
+
+ }
+
+
+ // --------------------------------------------------------- Private Methods
+
+
+}
Modified: struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/AbstractDesignInfo.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/AbstractDesignInfo.java?rev=381930&r1=381929&r2=381930&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/AbstractDesignInfo.java (original)
+++ struts/shale/trunk/core-library/src/designtime/org/apache/shale/design/AbstractDesignInfo.java Tue Feb 28 22:41:06 2006
@@ -1,44 +1,44 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id$
- */
-
-package org.apache.shale.design;
-
-import com.sun.rave.designtime.impl.BasicDesignInfo;
-
-/**
- * <p>Convenience base class for <code>DesignInfo</code> implementations for
- * JavaServer Faces components.</p>
- */
-public class AbstractDesignInfo extends BasicDesignInfo {
-
-
- // ------------------------------------------------------------ Constructors
-
-
- /**
- * <p>Creates a new <code>DesignInfo</code> instance for the specified
- * bean class.</p>
- *
- * @param clazz Bean class for which to create a <code>DesignInfo</code>
- */
- public AbstractDesignInfo(Class clazz) {
- super(clazz);
- }
-
-
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.design;
+
+import com.sun.rave.designtime.impl.BasicDesignInfo;
+
+/**
+ * <p>Convenience base class for <code>DesignInfo</code> implementations for
+ * JavaServer Faces components.</p>
+ */
+public class AbstractDesignInfo extends BasicDesignInfo {
+
+
+ // ------------------------------------------------------------ Constructors
+
+
+ /**
+ * <p>Creates a new <code>DesignInfo</code> instance for the specified
+ * bean class.</p>
+ *
+ * @param clazz Bean class for which to create a <code>DesignInfo</code>
+ */
+ public AbstractDesignInfo(Class clazz) {
+ super(clazz);
+ }
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org