home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 February / VPR9802A.ISO / APP_DEMO / VC / SOURCE.BIN / StateCheckBoxBeanInfo.java < prev    next >
Text File  |  1997-10-27  |  8KB  |  234 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5.  
  6. /**
  7.  * BeanInfo for StateCheckBox
  8.  *
  9.  */
  10.  
  11. public class StateCheckBoxBeanInfo extends SimpleBeanInfo {
  12.  
  13.     /**
  14.      * Constructs a StateCheckBoxBeanInfo object.
  15.      */
  16.     public StateCheckBoxBeanInfo() {
  17.     }
  18.  
  19.     /**
  20.      * Gets a BeanInfo for the superclass of this bean.
  21.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  22.      */
  23.     public BeanInfo[] getAdditionalBeanInfo() {
  24.         try {
  25.             BeanInfo[] bi = new BeanInfo[1];
  26.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  27.             return bi;
  28.         }
  29.         catch (IntrospectionException e) { throw new Error(e.toString());}
  30.     }
  31.  
  32.     /**
  33.      * Gets the SymantecBeanDescriptor for this bean.
  34.      * @return an object of type SymantecBeanDescriptor
  35.      * @see symantec.itools.beans.SymantecBeanDescriptor
  36.      */
  37.     public BeanDescriptor getBeanDescriptor() {
  38.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  39.         bd.setFolder("追加");
  40.         bd.setToolbar("追加");
  41. //        bd.setFolder("Additional");
  42. //        bd.setToolbar("Additional");
  43.         bd.setWinHelp("0x123A7");
  44.  
  45.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  46.                                                 "%name%.TWO_STATE",
  47.                                                 "スタイル: 2点切替"));
  48. //                                                "Style: TWO_STATE"));
  49.  
  50.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  51.                                                 "%name%.THREE_STATE",
  52.                                                 "スタイル: 3点切替"));
  53. //                                                "Style: THREE_STATE"));
  54.  
  55.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  56.                                                 "%name%.STATE_UNCHECKED",
  57.                                                 "チェック オフ"));
  58. //                                                "STATE_UNCHECKED"));
  59.  
  60.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  61.                                                 "%name%.STATE_CHECKED",
  62.                                                 "チェック オン"));
  63. //                                                "STATE_CHECKED"));
  64.  
  65.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  66.                                                 "%name%.STATE_DEFAULT",
  67.                                                 "デフォルト"));
  68. //                                                "STATE_DEFAULT"));
  69.  
  70.  
  71.         return (BeanDescriptor) bd;
  72.     }
  73.  
  74.     /**
  75.      * Gets an image that may be used to visually represent this bean
  76.      * (in the toolbar, on a form, etc).
  77.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  78.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  79.      * @return an image for this bean, always color even if requested monochrome
  80.      * @see BeanInfo#ICON_MONO_16x16
  81.      * @see BeanInfo#ICON_COLOR_16x16
  82.      * @see BeanInfo#ICON_MONO_32x32
  83.      * @see BeanInfo#ICON_COLOR_32x32
  84.      */
  85.     public java.awt.Image getIcon(int iconKind) {
  86.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  87.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  88.             java.awt.Image img = loadImage("StateCheckBoxC16.gif");
  89.             return img;
  90.         }
  91.  
  92.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  93.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  94.             java.awt.Image img = loadImage("StateCheckBoxC32.gif");
  95.             return img;
  96.         }
  97.  
  98.         return null;
  99.     }
  100.  
  101.     /**
  102.      * Gets an array of descriptions of the methods used for "connections" by
  103.      * Visual Caf's Interaction Wizard.
  104.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  105.      * @return method descriptions for this bean
  106.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  107.      */
  108.     public MethodDescriptor[] getMethodDescriptors() {
  109.         Class[] args;
  110.         ConnectionDescriptor connection;
  111.         java.util.Vector connections;
  112.         java.util.Vector md = new java.util.Vector();
  113.  
  114.         try{
  115.             args = new Class[1];
  116.             args[0] = java.lang.Integer.TYPE ;
  117.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setStyle", args));
  118.  
  119.             connections = new java.util.Vector();
  120.             connection = new ConnectionDescriptor("input", "int", "",
  121.                                     "%name%.setStyle(%arg%);",
  122.                                     "スタイルを設定する");
  123. //                                    "Set the checkbox style");
  124.             connections.addElement(connection);
  125.  
  126.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  127.             md.addElement(setStyle);
  128.         } catch (Exception e) { throw new Error("setStyle:: " + e.toString()); }
  129.  
  130.         try{
  131.             args = null;
  132.             MethodDescriptor getStyle = new MethodDescriptor(beanClass.getMethod("getStyle", args));
  133.  
  134.             connections = new java.util.Vector();
  135.             connection = new ConnectionDescriptor("output", "int", "",
  136.                                     "%name%.getStyle()",
  137.                                     "スタイルを取得する");
  138. //                                    "Get the checkbox style");
  139.             connections.addElement(connection);
  140.  
  141.             getStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  142.             md.addElement(getStyle);
  143.         } catch (Exception e) { throw new Error("getStyle:: " + e.toString()); }
  144.  
  145.         try{
  146.             args = new Class[1];
  147.             args[0] = java.lang.Integer.TYPE ;
  148.             MethodDescriptor setState = new MethodDescriptor(beanClass.getMethod("setState", args));
  149.  
  150.             connections = new java.util.Vector();
  151.             connection = new ConnectionDescriptor("input", "int", "",
  152.                                     "%name%.setState(%arg%);",
  153.                                     "状態を設定する");
  154. //                                    "Set the checkbox state");
  155.             connections.addElement(connection);
  156.  
  157.             connection = new ConnectionDescriptor("input", "void", "",
  158.                                     "%name%.setState(%name%.STATE_UNCHECKED);",
  159.                                     "チェックマークをクリアする");
  160. //                                    "Clear the checkbox");
  161.             connections.addElement(connection);
  162.  
  163.             connection = new ConnectionDescriptor("input", "void", "",
  164.                                     "%name%.setState(%name%.STATE_CHECKED);",
  165.                                     "チェックマークをセットする");
  166. //                                    "Check the checkbox");
  167.             connections.addElement(connection);
  168.  
  169.             setState.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  170.             md.addElement(setState);
  171.         } catch (Exception e) { throw new Error("setState:: " + e.toString()); }
  172.  
  173.         try{
  174.             args = null;
  175.             MethodDescriptor getState = new MethodDescriptor(beanClass.getMethod("getState", args));
  176.  
  177.             connections = new java.util.Vector();
  178.             connection = new ConnectionDescriptor("output", "int", "",
  179.                                     "%name%.getState()",
  180.                                     "状態を取得する");
  181. //                                    "Get the checkbox state");
  182.             connections.addElement(connection);
  183.  
  184.             connection = new ConnectionDescriptor("output", "boolean", "",
  185.                                     "(%name%.getState() == %name%.STATE_CHECKED)",
  186.                                     "チェックマークがセットされているならば");
  187. //                                    "Is checkbox On?");
  188.             connections.addElement(connection);
  189.  
  190.             connection = new ConnectionDescriptor("output", "boolean", "",
  191.                                     "(%name%.getState() == %name%.STATE_UNCHECKED)",
  192.                                     "チェックマークがクリアされているならば");
  193. //                                    "Is checkbox Off?");
  194.             connections.addElement(connection);
  195.  
  196.             getState.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  197.             md.addElement(getState);
  198.         } catch (Exception e) { throw new Error("getState:: " + e.toString()); }
  199.  
  200.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  201.         md.copyInto(rv);
  202.  
  203.         return rv;
  204.     }
  205.  
  206.     /**
  207.      * Returns descriptions of this bean's properties.
  208.      */
  209.     public PropertyDescriptor[] getPropertyDescriptors() {
  210.         try{
  211.         PropertyDescriptor style = new PropertyDescriptor("style", beanClass);
  212.         style.setBound(true);
  213.         style.setConstrained(true);
  214.         style.setDisplayName("スタイル");
  215. //        style.setDisplayName("Style");
  216.         style.setValue("ENUMERATION", "TWO_STATE=0, THREE_STATE=1");
  217.  
  218.         PropertyDescriptor state = new PropertyDescriptor("state", beanClass);
  219.         state.setBound(true);
  220.         state.setConstrained(true);
  221.         state.setDisplayName("状態");
  222. //        state.setDisplayName("State");
  223.         state.setValue("ENUMERATION", "STATE_UNCHECKED=0, STATE_CHECKED=1, STATE_DEFAULT=2");
  224.  
  225.         PropertyDescriptor[] rv = {
  226.             style,
  227.             state};
  228.         return rv;
  229.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  230.     }
  231.  
  232.     private final static Class beanClass = StateCheckBox.class;
  233.  
  234.     }    //  end of class StateCheckBoxBeanInfo