KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > hipergate > CategoriesBeanInfo


1 /*
2   Copyright (C) 2003 Know Gate S.L. All rights reserved.
3                       C/Oņa, 107 1š2 28050 Madrid (Spain)
4
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions
7   are met:
8
9   1. Redistributions of source code must retain the above copyright
10      notice, this list of conditions and the following disclaimer.
11
12   2. The end-user documentation included with the redistribution,
13      if any, must include the following acknowledgment:
14      "This product includes software parts from hipergate
15      (http://www.hipergate.org/)."
16      Alternately, this acknowledgment may appear in the software itself,
17      if and wherever such third-party acknowledgments normally appear.
18
19   3. The name hipergate must not be used to endorse or promote products
20      derived from this software without prior written permission.
21      Products derived from this software may not be called hipergate,
22      nor may hipergate appear in their name, without prior written
23      permission.
24
25   This library is distributed in the hope that it will be useful,
26   but WITHOUT ANY WARRANTY; without even the implied warranty of
27   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28
29   You should have received a copy of hipergate License with this code;
30   if not, visit http://www.hipergate.org or mail to info@hipergate.org
31 */

32
33 package com.knowgate.hipergate;
34
35 /**
36  * @author Sergio Montoro
37  * @version 1.0
38  */

39
40 import java.awt.Image JavaDoc;
41
42 import java.lang.ClassNotFoundException JavaDoc;
43 import java.lang.NoSuchMethodException JavaDoc;
44
45 import java.beans.SimpleBeanInfo JavaDoc;
46 import java.beans.BeanDescriptor JavaDoc;
47 import java.beans.MethodDescriptor JavaDoc;
48
49 import com.knowgate.hipergate.Categories;
50
51 public class CategoriesBeanInfo extends SimpleBeanInfo JavaDoc {
52
53   public CategoriesBeanInfo() {
54   }
55
56   public BeanDescriptor JavaDoc getBeanDescriptor() {
57     return new BeanDescriptor JavaDoc(beanClass);
58   }
59
60   public Image getIcon(int iconKind) {
61     switch(iconKind) {
62       case SimpleBeanInfo.ICON_MONO_16x16:
63         return loadImage("dbbind16m.gif");
64       case SimpleBeanInfo.ICON_COLOR_16x16:
65         return loadImage("dbbind16c.gif");
66       case SimpleBeanInfo.ICON_MONO_32x32:
67         return loadImage("dbbind32m.gif");
68       case SimpleBeanInfo.ICON_COLOR_32x32:
69         return loadImage("dbbind32c.gif");
70     }
71   return null;
72   }
73
74   public MethodDescriptor JavaDoc[] getMethodDescriptors() {
75     try {
76         Class JavaDoc voidParams[] = { };
77         Class JavaDoc getRootsParams[] = { Class.forName("java.sql.Connection") };
78         Class JavaDoc getRootsNamedParams[] = { Class.forName("java.sql.Connection"), Class.forName("String"), Class.forName("int") };
79         Class JavaDoc getChildsNamedParams[] = { Class.forName("java.sql.Connection"), Class.forName("int"), Class.forName("String"), Class.forName("int") };
80
81         MethodDescriptor JavaDoc clearCache = new MethodDescriptor JavaDoc(Categories.class.getMethod("clearCache", voidParams));
82
83         MethodDescriptor JavaDoc getRoots = new MethodDescriptor JavaDoc(Categories.class.getMethod("getRoots", getRootsParams));
84
85         MethodDescriptor JavaDoc getRootsCount = new MethodDescriptor JavaDoc(Categories.class.getMethod("getRootsCount", voidParams));
86
87         MethodDescriptor JavaDoc getRootsNamed = new MethodDescriptor JavaDoc(Categories.class.getMethod("getRootsNamed", getRootsNamedParams));
88
89         MethodDescriptor JavaDoc getChildsNamed = new MethodDescriptor JavaDoc(Categories.class.getMethod("getChildsNamed", getChildsNamedParams));
90
91         MethodDescriptor JavaDoc rv[] = {clearCache, getRoots, getRootsCount, getRootsNamed, getChildsNamed};
92
93         return rv;
94     }
95     catch (ClassNotFoundException JavaDoc e) {
96          throw new Error JavaDoc(e.toString());
97     }
98     catch (NoSuchMethodException JavaDoc e) {
99          throw new Error JavaDoc(e.toString());
100     }
101   }
102
103   private final static Class JavaDoc beanClass = Categories.class;
104 }
Popular Tags