[Ejtools-cvs] CVS: libraries/adwt/src/main/net/sourceforge/ejtools/awt GenericCustomizer.java,1.2,1.
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-05-05 20:13:25
|
Update of /cvsroot/ejtools/libraries/adwt/src/main/net/sourceforge/ejtools/awt In directory usw-pr-cvs1:/tmp/cvs-serv8617/adwt/src/main/net/sourceforge/ejtools/awt Modified Files: GenericCustomizer.java Log Message: Add some JavaDocs Index: GenericCustomizer.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/net/sourceforge/ejtools/awt/GenericCustomizer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GenericCustomizer.java 30 Apr 2002 21:07:09 -0000 1.2 --- GenericCustomizer.java 5 May 2002 20:13:22 -0000 1.3 *************** *** 43,73 **** /** ! * Description of the Class * ! * @author letiembl ! * @created 8 avril 2002 ! * @todo Non Supported classes displayed ! * @todo Result of Command put into an Output List */ public class GenericCustomizer extends JScrollPane implements Customizer { ! /** Description of the Field */ private JPanel beanGui; ! /** Description of the Field */ private MethodDescriptor md[]; ! /** Description of the Field */ private Object object; ! /** Description of the Field */ private JPanel p; ! /** Description of the Field */ private PropertyDescriptor pd[]; ! /** Description of the Field */ private JComponent previous; ! /** Description of the Field */ private boolean showMethods; ! /** Constructor for the GenericCustomizer object */ public GenericCustomizer() { --- 43,73 ---- /** ! * Description of the Class * ! * @author letiembl ! * @created 8 avril 2002 ! * @todo Non Supported classes displayed ! * @todo Result of Command put into an Output List */ public class GenericCustomizer extends JScrollPane implements Customizer { ! /** Description of the Field */ private JPanel beanGui; ! /** Description of the Field */ private MethodDescriptor md[]; ! /** Description of the Field */ private Object object; ! /** Description of the Field */ private JPanel p; ! /** Description of the Field */ private PropertyDescriptor pd[]; ! /** Description of the Field */ private JComponent previous; ! /** Description of the Field */ private boolean showMethods; ! /** Constructor for the GenericCustomizer object */ public GenericCustomizer() { *************** *** 77,83 **** /** ! * Constructor for the GenericCustomizer object * ! * @param obj Description of Parameter */ public GenericCustomizer(Object obj) --- 77,83 ---- /** ! * Constructor for the GenericCustomizer object * ! * @param obj Description of Parameter */ public GenericCustomizer(Object obj) *************** *** 89,95 **** /** ! * Constructor for the GenericCustomizer object * ! * @param flag Description of Parameter */ public GenericCustomizer(boolean flag) --- 89,95 ---- /** ! * Constructor for the GenericCustomizer object * ! * @param flag Description of Parameter */ public GenericCustomizer(boolean flag) *************** *** 105,112 **** /** ! * Constructor for the GenericCustomizer object * ! * @param flag Description of Parameter ! * @param obj Description of Parameter */ public GenericCustomizer(boolean flag, Object obj) --- 105,112 ---- /** ! * Constructor for the GenericCustomizer object * ! * @param flag Description of Parameter ! * @param obj Description of Parameter */ public GenericCustomizer(boolean flag, Object obj) *************** *** 118,303 **** /** ! * Sets the Object attribute of the GenericCustomizer object ! * ! * @param obj The new Object value ! */ ! public void setObject(Object obj) ! { ! try ! { ! p.removeAll(); ! ! if (obj == null) ! { ! validate(); ! repaint(); ! return; ! } ! object = obj; ! ! GridBagConstraints gridbagconstraints = new GridBagConstraints(); ! gridbagconstraints.insets = new Insets(3, 3, 3, 3); ! gridbagconstraints.anchor = GridBagConstraints.NORTH; ! gridbagconstraints.weighty = 1.0D; ! ! BeanInfo beaninfo; ! if (obj instanceof BeanInfo) ! { ! beaninfo = (BeanInfo) obj; ! } ! else ! { ! beaninfo = Introspector.getBeanInfo(obj.getClass()); ! } ! ! beanGui = new JPanel(new GridBagLayout()); ! beanGui.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), beaninfo.getBeanDescriptor().getDisplayName())); ! /* ! * if (beaninfo.getIcon(BeanInfo.ICON_COLOR_32x32) != null) ! * { ! * beanGui.setBorder(new GenericTitledBorder(BorderFactory.createEtchedBorder(), beaninfo.getBeanDescriptor().getDisplayName(), new ImageIcon(beaninfo.getIcon(BeanInfo.ICON_COLOR_32x32)))); ! * } ! * else ! * { ! * beanGui.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), beaninfo.getBeanDescriptor().getDisplayName())); ! * } ! */ ! pd = beaninfo.getPropertyDescriptors(); ! if (pd != null) ! { ! if (beaninfo.getBeanDescriptor().getValue("propertyorder") == null) ! { ! for (int i = 0; i < pd.length; i++) ! { ! if (!pd[i].getReadMethod().getDeclaringClass().equals(java.lang.Object.class) && !pd[i].isHidden()) ! { ! PropertyEditor propertyeditor = null; ! ! // Test if there is an editor ! Class class1 = pd[i].getPropertyEditorClass(); ! if (class1 != null) ! { ! propertyeditor = (PropertyEditor) class1.newInstance(); ! } ! ! // System.out.println("Property " + pd[i].getPropertyType()); ! ! // If it's an array, take ! if (pd[i].getPropertyType().isArray()) ! { ! Class componentType = pd[i].getPropertyType().getComponentType(); ! propertyeditor = PropertyEditorManager.findEditor(componentType); ! ! addArrayProperty(propertyeditor, pd[i]); ! } ! else ! { ! if (propertyeditor == null) ! { ! propertyeditor = PropertyEditorManager.findEditor(pd[i].getPropertyType()); ! } ! if (propertyeditor != null) ! { ! addProperty(propertyeditor, pd[i]); ! } ! } ! gridbagconstraints.weighty = 1.0D; ! } ! } ! } ! else ! { ! for (StringTokenizer stringtokenizer = new StringTokenizer((String) beaninfo.getBeanDescriptor().getValue("propertyorder"), ":"); stringtokenizer.hasMoreTokens(); ) ! { ! String s = stringtokenizer.nextToken(); ! for (int k = 0; k < pd.length; k++) ! { ! if (pd[k].getName().equals(s) && !pd[k].isHidden()) ! { ! PropertyEditor propertyeditor1 = null; ! Class class2 = pd[k].getPropertyEditorClass(); ! if (class2 != null) ! { ! propertyeditor1 = (PropertyEditor) class2.newInstance(); ! } ! ! // System.out.println("Property " + pd[k].getPropertyType()); ! ! // If it's an array, take ! if (pd[k].getPropertyType().isArray()) ! { ! Class componentType = pd[k].getPropertyType().getComponentType(); ! propertyeditor1 = PropertyEditorManager.findEditor(componentType); ! ! addArrayProperty(propertyeditor1, pd[k]); ! } ! else ! { ! if (propertyeditor1 == null) ! { ! propertyeditor1 = PropertyEditorManager.findEditor(pd[k].getPropertyType()); ! } ! if (propertyeditor1 != null) ! { ! addProperty(propertyeditor1, pd[k]); ! } ! } ! gridbagconstraints.weighty = 1.0D; ! } ! } ! } ! } ! } ! ! if (showMethods) ! { ! md = beaninfo.getMethodDescriptors(); ! ! gridbagconstraints.weighty = 1.0D; ! gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER; ! gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; ! ! if (md != null) ! { ! for (int j = 0; j < md.length; j++) ! { ! if (!md[j].getName().startsWith("get") && !md[j].getName().startsWith("set") && !md[j].getName().startsWith("is")) ! { ! JButton jbutton = new JButton(md[j].getDisplayName()); ! jbutton.setToolTipText(md[j].getShortDescription()); ! beanGui.add(jbutton, gridbagconstraints); ! jbutton.addActionListener(new MethodInvoker(md[j])); ! } ! } ! } ! } ! ! gridbagconstraints.weighty = 0.0D; ! gridbagconstraints.weightx = 1.0D; ! gridbagconstraints.fill = GridBagConstraints.BOTH; ! p.add(beanGui, gridbagconstraints); ! ! // Add a spacer ! gridbagconstraints.weighty = 1.0D; ! p.add(new JLabel(" "), gridbagconstraints); ! ! validate(); ! repaint(); ! } ! catch (Exception exception) ! { ! System.out.println("Exception occurred"); ! exception.printStackTrace(); ! } ! } ! ! ! /** ! * Adds a feature to the ArrayProperty attribute of the GenericCustomizer ! * object * ! * @param propertyeditor The feature to be added to the ArrayProperty * attribute ! * @param propertydescriptor The feature to be added to the ArrayProperty * attribute */ --- 118,127 ---- /** ! * Adds a feature to the ArrayProperty attribute of the GenericCustomizer ! * object * ! * @param propertyeditor The feature to be added to the ArrayProperty * attribute ! * @param propertydescriptor The feature to be added to the ArrayProperty * attribute */ *************** *** 406,414 **** /** ! * Adds a feature to the Property attribute of the GenericCustomizer object * ! * @param propertyeditor The feature to be added to the Property * attribute ! * @param propertydescriptor The feature to be added to the Property * attribute */ --- 230,238 ---- /** ! * Adds a feature to the Property attribute of the GenericCustomizer object * ! * @param propertyeditor The feature to be added to the Property * attribute ! * @param propertydescriptor The feature to be added to the Property * attribute */ *************** *** 527,535 **** /** ! * Description of the Method * ! * @param s Description of Parameter ! * @param obj Description of Parameter ! * @param obj1 Description of Parameter */ protected void updated(String s, Object obj, Object obj1) --- 351,535 ---- /** ! * Sets the Object attribute of the GenericCustomizer object * ! * @param obj The new Object value ! */ ! public void setObject(Object obj) ! { ! try ! { ! p.removeAll(); ! ! if (obj == null) ! { ! validate(); ! repaint(); ! return; ! } ! object = obj; ! ! GridBagConstraints gridbagconstraints = new GridBagConstraints(); ! gridbagconstraints.insets = new Insets(3, 3, 3, 3); ! gridbagconstraints.anchor = GridBagConstraints.NORTH; ! gridbagconstraints.weighty = 1.0D; ! ! BeanInfo beaninfo; ! if (obj instanceof BeanInfo) ! { ! beaninfo = (BeanInfo) obj; ! } ! else ! { ! beaninfo = Introspector.getBeanInfo(obj.getClass()); ! } ! ! beanGui = new JPanel(new GridBagLayout()); ! beanGui.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), beaninfo.getBeanDescriptor().getDisplayName())); ! /* ! * if (beaninfo.getIcon(BeanInfo.ICON_COLOR_32x32) != null) ! * { ! * beanGui.setBorder(new GenericTitledBorder(BorderFactory.createEtchedBorder(), beaninfo.getBeanDescriptor().getDisplayName(), new ImageIcon(beaninfo.getIcon(BeanInfo.ICON_COLOR_32x32)))); ! * } ! * else ! * { ! * beanGui.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), beaninfo.getBeanDescriptor().getDisplayName())); ! * } ! */ ! pd = beaninfo.getPropertyDescriptors(); ! if (pd != null) ! { ! if (beaninfo.getBeanDescriptor().getValue("propertyorder") == null) ! { ! for (int i = 0; i < pd.length; i++) ! { ! if (!pd[i].getReadMethod().getDeclaringClass().equals(java.lang.Object.class) && !pd[i].isHidden()) ! { ! PropertyEditor propertyeditor = null; ! ! // Test if there is an editor ! Class class1 = pd[i].getPropertyEditorClass(); ! if (class1 != null) ! { ! propertyeditor = (PropertyEditor) class1.newInstance(); ! } ! ! // System.out.println("Property " + pd[i].getPropertyType()); ! ! // If it's an array, take ! if (pd[i].getPropertyType().isArray()) ! { ! Class componentType = pd[i].getPropertyType().getComponentType(); ! propertyeditor = PropertyEditorManager.findEditor(componentType); ! ! addArrayProperty(propertyeditor, pd[i]); ! } ! else ! { ! if (propertyeditor == null) ! { ! propertyeditor = PropertyEditorManager.findEditor(pd[i].getPropertyType()); ! } ! if (propertyeditor != null) ! { ! addProperty(propertyeditor, pd[i]); ! } ! } ! gridbagconstraints.weighty = 1.0D; ! } ! } ! } ! else ! { ! for (StringTokenizer stringtokenizer = new StringTokenizer((String) beaninfo.getBeanDescriptor().getValue("propertyorder"), ":"); stringtokenizer.hasMoreTokens(); ) ! { ! String s = stringtokenizer.nextToken(); ! for (int k = 0; k < pd.length; k++) ! { ! if (pd[k].getName().equals(s) && !pd[k].isHidden()) ! { ! PropertyEditor propertyeditor1 = null; ! Class class2 = pd[k].getPropertyEditorClass(); ! if (class2 != null) ! { ! propertyeditor1 = (PropertyEditor) class2.newInstance(); ! } ! ! // System.out.println("Property " + pd[k].getPropertyType()); ! ! // If it's an array, take ! if (pd[k].getPropertyType().isArray()) ! { ! Class componentType = pd[k].getPropertyType().getComponentType(); ! propertyeditor1 = PropertyEditorManager.findEditor(componentType); ! ! addArrayProperty(propertyeditor1, pd[k]); ! } ! else ! { ! if (propertyeditor1 == null) ! { ! propertyeditor1 = PropertyEditorManager.findEditor(pd[k].getPropertyType()); ! } ! if (propertyeditor1 != null) ! { ! addProperty(propertyeditor1, pd[k]); ! } ! } ! gridbagconstraints.weighty = 1.0D; ! } ! } ! } ! } ! } ! ! if (showMethods) ! { ! md = beaninfo.getMethodDescriptors(); ! ! gridbagconstraints.weighty = 1.0D; ! gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER; ! gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; ! ! if (md != null) ! { ! for (int j = 0; j < md.length; j++) ! { ! if (!md[j].getName().startsWith("get") && !md[j].getName().startsWith("set") && !md[j].getName().startsWith("is")) ! { ! JButton jbutton = new JButton(md[j].getDisplayName()); ! jbutton.setToolTipText(md[j].getShortDescription()); ! beanGui.add(jbutton, gridbagconstraints); ! jbutton.addActionListener(new MethodInvoker(md[j])); ! } ! } ! } ! } ! ! gridbagconstraints.weighty = 0.0D; ! gridbagconstraints.weightx = 1.0D; ! gridbagconstraints.fill = GridBagConstraints.BOTH; ! p.add(beanGui, gridbagconstraints); ! ! // Add a spacer ! gridbagconstraints.weighty = 1.0D; ! p.add(new JLabel(" "), gridbagconstraints); ! ! validate(); ! repaint(); ! } ! catch (Exception exception) ! { ! System.out.println("Exception occurred"); ! exception.printStackTrace(); ! } ! } ! ! ! /** ! * Description of the Method ! * ! * @param s Description of Parameter ! * @param obj Description of Parameter ! * @param obj1 Description of Parameter */ protected void updated(String s, Object obj, Object obj1) *************** *** 540,558 **** /** ! * Description of the Class * ! * @author root ! * @created 7 octobre 2001 */ protected class BeanUpdater implements PropertyChangeListener { ! /** Description of the Field */ PropertyDescriptor pd; /** ! * Constructor for the BeanUpdater object * ! * @param propertydescriptor Description of Parameter */ public BeanUpdater(PropertyDescriptor propertydescriptor) --- 540,558 ---- /** ! * Description of the Class * ! * @author root ! * @created 7 octobre 2001 */ protected class BeanUpdater implements PropertyChangeListener { ! /** Description of the Field */ PropertyDescriptor pd; /** ! * Constructor for the BeanUpdater object * ! * @param propertydescriptor Description of Parameter */ public BeanUpdater(PropertyDescriptor propertydescriptor) *************** *** 563,569 **** /** ! * Description of the Method * ! * @param propertychangeevent Description of Parameter */ public void propertyChange(PropertyChangeEvent propertychangeevent) --- 563,569 ---- /** ! * Description of the Method * ! * @param propertychangeevent Description of Parameter */ public void propertyChange(PropertyChangeEvent propertychangeevent) *************** *** 593,616 **** /** ! * Description of the Class * ! * @author root ! * @created 7 octobre 2001 */ protected class EditorUpdater implements PropertyChangeListener { ! /** Description of the Field */ PropertyEditor editor; ! /** Description of the Field */ PropertyDescriptor pd; ! /** Description of the Field */ String propName; /** ! * Constructor for the EditorUpdater object * ! * @param propertyeditor Description of Parameter ! * @param propertydescriptor Description of Parameter */ public EditorUpdater(PropertyEditor propertyeditor, PropertyDescriptor propertydescriptor) --- 593,616 ---- /** ! * Description of the Class * ! * @author root ! * @created 7 octobre 2001 */ protected class EditorUpdater implements PropertyChangeListener { ! /** Description of the Field */ PropertyEditor editor; ! /** Description of the Field */ PropertyDescriptor pd; ! /** Description of the Field */ String propName; /** ! * Constructor for the EditorUpdater object * ! * @param propertyeditor Description of Parameter ! * @param propertydescriptor Description of Parameter */ public EditorUpdater(PropertyEditor propertyeditor, PropertyDescriptor propertydescriptor) *************** *** 623,630 **** /** ! * Constructor for the EditorUpdater object * ! * @param propertyeditor Description of Parameter ! * @param s Description of Parameter */ public EditorUpdater(PropertyEditor propertyeditor, String s) --- 623,630 ---- /** ! * Constructor for the EditorUpdater object * ! * @param propertyeditor Description of Parameter ! * @param s Description of Parameter */ public EditorUpdater(PropertyEditor propertyeditor, String s) *************** *** 637,643 **** /** ! * Description of the Method * ! * @param propertychangeevent Description of Parameter */ public void propertyChange(PropertyChangeEvent propertychangeevent) --- 637,643 ---- /** ! * Description of the Method * ! * @param propertychangeevent Description of Parameter */ public void propertyChange(PropertyChangeEvent propertychangeevent) *************** *** 673,691 **** /** ! * Description of the Class * ! * @author root ! * @created 7 octobre 2001 */ protected class MethodInvoker implements ActionListener { ! /** Description of the Field */ MethodDescriptor md; /** ! * Constructor for the MethodInvoker object * ! * @param methoddescriptor Description of Parameter */ MethodInvoker(MethodDescriptor methoddescriptor) --- 673,691 ---- /** ! * Description of the Class * ! * @author root ! * @created 7 octobre 2001 */ protected class MethodInvoker implements ActionListener { ! /** Description of the Field */ MethodDescriptor md; /** ! * Constructor for the MethodInvoker object * ! * @param methoddescriptor Description of Parameter */ MethodInvoker(MethodDescriptor methoddescriptor) *************** *** 696,702 **** /** ! * Description of the Method * ! * @param actionevent Description of Parameter */ public void actionPerformed(ActionEvent actionevent) --- 696,702 ---- /** ! * Description of the Method * ! * @param actionevent Description of Parameter */ public void actionPerformed(ActionEvent actionevent) |