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.awt.Image;
045: import java.beans.BeanDescriptor;
046: import java.beans.BeanInfo;
047: import java.beans.IntrospectionException;
048: import java.beans.PropertyDescriptor;
049: import java.util.Locale;
050: import java.util.List;
051: import java.util.ArrayList;
052: import java.util.Arrays;
053: import java.util.ResourceBundle;
054:
055: import com.sun.rave.designtime.CategoryDescriptor;
056: import com.sun.rave.designtime.Constants;
057: import com.sun.rave.designtime.faces.FacetDescriptor;
058: import com.sun.rave.designtime.markup.AttributeDescriptor;
059:
060: import org.netbeans.modules.visualweb.faces.dt.HtmlBeanInfoBase;
061: import org.netbeans.modules.visualweb.faces.dt.BeanDescriptorBase;
062: import org.netbeans.modules.visualweb.faces.dt.PropertyDescriptorBase;
063:
064: public abstract class UIDataBeanInfoBase extends
065: UIComponentBeanInfoBase {
066:
067: protected static ResourceBundle resources = ResourceBundle
068: .getBundle(
069: "org.netbeans.modules.visualweb.faces.dt_1_1.component.Bundle",
070: Locale.getDefault(), UIDataBeanInfoBase.class
071: .getClassLoader());
072:
073: public UIDataBeanInfoBase() {
074: beanClass = javax.faces.component.UIData.class;
075: }
076:
077: private BeanDescriptor beanDescriptor;
078:
079: public BeanDescriptor getBeanDescriptor() {
080:
081: if (beanDescriptor != null) {
082: return beanDescriptor;
083: }
084:
085: beanDescriptor = new BeanDescriptorBase(beanClass);
086: beanDescriptor.setDisplayName(resources
087: .getString("UIData_DisplayName"));
088: beanDescriptor.setShortDescription(resources
089: .getString("UIData_Description"));
090: beanDescriptor.setExpert(false);
091: beanDescriptor.setHidden(false);
092: beanDescriptor.setPreferred(false);
093: beanDescriptor.setValue(
094: Constants.BeanDescriptor.FACET_DESCRIPTORS,
095: getFacetDescriptors());
096: beanDescriptor.setValue(Constants.BeanDescriptor.HELP_KEY,
097: "projrave_ui_elements_palette_jsfstd_data_table");
098: beanDescriptor.setValue(Constants.BeanDescriptor.INSTANCE_NAME,
099: "dataTable");
100: beanDescriptor.setValue(Constants.BeanDescriptor.IS_CONTAINER,
101: Boolean.TRUE);
102: beanDescriptor
103: .setValue(Constants.BeanDescriptor.PROPERTIES_HELP_KEY,
104: "projrave_ui_elements_propsheets_jsfstd_data_table_props");
105: beanDescriptor.setValue(
106: Constants.BeanDescriptor.PROPERTY_CATEGORIES,
107: getCategoryDescriptors());
108: beanDescriptor.setValue(Constants.BeanDescriptor.TAG_NAME,
109: "dataTable");
110: beanDescriptor.setValue(Constants.BeanDescriptor.TAGLIB_PREFIX,
111: "h");
112: beanDescriptor.setValue(Constants.BeanDescriptor.TAGLIB_URI,
113: "http://java.sun.com/jsf/html");
114:
115: return beanDescriptor;
116:
117: }
118:
119: private PropertyDescriptor[] propertyDescriptors;
120:
121: public PropertyDescriptor[] getPropertyDescriptors() {
122:
123: if (propertyDescriptors != null) {
124: return propertyDescriptors;
125: }
126: AttributeDescriptor attrib = null;
127:
128: try {
129:
130: PropertyDescriptor prop_first = new PropertyDescriptorBase(
131: "first", beanClass, "getFirst", "setFirst");
132: prop_first.setDisplayName(resources
133: .getString("UIData_first_DisplayName"));
134: prop_first.setShortDescription(resources
135: .getString("UIData_first_Description"));
136: prop_first.setExpert(false);
137: prop_first.setHidden(true);
138: prop_first.setPreferred(false);
139: attrib = new AttributeDescriptor("first", false, null, true);
140: prop_first.setValue(
141: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
142: attrib);
143: prop_first
144: .setValue(
145: Constants.PropertyDescriptor.CATEGORY,
146: com.sun.rave.designtime.base.CategoryDescriptors.GENERAL);
147:
148: PropertyDescriptor prop_rowAvailable = new PropertyDescriptorBase(
149: "rowAvailable", beanClass, "isRowAvailable", null);
150: prop_rowAvailable.setDisplayName(resources
151: .getString("UIData_rowAvailable_DisplayName"));
152: prop_rowAvailable.setShortDescription(resources
153: .getString("UIData_rowAvailable_Description"));
154: prop_rowAvailable.setExpert(false);
155: prop_rowAvailable.setHidden(true);
156: prop_rowAvailable.setPreferred(false);
157: prop_rowAvailable
158: .setValue(
159: Constants.PropertyDescriptor.CATEGORY,
160: com.sun.rave.designtime.base.CategoryDescriptors.GENERAL);
161:
162: PropertyDescriptor prop_rowCount = new PropertyDescriptorBase(
163: "rowCount", beanClass, "getRowCount", null);
164: prop_rowCount.setDisplayName(resources
165: .getString("UIData_rowCount_DisplayName"));
166: prop_rowCount.setShortDescription(resources
167: .getString("UIData_rowCount_Description"));
168: prop_rowCount.setExpert(false);
169: prop_rowCount.setHidden(true);
170: prop_rowCount.setPreferred(false);
171: prop_rowCount
172: .setValue(
173: Constants.PropertyDescriptor.CATEGORY,
174: com.sun.rave.designtime.base.CategoryDescriptors.GENERAL);
175:
176: PropertyDescriptor prop_rowData = new PropertyDescriptorBase(
177: "rowData", beanClass, "getRowData", null);
178: prop_rowData.setDisplayName(resources
179: .getString("UIData_rowData_DisplayName"));
180: prop_rowData.setShortDescription(resources
181: .getString("UIData_rowData_Description"));
182: prop_rowData.setExpert(false);
183: prop_rowData.setHidden(true);
184: prop_rowData.setPreferred(false);
185: prop_rowData
186: .setValue(
187: Constants.PropertyDescriptor.CATEGORY,
188: com.sun.rave.designtime.base.CategoryDescriptors.GENERAL);
189:
190: PropertyDescriptor prop_rowIndex = new PropertyDescriptorBase(
191: "rowIndex", beanClass, "getRowIndex", "setRowIndex");
192: prop_rowIndex.setDisplayName(resources
193: .getString("UIData_rowIndex_DisplayName"));
194: prop_rowIndex.setShortDescription(resources
195: .getString("UIData_rowIndex_Description"));
196: prop_rowIndex.setExpert(false);
197: prop_rowIndex.setHidden(true);
198: prop_rowIndex.setPreferred(false);
199: prop_rowIndex
200: .setValue(
201: Constants.PropertyDescriptor.CATEGORY,
202: com.sun.rave.designtime.base.CategoryDescriptors.GENERAL);
203:
204: PropertyDescriptor prop_rows = new PropertyDescriptorBase(
205: "rows", beanClass, "getRows", "setRows");
206: prop_rows.setDisplayName(resources
207: .getString("UIData_rows_DisplayName"));
208: prop_rows.setShortDescription(resources
209: .getString("UIData_rows_Description"));
210: prop_rows
211: .setPropertyEditorClass(com.sun.rave.propertyeditors.IntegerPropertyEditor.class);
212: prop_rows.setExpert(false);
213: prop_rows.setHidden(false);
214: prop_rows.setPreferred(false);
215: attrib = new AttributeDescriptor("rows", false, null, true);
216: prop_rows.setValue(
217: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
218: attrib);
219: prop_rows
220: .setValue(
221: Constants.PropertyDescriptor.CATEGORY,
222: com.sun.rave.designtime.base.CategoryDescriptors.APPEARANCE);
223: prop_rows.setValue("minValue", new Integer(0));
224: prop_rows.setValue("unsetValue", new Integer(
225: Integer.MIN_VALUE));
226:
227: PropertyDescriptor prop_value = new PropertyDescriptorBase(
228: "value", beanClass, "getValue", "setValue");
229: prop_value.setDisplayName(resources
230: .getString("UIData_value_DisplayName"));
231: prop_value.setShortDescription(resources
232: .getString("UIData_value_Description"));
233: prop_value
234: .setPropertyEditorClass(org.netbeans.modules.visualweb.faces.dt.std.ValueBindingPropertyEditor.class);
235: prop_value.setExpert(false);
236: prop_value.setHidden(false);
237: prop_value.setPreferred(false);
238: attrib = new AttributeDescriptor("value", false, null, true);
239: prop_value.setValue(
240: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
241: attrib);
242: prop_value
243: .setValue(
244: Constants.PropertyDescriptor.CATEGORY,
245: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
246: prop_value.setValue("ignoreIsBound", "true");
247:
248: PropertyDescriptor prop_var = new PropertyDescriptorBase(
249: "var", beanClass, "getVar", "setVar");
250: prop_var.setDisplayName(resources
251: .getString("UIData_var_DisplayName"));
252: prop_var.setShortDescription(resources
253: .getString("UIData_var_Description"));
254: prop_var.setExpert(false);
255: prop_var.setHidden(false);
256: prop_var.setPreferred(false);
257: attrib = new AttributeDescriptor("var", false, null, true);
258: prop_var.setValue(
259: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
260: attrib);
261: prop_var
262: .setValue(
263: Constants.PropertyDescriptor.CATEGORY,
264: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
265:
266: List<PropertyDescriptor> propertyDescriptorList = new ArrayList<PropertyDescriptor>();
267: propertyDescriptorList.add(prop_first);
268: propertyDescriptorList.add(prop_rowAvailable);
269: propertyDescriptorList.add(prop_rowCount);
270: propertyDescriptorList.add(prop_rowData);
271: propertyDescriptorList.add(prop_rowIndex);
272: propertyDescriptorList.add(prop_rows);
273: propertyDescriptorList.add(prop_value);
274: propertyDescriptorList.add(prop_var);
275:
276: propertyDescriptorList.addAll(Arrays.asList(super
277: .getPropertyDescriptors()));
278: propertyDescriptors = propertyDescriptorList
279: .toArray(new PropertyDescriptor[propertyDescriptorList
280: .size()]);
281: return propertyDescriptors;
282:
283: } catch (IntrospectionException e) {
284: e.printStackTrace();
285: return null;
286: }
287:
288: }
289:
290: }
|