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

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: JXTaskPaneBeanInfo.java,v 1.3 2005/10/10 18:01:44 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.IntrospectionException;
  26. import java.beans.Introspector;
  27. import java.beans.MethodDescriptor;
  28. import java.beans.PropertyDescriptor;
  29. import java.beans.SimpleBeanInfo;
  30. import java.lang.reflect.Method;
  31. import java.util.Vector;
  32. /**
  33.  * BeanInfo class for JXTaskPane.
  34.  */
  35. public class JXTaskPaneBeanInfo extends SimpleBeanInfo
  36. {
  37.    /** Description of the Field */
  38.    protected BeanDescriptor bd = new BeanDescriptor(org.jdesktop.swingx.JXTaskPane.class);
  39.    /** Description of the Field */
  40.    protected Image iconMono16 = loadImage("resources/JXTaskPane16-mono.gif");
  41.    /** Description of the Field */
  42.    protected Image iconColor16 = loadImage("resources/JXTaskPane16.gif");
  43.    /** Description of the Field */
  44.    protected Image iconMono32 = loadImage("resources/JXTaskPane32-mono.gif");
  45.    /** Description of the Field */
  46.    protected Image iconColor32 = loadImage("resources/JXTaskPane32.gif");
  47.    /** Constructor for the JXTaskPaneBeanInfo object */
  48.    public JXTaskPaneBeanInfo() throws java.beans.IntrospectionException
  49.    {
  50.     // setup bean descriptor in constructor. 
  51.        bd.setName("JXTaskPane");
  52.        bd.setShortDescription("JXTaskPane is a container for tasks and other arbitrary components.");
  53.        bd.setValue("isContainer",Boolean.TRUE);
  54.        bd.setValue("containerDelegate","getContentPane");
  55.        BeanInfo info = Introspector.getBeanInfo(getBeanDescriptor().getBeanClass().getSuperclass());
  56.        String order = info.getBeanDescriptor().getValue("propertyorder") == null ? "" : (String) info.getBeanDescriptor().getValue("propertyorder");
  57.        PropertyDescriptor[] pd = getPropertyDescriptors();
  58.        for (int i = 0; i != pd.length; i++)
  59.        {
  60.           if (order.indexOf(pd[i].getName()) == -1)
  61.           {
  62.              order = order + (order.length() == 0 ? "" : ":") + pd[i].getName();
  63.           }
  64.        }
  65.        getBeanDescriptor().setValue("propertyorder", order);
  66.    }
  67.    /**
  68.     * Gets the additionalBeanInfo
  69.     *
  70.     * @return   The additionalBeanInfo value
  71.     */
  72.    public BeanInfo[] getAdditionalBeanInfo()
  73.    {
  74.       Vector bi = new Vector();
  75.       BeanInfo[] biarr = null;
  76.       try
  77.       {
  78.          for (Class cl = org.jdesktop.swingx.JXTaskPane.class.getSuperclass(); !cl.equals(java.awt.Component.class.getSuperclass()); cl = cl.getSuperclass()) {
  79.             bi.addElement(Introspector.getBeanInfo(cl));
  80.          }
  81.          biarr = new BeanInfo[bi.size()];
  82.          bi.copyInto(biarr);
  83.       }
  84.       catch (Exception e)
  85.       {
  86.          // Ignore it
  87.       }
  88.       return biarr;
  89.    }
  90.    /**
  91.     * Gets the beanDescriptor
  92.     *
  93.     * @return   The beanDescriptor value
  94.     */
  95.    public BeanDescriptor getBeanDescriptor()
  96.    {
  97.       return bd;
  98.    }
  99.    /**
  100.     * Gets the defaultPropertyIndex
  101.     *
  102.     * @return   The defaultPropertyIndex value
  103.     */
  104.    public int getDefaultPropertyIndex()
  105.    {
  106.       String defName = "";
  107.       if (defName.equals(""))
  108.       {
  109.          return -1;
  110.       }
  111.       PropertyDescriptor[] pd = getPropertyDescriptors();
  112.       for (int i = 0; i < pd.length; i++)
  113.       {
  114.          if (pd[i].getName().equals(defName))
  115.          {
  116.             return i;
  117.          }
  118.       }
  119.       return -1;
  120.    }
  121.    /**
  122.     * Gets the icon
  123.     *
  124.     * @param type  Description of the Parameter
  125.     * @return      The icon value
  126.     */
  127.    public Image getIcon(int type)
  128.    {
  129.       if (type == BeanInfo.ICON_COLOR_16x16)
  130.       {
  131.          return iconColor16;
  132.       }
  133.       if (type == BeanInfo.ICON_MONO_16x16)
  134.       {
  135.          return iconMono16;
  136.       }
  137.       if (type == BeanInfo.ICON_COLOR_32x32)
  138.       {
  139.          return iconColor32;
  140.       }
  141.       if (type == BeanInfo.ICON_MONO_32x32)
  142.       {
  143.          return iconMono32;
  144.       }
  145.       return null;
  146.    }
  147.    /**
  148.     * Gets the Property Descriptors
  149.     *
  150.     * @return   The propertyDescriptors value
  151.     */
  152.    public PropertyDescriptor[] getPropertyDescriptors() 
  153.    {
  154.       try
  155.       {
  156.          Vector descriptors = new Vector();
  157.          PropertyDescriptor descriptor = null;
  158.          try
  159.          {
  160.             descriptor = new PropertyDescriptor("title", org.jdesktop.swingx.JXTaskPane.class);
  161.          }
  162.          catch (IntrospectionException e)
  163.          {
  164.             descriptor = new PropertyDescriptor("title", org.jdesktop.swingx.JXTaskPane.class, "getTitle", null);
  165.          }
  166.          descriptor.setPreferred(true);
  167.          descriptor.setBound(true);
  168.          descriptors.add(descriptor);
  169.          try
  170.          {
  171.             descriptor = new PropertyDescriptor("icon", org.jdesktop.swingx.JXTaskPane.class);
  172.          }
  173.          catch (IntrospectionException e)
  174.          {
  175.             descriptor = new PropertyDescriptor("icon", org.jdesktop.swingx.JXTaskPane.class, "getIcon", null);
  176.          }
  177.          descriptor.setPreferred(true);
  178.          descriptor.setBound(true);
  179.          descriptors.add(descriptor);
  180.          try
  181.          {
  182.             descriptor = new PropertyDescriptor("special", org.jdesktop.swingx.JXTaskPane.class);
  183.          }
  184.          catch (IntrospectionException e)
  185.          {
  186.             descriptor = new PropertyDescriptor("special", org.jdesktop.swingx.JXTaskPane.class, "getSpecial", null);
  187.          }
  188.          descriptor.setPreferred(true);
  189.          descriptor.setBound(true);
  190.          descriptors.add(descriptor);
  191.          try
  192.          {
  193.             descriptor = new PropertyDescriptor("scrollOnExpand", org.jdesktop.swingx.JXTaskPane.class);
  194.          }
  195.          catch (IntrospectionException e)
  196.          {
  197.             descriptor = new PropertyDescriptor("scrollOnExpand", org.jdesktop.swingx.JXTaskPane.class, "getScrollOnExpand", null);
  198.          }
  199.          descriptor.setPreferred(true);
  200.          descriptor.setBound(true);
  201.          descriptors.add(descriptor);
  202.          try
  203.          {
  204.             descriptor = new PropertyDescriptor("expanded", org.jdesktop.swingx.JXTaskPane.class);
  205.          }
  206.          catch (IntrospectionException e)
  207.          {
  208.             descriptor = new PropertyDescriptor("expanded", org.jdesktop.swingx.JXTaskPane.class, "getExpanded", null);
  209.          }
  210.          descriptor.setPreferred(true);
  211.          descriptor.setBound(true);
  212.          descriptors.add(descriptor);
  213.          return (PropertyDescriptor[]) descriptors.toArray(new PropertyDescriptor[descriptors.size()]);
  214.       }
  215.       catch (Exception e)
  216.       {
  217.         // Ignore it
  218.       }
  219.       return null;
  220.    }
  221.    /**
  222.     * Gets the methodDescriptors attribute ...
  223.     *
  224.     * @return   The methodDescriptors value
  225.     */
  226.    public MethodDescriptor[] getMethodDescriptors() {
  227.       Vector descriptors = new Vector();
  228.       MethodDescriptor descriptor = null;
  229.       Method[] m;
  230.       Method method;
  231.       try {
  232.          m = Class.forName("org.jdesktop.swingx.JXTaskPane").getMethods();
  233.       } catch (ClassNotFoundException e) {
  234.          return new MethodDescriptor[0];
  235.       }
  236.       return (MethodDescriptor[]) descriptors.toArray(new MethodDescriptor[descriptors.size()]);
  237.    }
  238. }