JXTitledPanelBeanInfo.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:8k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: JXTitledPanelBeanInfo.java,v 1.3 2005/10/10 18:01:46 rbair Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.swingx;
  22. import java.beans.*;
  23. /**
  24.  * @author rbair
  25.  */
  26. public class JXTitledPanelBeanInfo extends SimpleBeanInfo {
  27.     
  28.     // Bean descriptor information will be obtained from introspection.//GEN-FIRST:BeanDescriptor
  29.     private static BeanDescriptor beanDescriptor = null;
  30.     private static BeanDescriptor getBdescriptor(){
  31. //GEN-HEADEREND:BeanDescriptor
  32.         
  33.         // Here you can add code for customizing the BeanDescriptor.
  34.         beanDescriptor = new BeanDescriptor(JXTitledPanel.class);
  35.         beanDescriptor.setValue("containerDelegate", "getContentContainer");
  36. //        beanDescriptor.setValue("isContainer", Boolean.TRUE);
  37.         
  38.         return beanDescriptor;     }//GEN-LAST:BeanDescriptor
  39.     
  40.     
  41.     // Properties information will be obtained from introspection.//GEN-FIRST:Properties
  42.     private static PropertyDescriptor[] properties = null;
  43.     private static PropertyDescriptor[] getPdescriptor(){
  44. //GEN-HEADEREND:Properties
  45.         
  46.         // Here you can add code for customizing the properties array.
  47.         
  48.         return properties;     }//GEN-LAST:Properties
  49.     
  50.     // Event set information will be obtained from introspection.//GEN-FIRST:Events
  51.     private static EventSetDescriptor[] eventSets = null;
  52.     private static EventSetDescriptor[] getEdescriptor(){
  53. //GEN-HEADEREND:Events
  54.         
  55.         // Here you can add code for customizing the event sets array.
  56.         
  57.         return eventSets;     }//GEN-LAST:Events
  58.     
  59.     // Method information will be obtained from introspection.//GEN-FIRST:Methods
  60.     private static MethodDescriptor[] methods = null;
  61.     private static MethodDescriptor[] getMdescriptor(){
  62. //GEN-HEADEREND:Methods
  63.         
  64.         // Here you can add code for customizing the methods array.
  65.         
  66.         return methods;     }//GEN-LAST:Methods
  67.     
  68.     private static java.awt.Image iconColor16 = null;//GEN-BEGIN:IconsDef
  69.     private static java.awt.Image iconColor32 = null;
  70.     private static java.awt.Image iconMono16 = null;
  71.     private static java.awt.Image iconMono32 = null;//GEN-END:IconsDef
  72.     private static String iconNameC16 = null;//GEN-BEGIN:Icons
  73.     private static String iconNameC32 = null;
  74.     private static String iconNameM16 = null;
  75.     private static String iconNameM32 = null;//GEN-END:Icons
  76.     
  77.     private static int defaultPropertyIndex = -1;//GEN-BEGIN:Idx
  78.     private static int defaultEventIndex = -1;//GEN-END:Idx
  79.     
  80.     
  81. //GEN-FIRST:Superclass
  82.     
  83.     // Here you can add code for customizing the Superclass BeanInfo.
  84.     
  85. //GEN-LAST:Superclass
  86.     
  87.     /**
  88.      * Gets the bean's <code>BeanDescriptor</code>s.
  89.      *
  90.      * @return BeanDescriptor describing the editable
  91.      * properties of this bean.  May return null if the
  92.      * information should be obtained by automatic analysis.
  93.      */
  94.     public BeanDescriptor getBeanDescriptor() {
  95.         return getBdescriptor();
  96.     }
  97.     
  98.     /**
  99.      * Gets the bean's <code>PropertyDescriptor</code>s.
  100.      *
  101.      * @return An array of PropertyDescriptors describing the editable
  102.      * properties supported by this bean.  May return null if the
  103.      * information should be obtained by automatic analysis.
  104.      * <p>
  105.      * If a property is indexed, then its entry in the result array will
  106.      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
  107.      * A client of getPropertyDescriptors can use "instanceof" to check
  108.      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
  109.      */
  110.     public PropertyDescriptor[] getPropertyDescriptors() {
  111.         return getPdescriptor();
  112.     }
  113.     
  114.     /**
  115.      * Gets the bean's <code>EventSetDescriptor</code>s.
  116.      *
  117.      * @return  An array of EventSetDescriptors describing the kinds of
  118.      * events fired by this bean.  May return null if the information
  119.      * should be obtained by automatic analysis.
  120.      */
  121.     public EventSetDescriptor[] getEventSetDescriptors() {
  122.         return getEdescriptor();
  123.     }
  124.     
  125.     /**
  126.      * Gets the bean's <code>MethodDescriptor</code>s.
  127.      *
  128.      * @return  An array of MethodDescriptors describing the methods
  129.      * implemented by this bean.  May return null if the information
  130.      * should be obtained by automatic analysis.
  131.      */
  132.     public MethodDescriptor[] getMethodDescriptors() {
  133.         return getMdescriptor();
  134.     }
  135.     
  136.     /**
  137.      * A bean may have a "default" property that is the property that will
  138.      * mostly commonly be initially chosen for update by human's who are
  139.      * customizing the bean.
  140.      * @return  Index of default property in the PropertyDescriptor array
  141.      *  returned by getPropertyDescriptors.
  142.      * <P> Returns -1 if there is no default property.
  143.      */
  144.     public int getDefaultPropertyIndex() {
  145.         return defaultPropertyIndex;
  146.     }
  147.     
  148.     /**
  149.      * A bean may have a "default" event that is the event that will
  150.      * mostly commonly be used by human's when using the bean.
  151.      * @return Index of default event in the EventSetDescriptor array
  152.      * returned by getEventSetDescriptors.
  153.      * <P> Returns -1 if there is no default event.
  154.      */
  155.     public int getDefaultEventIndex() {
  156.         return defaultEventIndex;
  157.     }
  158.     
  159.     /**
  160.      * This method returns an image object that can be used to
  161.      * represent the bean in toolboxes, toolbars, etc.   Icon images
  162.      * will typically be GIFs, but may in future include other formats.
  163.      * <p>
  164.      * Beans aren't required to provide icons and may return null from
  165.      * this method.
  166.      * <p>
  167.      * There are four possible flavors of icons (16x16 color,
  168.      * 32x32 color, 16x16 mono, 32x32 mono).  If a bean choses to only
  169.      * support a single icon we recommend supporting 16x16 color.
  170.      * <p>
  171.      * We recommend that icons have a "transparent" background
  172.      * so they can be rendered onto an existing background.
  173.      *
  174.      * @param  iconKind  The kind of icon requested.  This should be
  175.      *    one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
  176.      *    ICON_MONO_16x16, or ICON_MONO_32x32.
  177.      * @return  An image object representing the requested icon.  May
  178.      *    return null if no suitable icon is available.
  179.      */
  180.     public java.awt.Image getIcon(int iconKind) {
  181.         switch ( iconKind ) {
  182.             case ICON_COLOR_16x16:
  183.                 if ( iconNameC16 == null )
  184.                     return null;
  185.                 else {
  186.                     if( iconColor16 == null )
  187.                         iconColor16 = loadImage( iconNameC16 );
  188.                     return iconColor16;
  189.                 }
  190.             case ICON_COLOR_32x32:
  191.                 if ( iconNameC32 == null )
  192.                     return null;
  193.                 else {
  194.                     if( iconColor32 == null )
  195.                         iconColor32 = loadImage( iconNameC32 );
  196.                     return iconColor32;
  197.                 }
  198.             case ICON_MONO_16x16:
  199.                 if ( iconNameM16 == null )
  200.                     return null;
  201.                 else {
  202.                     if( iconMono16 == null )
  203.                         iconMono16 = loadImage( iconNameM16 );
  204.                     return iconMono16;
  205.                 }
  206.             case ICON_MONO_32x32:
  207.                 if ( iconNameM32 == null )
  208.                     return null;
  209.                 else {
  210.                     if( iconMono32 == null )
  211.                         iconMono32 = loadImage( iconNameM32 );
  212.                     return iconMono32;
  213.                 }
  214.             default: return null;
  215.         }
  216.     }
  217.     
  218. }