001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.visualweb.faces.dt_1_2.component;
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 com.sun.rave.faces.event.Action;
055: import java.beans.EventSetDescriptor;
056: import java.lang.reflect.Method;
057: import javax.faces.event.ActionEvent;
058: import javax.faces.event.ActionListener;
059:
060: public abstract class UICommandBeanInfoBase extends
061: UIComponentBeanInfoBase {
062:
063: protected static ResourceBundle resources = ResourceBundle
064: .getBundle(
065: "org.netbeans.modules.visualweb.faces.dt_1_2.component.Bundle",
066: Locale.getDefault(), UICommandBeanInfoBase.class
067: .getClassLoader());
068:
069: public UICommandBeanInfoBase() {
070: beanClass = javax.faces.component.UICommand.class;
071: defaultPropertyName = "value";
072: iconFileName_C16 = "/com/sun/rave/faces/dt_1_2/component/UICommand_C16";
073: iconFileName_C32 = "/com/sun/rave/faces/dt_1_2/component/UICommand_C32";
074: iconFileName_M16 = "/com/sun/rave/faces/dt_1_2/component/UICommand_M16";
075: iconFileName_M32 = "/com/sun/rave/faces/dt_1_2/component/UICommand_M32";
076: }
077:
078: private PropertyDescriptor[] propertyDescriptors;
079:
080: public PropertyDescriptor[] getPropertyDescriptors() {
081:
082: if (propertyDescriptors != null) {
083: return propertyDescriptors;
084: }
085: AttributeDescriptor attrib = null;
086:
087: try {
088:
089: PropertyDescriptor prop_actionExpression = new PropertyDescriptorBase(
090: "actionExpression", beanClass, "getAction",
091: "setAction");
092: prop_actionExpression
093: .setDisplayName(resources
094: .getString("UICommand_actionExpression_DisplayName"));
095: prop_actionExpression
096: .setShortDescription(resources
097: .getString("UICommand_actionExpression_Description"));
098: prop_actionExpression
099: .setPropertyEditorClass(com.sun.rave.propertyeditors.MethodBindingPropertyEditor.class);
100: prop_actionExpression.setExpert(false);
101: prop_actionExpression.setHidden(true);
102: prop_actionExpression.setPreferred(false);
103: attrib = new AttributeDescriptor("action", false, null,
104: true);
105: prop_actionExpression.setValue(
106: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
107: attrib);
108: prop_actionExpression
109: .setValue(
110: Constants.PropertyDescriptor.CATEGORY,
111: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
112:
113: PropertyDescriptor prop_actionListener = new PropertyDescriptorBase(
114: "actionListener", beanClass, "getActionListener",
115: "setActionListener");
116: prop_actionListener.setDisplayName(resources
117: .getString("UICommand_actionListener_DisplayName"));
118: prop_actionListener.setShortDescription(resources
119: .getString("UICommand_actionListener_Description"));
120: prop_actionListener
121: .setPropertyEditorClass(com.sun.rave.propertyeditors.MethodBindingPropertyEditor.class);
122: prop_actionListener.setExpert(false);
123: prop_actionListener.setHidden(false);
124: prop_actionListener.setPreferred(false);
125: attrib = new AttributeDescriptor("actionListener", false,
126: null, true);
127: prop_actionListener.setValue(
128: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
129: attrib);
130: prop_actionListener
131: .setValue(
132: Constants.PropertyDescriptor.CATEGORY,
133: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
134:
135: PropertyDescriptor prop_immediate = new PropertyDescriptorBase(
136: "immediate", beanClass, "isImmediate",
137: "setImmediate");
138: prop_immediate.setDisplayName(resources
139: .getString("UICommand_immediate_DisplayName"));
140: prop_immediate.setShortDescription(resources
141: .getString("UICommand_immediate_Description"));
142: prop_immediate.setExpert(false);
143: prop_immediate.setHidden(false);
144: prop_immediate.setPreferred(false);
145: attrib = new AttributeDescriptor("immediate", false, null,
146: true);
147: prop_immediate.setValue(
148: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
149: attrib);
150: prop_immediate
151: .setValue(
152: Constants.PropertyDescriptor.CATEGORY,
153: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
154:
155: PropertyDescriptor prop_value = new PropertyDescriptorBase(
156: "value", beanClass, "getValue", "setValue");
157: prop_value.setDisplayName(resources
158: .getString("UICommand_value_DisplayName"));
159: prop_value.setShortDescription(resources
160: .getString("UICommand_value_Description"));
161: prop_value
162: .setPropertyEditorClass(org.netbeans.modules.visualweb.faces.dt.std.ValueBindingPropertyEditor.class);
163: prop_value.setExpert(false);
164: prop_value.setHidden(false);
165: prop_value.setPreferred(false);
166: attrib = new AttributeDescriptor("value", false, null, true);
167: prop_value.setValue(
168: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
169: attrib);
170: prop_value
171: .setValue(
172: Constants.PropertyDescriptor.CATEGORY,
173: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
174: prop_value.setValue("ignoreIsBound", "true");
175:
176: List<PropertyDescriptor> propertyDescriptorList = new ArrayList<PropertyDescriptor>();
177: propertyDescriptorList.add(prop_actionExpression);
178: propertyDescriptorList.add(prop_actionListener);
179: propertyDescriptorList.add(prop_immediate);
180: propertyDescriptorList.add(prop_value);
181:
182: propertyDescriptorList.addAll(Arrays.asList(super
183: .getPropertyDescriptors()));
184: propertyDescriptors = propertyDescriptorList
185: .toArray(new PropertyDescriptor[propertyDescriptorList
186: .size()]);
187: return propertyDescriptors;
188:
189: } catch (IntrospectionException e) {
190: e.printStackTrace();
191: return null;
192: }
193:
194: }
195:
196: private EventSetDescriptor[] eventSetDescriptors;
197:
198: public EventSetDescriptor[] getEventSetDescriptors() {
199: if (eventSetDescriptors == null) {
200: try {
201: eventSetDescriptors = new EventSetDescriptor[] {
202: new EventSetDescriptor("action", Action.class, //NOI18N
203: new Method[] { Action.class.getMethod(
204: "action", new Class[] {}) }, //NOI18N
205: null, null),
206: new EventSetDescriptor(
207: "actionListener",
208: ActionListener.class, //NOI18N
209: new Method[] { ActionListener.class
210: .getMethod(
211: "processAction",
212: new Class[] { ActionEvent.class }) }, //NOI18N
213: null, null) };
214: eventSetDescriptors[0].setValue(
215: Constants.EventSetDescriptor.BINDING_PROPERTY,
216: getPropertyDescriptor("actionExpression")); //NOI18N
217: String defaultHandler = resources
218: .getString("UICommand_actionHandler"); // NOI18N
219: eventSetDescriptors[0].setValue(
220: Constants.EventDescriptor.DEFAULT_EVENT_BODY,
221: defaultHandler);
222: eventSetDescriptors[1].setValue(
223: Constants.EventSetDescriptor.BINDING_PROPERTY,
224: getPropertyDescriptor("actionListener")); //NOI18N
225: eventSetDescriptors[1].setHidden(true);
226: } catch (Exception e) {
227: e.printStackTrace();
228: }
229: }
230: return eventSetDescriptors;
231: }
232:
233: }
|