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;
043:
044: import java.beans.IntrospectionException;
045: import java.beans.PropertyDescriptor;
046: import java.util.Locale;
047: import java.util.List;
048: import java.util.ArrayList;
049: import java.util.Arrays;
050: import java.util.ResourceBundle;
051: import com.sun.rave.designtime.Constants;
052: import com.sun.rave.designtime.markup.AttributeDescriptor;
053: import org.netbeans.modules.visualweb.faces.dt.PropertyDescriptorBase;
054: import java.beans.EventSetDescriptor;
055: import java.lang.reflect.Method;
056: import javax.faces.component.UIComponent;
057: import javax.faces.context.FacesContext;
058: import javax.faces.event.ValueChangeEvent;
059: import javax.faces.event.ValueChangeListener;
060: import javax.faces.validator.Validator;
061:
062: public abstract class UIInputBeanInfoBase extends UIOutputBeanInfoBase {
063:
064: protected static ResourceBundle resources = ResourceBundle
065: .getBundle(
066: "org.netbeans.modules.visualweb.faces.dt_1_1.component.Bundle",
067: Locale.getDefault(), UIInputBeanInfoBase.class
068: .getClassLoader());
069:
070: public UIInputBeanInfoBase() {
071: beanClass = javax.faces.component.UIInput.class;
072: defaultPropertyName = "value";
073: }
074:
075: private PropertyDescriptor[] propertyDescriptors;
076:
077: public PropertyDescriptor[] getPropertyDescriptors() {
078:
079: if (propertyDescriptors != null) {
080: return propertyDescriptors;
081: }
082: AttributeDescriptor attrib = null;
083:
084: try {
085:
086: PropertyDescriptor prop_immediate = new PropertyDescriptorBase(
087: "immediate", beanClass, "isImmediate",
088: "setImmediate");
089: prop_immediate.setDisplayName(resources
090: .getString("UIInput_immediate_DisplayName"));
091: prop_immediate.setShortDescription(resources
092: .getString("UIInput_immediate_Description"));
093: prop_immediate.setExpert(false);
094: prop_immediate.setHidden(false);
095: prop_immediate.setPreferred(false);
096: attrib = new AttributeDescriptor("immediate", false, null,
097: true);
098: prop_immediate.setValue(
099: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
100: attrib);
101: prop_immediate
102: .setValue(
103: Constants.PropertyDescriptor.CATEGORY,
104: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
105:
106: PropertyDescriptor prop_localValueSet = new PropertyDescriptorBase(
107: "localValueSet", beanClass, "isLocalValueSet",
108: "setLocalValueSet");
109: prop_localValueSet.setDisplayName(resources
110: .getString("UIInput_localValueSet_DisplayName"));
111: prop_localValueSet.setShortDescription(resources
112: .getString("UIInput_localValueSet_Description"));
113: prop_localValueSet.setExpert(false);
114: prop_localValueSet.setHidden(true);
115: prop_localValueSet.setPreferred(false);
116: prop_localValueSet
117: .setValue(
118: Constants.PropertyDescriptor.CATEGORY,
119: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
120:
121: PropertyDescriptor prop_required = new PropertyDescriptorBase(
122: "required", beanClass, "isRequired", "setRequired");
123: prop_required.setDisplayName(resources
124: .getString("UIInput_required_DisplayName"));
125: prop_required.setShortDescription(resources
126: .getString("UIInput_required_Description"));
127: prop_required.setExpert(false);
128: prop_required.setHidden(false);
129: prop_required.setPreferred(false);
130: attrib = new AttributeDescriptor("required", false, null,
131: true);
132: prop_required.setValue(
133: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
134: attrib);
135: prop_required
136: .setValue(
137: Constants.PropertyDescriptor.CATEGORY,
138: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
139:
140: PropertyDescriptor prop_submittedValue = new PropertyDescriptorBase(
141: "submittedValue", beanClass, "getSubmittedValue",
142: "setSubmittedValue");
143: prop_submittedValue.setDisplayName(resources
144: .getString("UIInput_submittedValue_DisplayName"));
145: prop_submittedValue.setShortDescription(resources
146: .getString("UIInput_submittedValue_Description"));
147: prop_submittedValue.setExpert(false);
148: prop_submittedValue.setHidden(true);
149: prop_submittedValue.setPreferred(false);
150: prop_submittedValue
151: .setValue(
152: Constants.PropertyDescriptor.CATEGORY,
153: com.sun.rave.designtime.base.CategoryDescriptors.INTERNAL);
154:
155: PropertyDescriptor prop_validator = new PropertyDescriptorBase(
156: "validator", beanClass, "getValidator",
157: "setValidator");
158: prop_validator.setDisplayName(resources
159: .getString("UIInput_validator_DisplayName"));
160: prop_validator.setShortDescription(resources
161: .getString("UIInput_validator_Description"));
162: prop_validator
163: .setPropertyEditorClass(com.sun.rave.propertyeditors.ValidatorPropertyEditor.class);
164: prop_validator.setExpert(false);
165: prop_validator.setHidden(false);
166: prop_validator.setPreferred(false);
167: attrib = new AttributeDescriptor("validator", false, null,
168: true);
169: prop_validator.setValue(
170: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
171: attrib);
172: prop_validator
173: .setValue(
174: Constants.PropertyDescriptor.CATEGORY,
175: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
176:
177: PropertyDescriptor prop_valueChangeListener = new PropertyDescriptorBase(
178: "valueChangeListener", beanClass,
179: "getValueChangeListener", "setValueChangeListener");
180: prop_valueChangeListener
181: .setDisplayName(resources
182: .getString("UIInput_valueChangeListener_DisplayName"));
183: prop_valueChangeListener
184: .setShortDescription(resources
185: .getString("UIInput_valueChangeListener_Description"));
186: prop_valueChangeListener
187: .setPropertyEditorClass(com.sun.rave.propertyeditors.MethodBindingPropertyEditor.class);
188: prop_valueChangeListener.setExpert(false);
189: prop_valueChangeListener.setHidden(false);
190: prop_valueChangeListener.setPreferred(false);
191: attrib = new AttributeDescriptor("valueChangeListener",
192: false, null, true);
193: prop_valueChangeListener.setValue(
194: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
195: attrib);
196: prop_valueChangeListener
197: .setValue(
198: Constants.PropertyDescriptor.CATEGORY,
199: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
200:
201: List<PropertyDescriptor> propertyDescriptorList = new ArrayList<PropertyDescriptor>();
202: propertyDescriptorList.add(prop_immediate);
203: propertyDescriptorList.add(prop_localValueSet);
204: propertyDescriptorList.add(prop_required);
205: propertyDescriptorList.add(prop_submittedValue);
206: propertyDescriptorList.add(prop_validator);
207: propertyDescriptorList.add(prop_valueChangeListener);
208:
209: propertyDescriptorList.addAll(Arrays.asList(super
210: .getPropertyDescriptors()));
211: propertyDescriptors = propertyDescriptorList
212: .toArray(new PropertyDescriptor[propertyDescriptorList
213: .size()]);
214: return propertyDescriptors;
215:
216: } catch (IntrospectionException e) {
217: e.printStackTrace();
218: return null;
219: }
220:
221: }
222:
223: private EventSetDescriptor[] eventSetDescriptors;
224:
225: public EventSetDescriptor[] getEventSetDescriptors() {
226: if (eventSetDescriptors == null) {
227: try {
228: eventSetDescriptors = new EventSetDescriptor[] {
229: new EventSetDescriptor(
230: "validate",
231: Validator.class, //NOI18N
232: new Method[] { Validator.class
233: .getMethod(
234: "validate", //NOI18N
235: new Class[] {
236: FacesContext.class,
237: UIComponent.class,
238: Object.class }) },
239: null, null),
240: new EventSetDescriptor(
241: "valueChange",
242: ValueChangeListener.class, //NOI18N
243: new Method[] { ValueChangeListener.class
244: .getMethod(
245: "processValueChange", //NOI18N
246: new Class[] { ValueChangeEvent.class }) },
247: null, null), };
248: eventSetDescriptors[0].setValue(
249: Constants.EventSetDescriptor.BINDING_PROPERTY,
250: getPropertyDescriptor("validator")); //NOI18N
251: eventSetDescriptors[0].setValue(
252: Constants.EventDescriptor.DEFAULT_EVENT_BODY,
253: resources.getString("UIInput_validateHandler")); //NOI18N
254: eventSetDescriptors[0]
255: .setValue(
256: Constants.EventDescriptor.PARAMETER_NAMES,
257: new String[] { "context", "component",
258: "value" });
259: eventSetDescriptors[0]
260: .setValue(
261: Constants.EventDescriptor.REQUIRED_IMPORTS,
262: new String[] {
263: "javax.faces.application.FacesMessage",
264: "javax.faces.validator.ValidatorException" });
265: eventSetDescriptors[1].setValue(
266: Constants.EventSetDescriptor.BINDING_PROPERTY,
267: getPropertyDescriptor("valueChangeListener")); //NOI18N
268: eventSetDescriptors[1].setValue(
269: Constants.EventDescriptor.PARAMETER_NAMES,
270: new String[] { "vce" });
271: } catch (Exception e) {
272: e.printStackTrace();
273: }
274: }
275: return eventSetDescriptors;
276: }
277:
278: }
|