1   package nl.tudelft.dsol.introspection.beans;
2   
3   import java.awt.Image;
4   import java.beans.EventSetDescriptor;
5   import java.beans.IntrospectionException;
6   import java.beans.MethodDescriptor;
7   import java.beans.PropertyDescriptor;
8   import java.beans.SimpleBeanInfo;
9   
10  /***
11   * <p>
12   * (c) copyright 2002-2005-2004 <a href="http://www.simulation.tudelft.nl">Delft
13   * University of Technology </a>, the Netherlands. <br>
14   * See for project information <a
15   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
16   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
17   * General Public License (LGPL) </a>, no warranty.
18   * 
19   * @author <a
20   *         href="http://web.eur.nl/fbk/dep/dep1/Introduction/Staff/People/Lang">Niels
21   *         Lang </a><a href="http://www.peter-jacobs.com/index.htm">Peter
22   *         Jacobs </a>
23   * @version 1.1 Apr 15, 2004
24   * @since 1.5
25   */
26  public class SubTestBean2BeanInfo extends SimpleBeanInfo
27  {
28  
29      /*** Property identifiers //GEN-FIRST:Properties */
30      private static final int PROPERTY_testProp1 = 0;
31  
32      /*** Property array */
33      private static PropertyDescriptor[] properties = new PropertyDescriptor[1];
34  
35      static
36      {
37          try
38          {
39              properties[PROPERTY_testProp1] = new PropertyDescriptor(
40                      "testProp1", SubTestBean2.class, "getTestProp1",
41                      "setTestProp1");
42          } catch (IntrospectionException e)
43          {
44              e.printStackTrace();
45          }
46  
47          // Here you can add code for customizing the properties array.
48      }
49  
50      // EventSet identifiers//GEN-FIRST:Events
51  
52      /*** EventSet array */
53      private static EventSetDescriptor[] eventSets = new EventSetDescriptor[0];
54  
55      // GEN-HEADEREND:Events
56  
57      // Here you can add code for customizing the event sets array.
58  
59      // GEN-LAST:Events
60  
61      // Method identifiers //GEN-FIRST:Methods
62  
63      /*** Method array */
64      private static MethodDescriptor[] methods = new MethodDescriptor[0];
65  
66      // GEN-HEADEREND:Methods
67  
68      // Here you can add code for customizing the methods array.
69  
70      // GEN-LAST:Methods
71  
72      /*** iconColor */
73      private static Image iconColor16 = null; // GEN-BEGIN:IconsDef
74  
75      /*** iconColor */
76      private static Image iconColor32 = null;
77  
78      /*** iconColor */
79      private static Image iconMono16 = null;
80  
81      /*** iconColor */
82      private static Image iconMono32 = null; // GEN-END:IconsDef
83  
84      /*** iconName */
85      private static String iconNameC16 = null;
86  
87      /*** iconName */
88      private static String iconNameC32 = null;
89  
90      /*** iconName */
91      private static String iconNameM16 = null;
92  
93      /*** iconName */
94      private static String iconNameM32 = null;
95  
96      /*** iconName */
97      private static int defaultPropertyIndex = -1;
98  
99      /***
100      * Gets the bean's <code>PropertyDescriptor</code>s.
101      * 
102      * @return An array of PropertyDescriptors describing the editable
103      *         properties supported by this bean. May return null if the
104      *         information should be obtained by automatic analysis.
105      *         <p>
106      *         If a property is indexed, then its entry in the result array will
107      *         belong to the IndexedPropertyDescriptor subclass of
108      *         PropertyDescriptor. A client of getPropertyDescriptors can use
109      *         "instanceof" to check if a given PropertyDescriptor is an
110      *         IndexedPropertyDescriptor.
111      */
112     @Override
113     public PropertyDescriptor[] getPropertyDescriptors()
114     {
115         return properties;
116     }
117 
118     /***
119      * Gets the bean's <code>EventSetDescriptor</code>s.
120      * 
121      * @return An array of EventSetDescriptors describing the kinds of events
122      *         fired by this bean. May return null if the information should be
123      *         obtained by automatic analysis.
124      */
125     @Override
126     public EventSetDescriptor[] getEventSetDescriptors()
127     {
128         return eventSets;
129     }
130 
131     /***
132      * Gets the bean's <code>MethodDescriptor</code>s.
133      * 
134      * @return An array of MethodDescriptors describing the methods implemented
135      *         by this bean. May return null if the information should be
136      *         obtained by automatic analysis.
137      */
138     @Override
139     public MethodDescriptor[] getMethodDescriptors()
140     {
141         return methods;
142     }
143 
144     /***
145      * A bean may have a "default" property that is the property that will
146      * mostly commonly be initially chosen for update by human's who are
147      * customizing the bean.
148      * 
149      * @return Index of default property in the PropertyDescriptor array
150      *         returned by getPropertyDescriptors.
151      *         <P>
152      *         Returns -1 if there is no default property.
153      */
154     @Override
155     public int getDefaultPropertyIndex()
156     {
157         return defaultPropertyIndex;
158     }
159 
160     /***
161      * A bean may have a "default" event that is the event that will mostly
162      * commonly be used by human's when using the bean.
163      * 
164      * @return Index of default event in the EventSetDescriptor array returned
165      *         by getEventSetDescriptors.
166      *         <P>
167      *         Returns -1 if there is no default event.
168      */
169     @Override
170     public int getDefaultEventIndex()
171     {
172         return defaultPropertyIndex;
173     }
174 
175     /***
176      * This method returns an image object that can be used to represent the
177      * bean in toolboxes, toolbars, etc. Icon images will typically be GIFs, but
178      * may in future include other formats.
179      * <p>
180      * Beans aren't required to provide icons and may return null from this
181      * method.
182      * <p>
183      * There are four possible flavors of icons (16x16 color, 32x32 color, 16x16
184      * mono, 32x32 mono). If a bean choses to only support a single icon we
185      * recommend supporting 16x16 color.
186      * <p>
187      * We recommend that icons have a "transparent" background so they can be
188      * rendered onto an existing background.
189      * 
190      * @param iconKind The kind of icon requested. This should be one of the
191      *        constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
192      *        ICON_MONO_16x16, or ICON_MONO_32x32.
193      * @return An image object representing the requested icon. May return null
194      *         if no suitable icon is available.
195      */
196     @Override
197     public Image getIcon(final int iconKind)
198     {
199         switch (iconKind)
200         {
201             case ICON_COLOR_16x16:
202                 if (iconNameC16 == null)
203                 {
204                     return null;
205                 }
206 
207                 if (iconColor16 == null)
208                 {
209                     iconColor16 = loadImage(iconNameC16);
210                 }
211                 return iconColor16;
212 
213             case ICON_COLOR_32x32:
214                 if (iconNameC32 == null)
215                 {
216                     return null;
217                 }
218 
219                 if (iconColor32 == null)
220                 {
221                     iconColor32 = loadImage(iconNameC32);
222                 }
223                 return iconColor32;
224 
225             case ICON_MONO_16x16:
226                 if (iconNameM16 == null)
227                 {
228                     return null;
229                 }
230 
231                 if (iconMono16 == null)
232                 {
233                     iconMono16 = loadImage(iconNameM16);
234                 }
235                 return iconMono16;
236 
237             case ICON_MONO_32x32:
238                 if (iconNameM32 == null)
239                 {
240                     return null;
241                 }
242 
243                 if (iconNameM32 == null)
244                 {
245                     iconMono32 = loadImage(iconNameM32);
246                 }
247                 return iconMono32;
248             default:
249                 return null;
250         }
251     }
252 
253 }