1 32 33 package com.knowgate.hipergate; 34 35 39 40 import java.awt.Image ; 41 42 import java.lang.ClassNotFoundException ; 43 import java.lang.NoSuchMethodException ; 44 45 import java.beans.SimpleBeanInfo ; 46 import java.beans.BeanDescriptor ; 47 import java.beans.MethodDescriptor ; 48 49 import com.knowgate.hipergate.Categories; 50 51 public class CategoriesBeanInfo extends SimpleBeanInfo { 52 53 public CategoriesBeanInfo() { 54 } 55 56 public BeanDescriptor getBeanDescriptor() { 57 return new BeanDescriptor (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 [] getMethodDescriptors() { 75 try { 76 Class voidParams[] = { }; 77 Class getRootsParams[] = { Class.forName("java.sql.Connection") }; 78 Class getRootsNamedParams[] = { Class.forName("java.sql.Connection"), Class.forName("String"), Class.forName("int") }; 79 Class getChildsNamedParams[] = { Class.forName("java.sql.Connection"), Class.forName("int"), Class.forName("String"), Class.forName("int") }; 80 81 MethodDescriptor clearCache = new MethodDescriptor (Categories.class.getMethod("clearCache", voidParams)); 82 83 MethodDescriptor getRoots = new MethodDescriptor (Categories.class.getMethod("getRoots", getRootsParams)); 84 85 MethodDescriptor getRootsCount = new MethodDescriptor (Categories.class.getMethod("getRootsCount", voidParams)); 86 87 MethodDescriptor getRootsNamed = new MethodDescriptor (Categories.class.getMethod("getRootsNamed", getRootsNamedParams)); 88 89 MethodDescriptor getChildsNamed = new MethodDescriptor (Categories.class.getMethod("getChildsNamed", getChildsNamedParams)); 90 91 MethodDescriptor rv[] = {clearCache, getRoots, getRootsCount, getRootsNamed, getChildsNamed}; 92 93 return rv; 94 } 95 catch (ClassNotFoundException e) { 96 throw new Error (e.toString()); 97 } 98 catch (NoSuchMethodException e) { 99 throw new Error (e.toString()); 100 } 101 } 102 103 private final static Class beanClass = Categories.class; 104 } | Popular Tags |