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.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 UIGraphicBeanInfoBase extends
065: UIComponentBeanInfoBase {
066:
067: protected static ResourceBundle resources = ResourceBundle
068: .getBundle(
069: "org.netbeans.modules.visualweb.faces.dt_1_2.component.Bundle",
070: Locale.getDefault(), UIGraphicBeanInfoBase.class
071: .getClassLoader());
072:
073: public UIGraphicBeanInfoBase() {
074: beanClass = javax.faces.component.UIGraphic.class;
075: defaultPropertyName = "value";
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_url = new PropertyDescriptorBase(
090: "url", beanClass, "getUrl", "setUrl");
091: prop_url.setDisplayName(resources
092: .getString("UIGraphic_url_DisplayName"));
093: prop_url.setShortDescription(resources
094: .getString("UIGraphic_url_Description"));
095: prop_url
096: .setPropertyEditorClass(com.sun.rave.propertyeditors.UrlPropertyEditor.class);
097: prop_url.setExpert(false);
098: prop_url.setHidden(true);
099: prop_url.setPreferred(false);
100: prop_url
101: .setValue(
102: Constants.PropertyDescriptor.CATEGORY,
103: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
104:
105: PropertyDescriptor prop_value = new PropertyDescriptorBase(
106: "value", beanClass, "getValue", "setValue");
107: prop_value.setDisplayName(resources
108: .getString("UIGraphic_value_DisplayName"));
109: prop_value.setShortDescription(resources
110: .getString("UIGraphic_value_Description"));
111: prop_value
112: .setPropertyEditorClass(com.sun.rave.propertyeditors.UrlPropertyEditor.class);
113: prop_value.setExpert(false);
114: prop_value.setHidden(false);
115: prop_value.setPreferred(false);
116: attrib = new AttributeDescriptor("value", false, null, true);
117: prop_value.setValue(
118: Constants.PropertyDescriptor.ATTRIBUTE_DESCRIPTOR,
119: attrib);
120: prop_value
121: .setValue(
122: Constants.PropertyDescriptor.CATEGORY,
123: com.sun.rave.designtime.base.CategoryDescriptors.DATA);
124: prop_value.setValue("ignoreIsBound", "true");
125:
126: List<PropertyDescriptor> propertyDescriptorList = new ArrayList<PropertyDescriptor>();
127: propertyDescriptorList.add(prop_url);
128: propertyDescriptorList.add(prop_value);
129:
130: propertyDescriptorList.addAll(Arrays.asList(super
131: .getPropertyDescriptors()));
132: propertyDescriptors = propertyDescriptorList
133: .toArray(new PropertyDescriptor[propertyDescriptorList
134: .size()]);
135: return propertyDescriptors;
136:
137: } catch (IntrospectionException e) {
138: e.printStackTrace();
139: return null;
140: }
141:
142: }
143:
144: }
|