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 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_1.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 = "/org/netbeans/modules/visualweb/faces/dt_1_1/component/UICommand_C16";
073: iconFileName_C32 = "/org/netbeans/modules/visualweb/faces/dt_1_1/component/UICommand_C32";
074: iconFileName_M16 = "/org/netbeans/modules/visualweb/faces/dt_1_1/component/UICommand_M16";
075: iconFileName_M32 = "/org/netbeans/modules/visualweb/faces/dt_1_1/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_action = new PropertyDescriptorBase(
090: "action", beanClass, "getAction", "setAction");
091: prop_action.setDisplayName(resources
092: .getString("UICommand_action_DisplayName"));
093: prop_action.setShortDescription(resources
094: .getString("UICommand_action_Description"));
095: prop_action
096: .setPropertyEditorClass(com.sun.rave.propertyeditors.MethodBindingPropertyEditor.class);
097: prop_action.setExpert(false);
098: prop_action.setHidden(true);
099: prop_action.setPreferred(false);
100: attrib = new AttributeDescriptor("action", false, null,
101: true);
102: prop_action.setValue(
103: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
104: attrib);
105: prop_action
106: .setValue(
107: Constants.PropertyDescriptor.CATEGORY,
108: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
109:
110: PropertyDescriptor prop_actionListener = new PropertyDescriptorBase(
111: "actionListener", beanClass, "getActionListener",
112: "setActionListener");
113: prop_actionListener.setDisplayName(resources
114: .getString("UICommand_actionListener_DisplayName"));
115: prop_actionListener.setShortDescription(resources
116: .getString("UICommand_actionListener_Description"));
117: prop_actionListener
118: .setPropertyEditorClass(com.sun.rave.propertyeditors.MethodBindingPropertyEditor.class);
119: prop_actionListener.setExpert(false);
120: prop_actionListener.setHidden(false);
121: prop_actionListener.setPreferred(false);
122: attrib = new AttributeDescriptor("actionListener", false,
123: null, true);
124: prop_actionListener.setValue(
125: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
126: attrib);
127: prop_actionListener
128: .setValue(
129: Constants.PropertyDescriptor.CATEGORY,
130: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
131:
132: PropertyDescriptor prop_immediate = new PropertyDescriptorBase(
133: "immediate", beanClass, "isImmediate",
134: "setImmediate");
135: prop_immediate.setDisplayName(resources
136: .getString("UICommand_immediate_DisplayName"));
137: prop_immediate.setShortDescription(resources
138: .getString("UICommand_immediate_Description"));
139: prop_immediate.setExpert(false);
140: prop_immediate.setHidden(false);
141: prop_immediate.setPreferred(false);
142: attrib = new AttributeDescriptor("immediate", false, null,
143: true);
144: prop_immediate.setValue(
145: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
146: attrib);
147: prop_immediate
148: .setValue(
149: Constants.PropertyDescriptor.CATEGORY,
150: com.sun.rave.designtime.base.CategoryDescriptors.ADVANCED);
151:
152: PropertyDescriptor prop_value = new PropertyDescriptorBase(
153: "value", beanClass, "getValue", "setValue");
154: prop_value.setDisplayName(resources
155: .getString("UICommand_value_DisplayName"));
156: prop_value.setShortDescription(resources
157: .getString("UICommand_value_Description"));
158: prop_value
159: .setPropertyEditorClass(org.netbeans.modules.visualweb.faces.dt.std.ValueBindingPropertyEditor.class);
160: prop_value.setExpert(false);
161: prop_value.setHidden(false);
162: prop_value.setPreferred(false);
163: attrib = new AttributeDescriptor("value", false, null, true);
164: prop_value.setValue(
165: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
166: attrib);
167: prop_value
168: .setValue(
169: Constants.PropertyDescriptor.CATEGORY,
170: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
171: prop_value.setValue("ignoreIsBound", "true");
172:
173: List<PropertyDescriptor> propertyDescriptorList = new ArrayList<PropertyDescriptor>();
174: propertyDescriptorList.add(prop_action);
175: propertyDescriptorList.add(prop_actionListener);
176: propertyDescriptorList.add(prop_immediate);
177: propertyDescriptorList.add(prop_value);
178:
179: propertyDescriptorList.addAll(Arrays.asList(super
180: .getPropertyDescriptors()));
181: propertyDescriptors = propertyDescriptorList
182: .toArray(new PropertyDescriptor[propertyDescriptorList
183: .size()]);
184: return propertyDescriptors;
185:
186: } catch (IntrospectionException e) {
187: e.printStackTrace();
188: return null;
189: }
190:
191: }
192:
193: private EventSetDescriptor[] eventSetDescriptors;
194:
195: public EventSetDescriptor[] getEventSetDescriptors() {
196: if (eventSetDescriptors == null) {
197: try {
198: eventSetDescriptors = new EventSetDescriptor[] {
199: new EventSetDescriptor("action", Action.class, //NOI18N
200: new Method[] { Action.class.getMethod(
201: "action", new Class[] {}) }, //NOI18N
202: null, null),
203: new EventSetDescriptor(
204: "actionListener",
205: ActionListener.class, //NOI18N
206: new Method[] { ActionListener.class
207: .getMethod(
208: "processAction",
209: new Class[] { ActionEvent.class }) }, //NOI18N
210: null, null) };
211: eventSetDescriptors[0].setValue(
212: Constants.EventSetDescriptor.BINDING_PROPERTY,
213: getPropertyDescriptor("action")); //NOI18N
214: String defaultHandler = resources
215: .getString("UICommand_actionHandler"); // NOI18N
216: eventSetDescriptors[0].setValue(
217: Constants.EventDescriptor.DEFAULT_EVENT_BODY,
218: defaultHandler);
219: eventSetDescriptors[1].setValue(
220: Constants.EventSetDescriptor.BINDING_PROPERTY,
221: getPropertyDescriptor("actionListener")); //NOI18N
222: eventSetDescriptors[1].setHidden(true);
223: } catch (Exception e) {
224: e.printStackTrace();
225: }
226: }
227: return eventSetDescriptors;
228: }
229:
230: }
|