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

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: JXTaskPaneContainerBeanInfo.java,v 1.3 2005/10/10 18:01:50 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.awt.Image;
  23. import java.beans.BeanDescriptor;
  24. import java.beans.BeanInfo;
  25. import java.beans.Introspector;
  26. import java.beans.MethodDescriptor;
  27. import java.beans.PropertyDescriptor;
  28. import java.beans.SimpleBeanInfo;
  29. import java.lang.reflect.Method;
  30. import java.util.Vector;
  31. /**
  32.  * BeanInfo class for JXTaskPaneContainer.
  33.  */
  34. public class JXTaskPaneContainerBeanInfo extends SimpleBeanInfo
  35. {
  36.    /** Description of the Field */
  37.    protected BeanDescriptor bd = new BeanDescriptor(org.jdesktop.swingx.JXTaskPaneContainer.class);
  38.    /** Description of the Field */
  39.    protected Image iconMono16 = loadImage("resources/JXTaskPaneContainer16-mono.gif");
  40.    /** Description of the Field */
  41.    protected Image iconColor16 = loadImage("resources/JXTaskPaneContainer16.gif");
  42.    /** Description of the Field */
  43.    protected Image iconMono32 = loadImage("resources/JXTaskPaneContainer32-mono.gif");
  44.    /** Description of the Field */
  45.    protected Image iconColor32 = loadImage("resources/JXTaskPaneContainer32.gif");
  46.    /** Constructor for the JXTaskPaneContainerBeanInfo object */
  47.    public JXTaskPaneContainerBeanInfo() throws java.beans.IntrospectionException
  48.    {
  49.     // setup bean descriptor in constructor. 
  50.        bd.setName("JXTaskPaneContainer");
  51.        bd.setShortDescription("A component that contains JXTaskPanes.");
  52.        bd.setValue("isContainer",Boolean.TRUE);
  53.        BeanInfo info = Introspector.getBeanInfo(getBeanDescriptor().getBeanClass().getSuperclass());
  54.        String order = info.getBeanDescriptor().getValue("propertyorder") == null ? "" : (String) info.getBeanDescriptor().getValue("propertyorder");
  55.        PropertyDescriptor[] pd = getPropertyDescriptors();
  56.        for (int i = 0; i != pd.length; i++)
  57.        {
  58.           if (order.indexOf(pd[i].getName()) == -1)
  59.           {
  60.              order = order + (order.length() == 0 ? "" : ":") + pd[i].getName();
  61.           }
  62.        }
  63.        getBeanDescriptor().setValue("propertyorder", order);
  64.    }
  65.    /**
  66.     * Gets the additionalBeanInfo
  67.     *
  68.     * @return   The additionalBeanInfo value
  69.     */
  70.    public BeanInfo[] getAdditionalBeanInfo()
  71.    {
  72.       Vector bi = new Vector();
  73.       BeanInfo[] biarr = null;
  74.       try
  75.       {
  76.          for (Class cl = org.jdesktop.swingx.JXTaskPaneContainer.class.getSuperclass(); !cl.equals(java.awt.Component.class.getSuperclass()); cl = cl.getSuperclass()) {
  77.             bi.addElement(Introspector.getBeanInfo(cl));
  78.          }
  79.          biarr = new BeanInfo[bi.size()];
  80.          bi.copyInto(biarr);
  81.       }
  82.       catch (Exception e)
  83.       {
  84.          // Ignore it
  85.       }
  86.       return biarr;
  87.    }
  88.    /**
  89.     * Gets the beanDescriptor
  90.     *
  91.     * @return   The beanDescriptor value
  92.     */
  93.    public BeanDescriptor getBeanDescriptor()
  94.    {
  95.       return bd;
  96.    }
  97.    /**
  98.     * Gets the defaultPropertyIndex
  99.     *
  100.     * @return   The defaultPropertyIndex value
  101.     */
  102.    public int getDefaultPropertyIndex()
  103.    {
  104.       String defName = "";
  105.       if (defName.equals(""))
  106.       {
  107.          return -1;
  108.       }
  109.       PropertyDescriptor[] pd = getPropertyDescriptors();
  110.       for (int i = 0; i < pd.length; i++)
  111.       {
  112.          if (pd[i].getName().equals(defName))
  113.          {
  114.             return i;
  115.          }
  116.       }
  117.       return -1;
  118.    }
  119.    /**
  120.     * Gets the icon
  121.     *
  122.     * @param type  Description of the Parameter
  123.     * @return      The icon value
  124.     */
  125.    public Image getIcon(int type)
  126.    {
  127.       if (type == BeanInfo.ICON_COLOR_16x16)
  128.       {
  129.          return iconColor16;
  130.       }
  131.       if (type == BeanInfo.ICON_MONO_16x16)
  132.       {
  133.          return iconMono16;
  134.       }
  135.       if (type == BeanInfo.ICON_COLOR_32x32)
  136.       {
  137.          return iconColor32;
  138.       }
  139.       if (type == BeanInfo.ICON_MONO_32x32)
  140.       {
  141.          return iconMono32;
  142.       }
  143.       return null;
  144.    }
  145.    /**
  146.     * Gets the Property Descriptors
  147.     *
  148.     * @return   The propertyDescriptors value
  149.     */
  150.    public PropertyDescriptor[] getPropertyDescriptors() 
  151.    {
  152.       try
  153.       {
  154.          Vector descriptors = new Vector();
  155.          PropertyDescriptor descriptor = null;
  156.          return (PropertyDescriptor[]) descriptors.toArray(new PropertyDescriptor[descriptors.size()]);
  157.       }
  158.       catch (Exception e)
  159.       {
  160.         // Ignore it
  161.       }
  162.       return null;
  163.    }
  164.    /**
  165.     * Gets the methodDescriptors attribute ...
  166.     *
  167.     * @return   The methodDescriptors value
  168.     */
  169.    public MethodDescriptor[] getMethodDescriptors() {
  170.       Vector descriptors = new Vector();
  171.       MethodDescriptor descriptor = null;
  172.       Method[] m;
  173.       Method method;
  174.       try {
  175.          m = Class.forName("org.jdesktop.swingx.JXTaskPaneContainer").getMethods();
  176.       } catch (ClassNotFoundException e) {
  177.          return new MethodDescriptor[0];
  178.       }
  179.       return (MethodDescriptor[]) descriptors.toArray(new MethodDescriptor[descriptors.size()]);
  180.    }
  181. }