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-2006 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.beaninfo;
043:
044: import java.awt.Image;
045: import java.beans.*;
046:
047: import org.netbeans.core.ui.SwingBrowser;
048: import org.openide.util.NbBundle;
049: import org.openide.util.Utilities;
050:
051: /**
052: * Swing HTML Browser support.
053: *
054: * Factory for built-in Swing HTML browser.
055: *
056: * @author Radim Kubacki
057: */
058: public class SwingBrowserBeanInfo extends SimpleBeanInfo {
059:
060: /**
061: * Gets the bean's <code>BeanDescriptor</code>s.
062: *
063: * @return BeanDescriptor describing the editable
064: * properties of this bean. May return null if the
065: * information should be obtained by automatic analysis.
066: */
067: public BeanDescriptor getBeanDescriptor() {
068: BeanDescriptor beanDescriptor = new BeanDescriptor(
069: SwingBrowser.class);
070: beanDescriptor.setDisplayName(NbBundle.getMessage(
071: SwingBrowserBeanInfo.class, "CTL_SwingBrowser"));
072: beanDescriptor.setShortDescription(NbBundle.getMessage(
073: SwingBrowserBeanInfo.class, "HINT_SwingBrowser"));
074:
075: beanDescriptor.setValue("helpID",
076: "org.openide.awt.SwingBrowser"); // NOI18N
077: return beanDescriptor;
078: }
079:
080: /**
081: * Gets the bean's <code>PropertyDescriptor</code>s.
082: *
083: * @return An array of PropertyDescriptors describing the editable
084: * properties supported by this bean. May return null if the
085: * information should be obtained by automatic analysis.
086: * <p>
087: * If a property is indexed, then its entry in the result array will
088: * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
089: * A client of getPropertyDescriptors can use "instanceof" to check
090: * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
091: */
092: public PropertyDescriptor[] getPropertyDescriptors() {
093: try {
094: PropertyDescriptor[] props = new PropertyDescriptor[] { new PropertyDescriptor(
095: SwingBrowser.PROP_DESCRIPTION, SwingBrowser.class,
096: "getDescritpion", null) // NOI18N
097: };
098: props[0].setDisplayName(NbBundle.getMessage(
099: SwingBrowserBeanInfo.class,
100: "PROP_SwingBrowserDescription"));
101: props[0].setShortDescription(NbBundle.getMessage(
102: SwingBrowserBeanInfo.class,
103: "HINT_SwingBrowserDescription"));
104: return props;
105: } catch (IntrospectionException e) {
106: return null;
107: }
108: }
109:
110: /**
111: * Gets the bean's <code>EventSetDescriptor</code>s.
112: *
113: * @return An array of EventSetDescriptors describing the kinds of
114: * events fired by this bean. May return null if the information
115: * should be obtained by automatic analysis.
116: */
117: public EventSetDescriptor[] getEventSetDescriptors() {
118: try {
119: return new EventSetDescriptor[] { new EventSetDescriptor(
120: SwingBrowser.class,
121: "propertyChangeListener", // NOI18N
122: PropertyChangeListener.class,
123: new String[] { "propertyChange" }, // NOI18N
124: "addPropertyChangeListener", // NOI18N
125: "removePropertyChangeListener" // NOI18N
126: ) // NOI18N
127: };
128: } catch (IntrospectionException e) {
129: return null;
130: }
131: }
132:
133: /**
134: * Returns the internal browser icon.
135: */
136: public Image getIcon(int type) {
137: return Utilities
138: .loadImage("org/openide/resources/html/htmlView.gif"); // NOI18N
139: }
140: }
|