001: /*
002: Copyright (C) 2003 Know Gate S.L. All rights reserved.
003: C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005: Redistribution and use in source and binary forms, with or without
006: modification, are permitted provided that the following conditions
007: are met:
008:
009: 1. Redistributions of source code must retain the above copyright
010: notice, this list of conditions and the following disclaimer.
011:
012: 2. The end-user documentation included with the redistribution,
013: if any, must include the following acknowledgment:
014: "This product includes software parts from hipergate
015: (http://www.hipergate.org/)."
016: Alternately, this acknowledgment may appear in the software itself,
017: if and wherever such third-party acknowledgments normally appear.
018:
019: 3. The name hipergate must not be used to endorse or promote products
020: derived from this software without prior written permission.
021: Products derived from this software may not be called hipergate,
022: nor may hipergate appear in their name, without prior written
023: permission.
024:
025: This library is distributed in the hope that it will be useful,
026: but WITHOUT ANY WARRANTY; without even the implied warranty of
027: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029: You should have received a copy of hipergate License with this code;
030: if not, visit http://www.hipergate.org or mail to info@hipergate.org
031: */
032:
033: package com.knowgate.hipergate;
034:
035: /**
036: * @author Sergio Montoro
037: * @version 1.0
038: */
039:
040: import java.awt.Image;
041:
042: import java.lang.ClassNotFoundException;
043: import java.lang.NoSuchMethodException;
044:
045: import java.beans.SimpleBeanInfo;
046: import java.beans.BeanDescriptor;
047: import java.beans.MethodDescriptor;
048:
049: import com.knowgate.hipergate.Categories;
050:
051: public class CategoriesBeanInfo extends SimpleBeanInfo {
052:
053: public CategoriesBeanInfo() {
054: }
055:
056: public BeanDescriptor getBeanDescriptor() {
057: return new BeanDescriptor(beanClass);
058: }
059:
060: public Image getIcon(int iconKind) {
061: switch (iconKind) {
062: case SimpleBeanInfo.ICON_MONO_16x16:
063: return loadImage("dbbind16m.gif");
064: case SimpleBeanInfo.ICON_COLOR_16x16:
065: return loadImage("dbbind16c.gif");
066: case SimpleBeanInfo.ICON_MONO_32x32:
067: return loadImage("dbbind32m.gif");
068: case SimpleBeanInfo.ICON_COLOR_32x32:
069: return loadImage("dbbind32c.gif");
070: }
071: return null;
072: }
073:
074: public MethodDescriptor[] getMethodDescriptors() {
075: try {
076: Class voidParams[] = {};
077: Class getRootsParams[] = { Class
078: .forName("java.sql.Connection") };
079: Class getRootsNamedParams[] = {
080: Class.forName("java.sql.Connection"),
081: Class.forName("String"), Class.forName("int") };
082: Class getChildsNamedParams[] = {
083: Class.forName("java.sql.Connection"),
084: Class.forName("int"), Class.forName("String"),
085: Class.forName("int") };
086:
087: MethodDescriptor clearCache = new MethodDescriptor(
088: Categories.class
089: .getMethod("clearCache", voidParams));
090:
091: MethodDescriptor getRoots = new MethodDescriptor(
092: Categories.class.getMethod("getRoots",
093: getRootsParams));
094:
095: MethodDescriptor getRootsCount = new MethodDescriptor(
096: Categories.class.getMethod("getRootsCount",
097: voidParams));
098:
099: MethodDescriptor getRootsNamed = new MethodDescriptor(
100: Categories.class.getMethod("getRootsNamed",
101: getRootsNamedParams));
102:
103: MethodDescriptor getChildsNamed = new MethodDescriptor(
104: Categories.class.getMethod("getChildsNamed",
105: getChildsNamedParams));
106:
107: MethodDescriptor rv[] = { clearCache, getRoots,
108: getRootsCount, getRootsNamed, getChildsNamed };
109:
110: return rv;
111: } catch (ClassNotFoundException e) {
112: throw new Error(e.toString());
113: } catch (NoSuchMethodException e) {
114: throw new Error(e.toString());
115: }
116: }
117:
118: private final static Class beanClass = Categories.class;
119: }
|