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