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