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: package org.netbeans.modules.visualweb.faces.dt.component;
042:
043: import java.awt.Image;
044: import java.beans.BeanDescriptor;
045: import java.beans.BeanInfo;
046: import java.beans.IntrospectionException;
047: import java.beans.PropertyDescriptor;
048: import java.util.Locale;
049: import java.util.ResourceBundle;
050:
051: import com.sun.rave.designtime.CategoryDescriptor;
052: import com.sun.rave.designtime.Constants;
053: import com.sun.rave.designtime.faces.FacetDescriptor;
054: import com.sun.rave.designtime.markup.AttributeDescriptor;
055:
056: import org.netbeans.modules.visualweb.faces.dt.HtmlBeanInfoBase;
057: import org.netbeans.modules.visualweb.faces.dt.BeanDescriptorBase;
058: import org.netbeans.modules.visualweb.faces.dt.PropertyDescriptorBase;
059:
060: abstract class EncodingComponentBeanInfoBase extends HtmlBeanInfoBase {
061:
062: protected static ResourceBundle resources = ResourceBundle
063: .getBundle(
064: "org.netbeans.modules.visualweb.faces.dt.component.Bundle-JSF-base",
065: Locale.getDefault(),
066: EncodingComponentBeanInfoBase.class
067: .getClassLoader());
068:
069: /**
070: * <p>Construct a new <code>EncodingComponentBeanInfoBase</code>.</p>
071: */
072: public EncodingComponentBeanInfoBase() {
073:
074: beanClass = com.sun.rave.faces.component.EncodingComponent.class;
075:
076: iconFileName_C16 = "/org/netbeans/modules/visualweb/faces/dt/component/EncodingComponent_C16";
077: iconFileName_C32 = "/org/netbeans/modules/visualweb/faces/dt/component/EncodingComponent_C32";
078: iconFileName_M16 = "/org/netbeans/modules/visualweb/faces/dt/component/EncodingComponent_M16";
079: iconFileName_M32 = "/org/netbeans/modules/visualweb/faces/dt/component/EncodingComponent_M32";
080:
081: }
082:
083: private BeanDescriptor beanDescriptor;
084:
085: /**
086: * <p>Return the <code>BeanDescriptor</code> for this bean.</p>
087: */
088: public BeanDescriptor getBeanDescriptor() {
089:
090: if (beanDescriptor != null) {
091: return beanDescriptor;
092: }
093:
094: beanDescriptor = new BeanDescriptorBase(beanClass);
095: beanDescriptor.setDisplayName(resources
096: .getString("EncodingComponent_DisplayName"));
097: beanDescriptor.setShortDescription(resources
098: .getString("EncodingComponent_Description"));
099: beanDescriptor.setExpert(false);
100: beanDescriptor.setHidden(false);
101: beanDescriptor.setPreferred(false);
102: beanDescriptor.setValue(
103: Constants.BeanDescriptor.FACET_DESCRIPTORS,
104: getFacetDescriptors());
105: beanDescriptor
106: .setValue(Constants.BeanDescriptor.HELP_KEY,
107: "projrave_ui_elements_palette_jsf-val-conv_set_encoding_component");
108: beanDescriptor.setValue(Constants.BeanDescriptor.INSTANCE_NAME,
109: "encoding");
110: beanDescriptor.setValue(Constants.BeanDescriptor.IS_CONTAINER,
111: Boolean.TRUE);
112: beanDescriptor.setValue(
113: Constants.BeanDescriptor.MARKUP_SECTION, "head");
114: beanDescriptor.setValue(
115: Constants.BeanDescriptor.PROPERTY_CATEGORIES,
116: getCategoryDescriptors());
117: beanDescriptor.setValue(Constants.BeanDescriptor.TAG_NAME,
118: "encoding");
119: beanDescriptor.setValue(Constants.BeanDescriptor.TAGLIB_PREFIX,
120: "j");
121: beanDescriptor.setValue(Constants.BeanDescriptor.TAGLIB_URI,
122: "http://www.sun.com/creator/rave.faces");
123: beanDescriptor.setValue(
124: Constants.BeanDescriptor.TRAY_COMPONENT, Boolean.TRUE);
125: return beanDescriptor;
126:
127: }
128:
129: /**
130: * <p>Return the <code>CategoryDescriptor</code> array for the property categories of this component.</p>
131: */
132: private CategoryDescriptor[] getCategoryDescriptors() {
133:
134: return com.sun.rave.designtime.base.CategoryDescriptors
135: .getDefaultCategoryDescriptors();
136:
137: }
138:
139: /**
140: * <p>The cached facet descriptors.</p>
141: */
142: protected FacetDescriptor[] facetDescriptors;
143:
144: /**
145: * <p>Return the <code>FacetDescriptor</code>s for this bean.</p>
146: */
147: public FacetDescriptor[] getFacetDescriptors() {
148:
149: if (facetDescriptors != null) {
150: return facetDescriptors;
151: }
152: facetDescriptors = new FacetDescriptor[] {};
153: return facetDescriptors;
154:
155: }
156:
157: private PropertyDescriptor[] propDescriptors;
158:
159: /**
160: * <p>Return the <code>PropertyDescriptor</code>s for this bean.</p>
161: */
162: public PropertyDescriptor[] getPropertyDescriptors() {
163:
164: if (propDescriptors != null) {
165: return propDescriptors;
166: }
167: AttributeDescriptor attrib = null;
168:
169: try {
170:
171: PropertyDescriptor prop_value = new PropertyDescriptorBase(
172: "value", beanClass, "getValue", "setValue");
173: prop_value.setDisplayName(resources
174: .getString("EncodingComponent_value_DisplayName"));
175: prop_value.setShortDescription(resources
176: .getString("EncodingComponent_value_Description"));
177: prop_value
178: .setPropertyEditorClass(loadClass("com.sun.rave.propertyeditors.SelectOneDomainEditor"));
179: prop_value.setExpert(false);
180: prop_value.setHidden(false);
181: prop_value.setPreferred(false);
182: attrib = new AttributeDescriptor("value", false, null, true);
183: prop_value.setValue(
184: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
185: attrib);
186: prop_value
187: .setValue(
188: Constants.PropertyDescriptor.CATEGORY,
189: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
190: prop_value
191: .setValue(
192: "com.sun.rave.propertyeditors.DOMAIN_CLASS",
193: com.sun.rave.propertyeditors.domains.CharacterSetsDomain.class);
194:
195: propDescriptors = new PropertyDescriptor[] { prop_value, };
196: return propDescriptors;
197:
198: } catch (IntrospectionException e) {
199: e.printStackTrace();
200: return null;
201: }
202:
203: }
204:
205: }
|