Clover coverage report - AdWT - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:14:10 CET
file stats: LOC: 662   Methods: 16
NCLOC: 463   Classes: 4
 
 Source file Conditionals Statements Methods TOTAL
GenericCustomizer.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * EJTools, the Enterprise Java Tools
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at www.gnu.org.
 6   
  */
 7   
 package org.ejtools.adwt;
 8   
 
 9   
 import java.awt.Color;
 10   
 import java.awt.Component;
 11   
 import java.awt.Frame;
 12   
 import java.awt.GridBagConstraints;
 13   
 import java.awt.GridBagLayout;
 14   
 import java.awt.Insets;
 15   
 import java.awt.event.ActionEvent;
 16   
 import java.awt.event.ActionListener;
 17   
 import java.beans.BeanInfo;
 18   
 import java.beans.Customizer;
 19   
 import java.beans.Introspector;
 20   
 import java.beans.MethodDescriptor;
 21   
 import java.beans.PropertyChangeEvent;
 22   
 import java.beans.PropertyChangeListener;
 23   
 import java.beans.PropertyDescriptor;
 24   
 import java.beans.PropertyEditor;
 25   
 import java.beans.PropertyVetoException;
 26   
 import java.lang.reflect.InvocationTargetException;
 27   
 import java.lang.reflect.Method;
 28   
 import java.util.StringTokenizer;
 29   
 
 30   
 import javax.swing.JButton;
 31   
 import javax.swing.JComponent;
 32   
 import javax.swing.JLabel;
 33   
 import javax.swing.JOptionPane;
 34   
 import javax.swing.JPanel;
 35   
 import javax.swing.JScrollPane;
 36   
 import javax.swing.SwingConstants;
 37   
 import javax.swing.SwingUtilities;
 38   
 import javax.swing.border.TitledBorder;
 39   
 
 40   
 import org.ejtools.adwt.editor.ArrayEditor;
 41   
 import org.ejtools.beans.CustomPropertyEditorManager;
 42   
 import org.ejtools.util.ClassTools;
 43   
 
 44   
 import com.dreambean.awt.GenericMethodDialog;
 45   
 import com.dreambean.awt.GenericPropertyCustomizer;
 46   
 
 47   
 /**
 48   
  * Description of the Class
 49   
  *
 50   
  * @author    Laurent Etiemble
 51   
  * @version   $Revision: 1.10 $
 52   
  * @todo      Non Supported classes displayed
 53   
  * @todo      Result of Command put into an Output List
 54   
  */
 55   
 public class GenericCustomizer extends JScrollPane implements Customizer
 56   
 {
 57   
 
 58   
    /** Description of the Field */
 59   
    private JPanel beanGui;
 60   
    /** Description of the Field */
 61   
    private MethodDescriptor md[];
 62   
    /** Description of the Field */
 63   
    private Object object;
 64   
    /** Description of the Field */
 65   
    private JPanel p;
 66   
    /** Description of the Field */
 67   
    private PropertyDescriptor pd[];
 68   
    /** Description of the Field */
 69   
    private JComponent previous;
 70   
    /** Description of the Field */
 71   
    private boolean showMethods;
 72   
 
 73   
 
 74   
    /** Constructor for the GenericCustomizer object */
 75  0
    public GenericCustomizer()
 76   
    {
 77  0
       this(true);
 78   
    }
 79   
 
 80   
 
 81   
    /**
 82   
     * Constructor for the GenericCustomizer object
 83   
     *
 84   
     * @param obj  Description of Parameter
 85   
     */
 86  0
    public GenericCustomizer(Object obj)
 87   
    {
 88  0
       this();
 89  0
       this.setObject(obj);
 90   
    }
 91   
 
 92   
 
 93   
    /**
 94   
     * Constructor for the GenericCustomizer object
 95   
     *
 96   
     * @param flag  Description of Parameter
 97   
     */
 98  0
    public GenericCustomizer(boolean flag)
 99   
    {
 100  0
       super(new JPanel());
 101  0
       this.previous = null;
 102  0
       this.p = (JPanel) getViewport().getView();
 103  0
       this.p.setLayout(new GridBagLayout());
 104  0
       this.showMethods = flag;
 105   
    }
 106   
 
 107   
 
 108   
    /**
 109   
     * Constructor for the GenericCustomizer object
 110   
     *
 111   
     * @param flag  Description of Parameter
 112   
     * @param obj   Description of Parameter
 113   
     */
 114  0
    public GenericCustomizer(boolean flag, Object obj)
 115   
    {
 116  0
       this(flag);
 117  0
       this.setObject(obj);
 118   
    }
 119   
 
 120   
 
 121   
    /**
 122   
     * Sets the Object attribute of the GenericCustomizer object
 123   
     *
 124   
     * @param obj  The new Object value
 125   
     */
 126  0
    public void setObject(Object obj)
 127   
    {
 128  0
       try
 129   
       {
 130  0
          this.p.removeAll();
 131   
 
 132  0
          if (obj == null)
 133   
          {
 134  0
             this.validate();
 135  0
             this.repaint();
 136  0
             return;
 137   
          }
 138  0
          this.object = obj;
 139   
 
 140  0
          GridBagConstraints gridbagconstraints = new GridBagConstraints();
 141  0
          gridbagconstraints.insets = new Insets(0, 0, 0, 0);
 142  0
          gridbagconstraints.anchor = GridBagConstraints.NORTH;
 143  0
          gridbagconstraints.weighty = 1.0D;
 144   
 
 145  0
          BeanInfo beaninfo;
 146  0
          if (obj instanceof BeanInfo)
 147   
          {
 148  0
             beaninfo = (BeanInfo) obj;
 149   
          }
 150   
          else
 151   
          {
 152  0
             beaninfo = Introspector.getBeanInfo(obj.getClass());
 153   
          }
 154   
 
 155  0
          this.beanGui = new JPanel(new GridBagLayout());
 156  0
          this.beanGui.setBorder(new TitledBorder(beaninfo.getBeanDescriptor().getDisplayName()));
 157   
 
 158  0
          pd = beaninfo.getPropertyDescriptors();
 159  0
          if (pd != null)
 160   
          {
 161  0
             if (beaninfo.getBeanDescriptor().getValue("propertyorder") == null)
 162   
             {
 163  0
                for (int i = 0; i < pd.length; i++)
 164   
                {
 165  0
                   if (!pd[i].getReadMethod().getDeclaringClass().equals(Object.class) && !pd[i].isHidden())
 166   
                   {
 167  0
                      PropertyEditor propertyeditor = null;
 168   
 
 169   
                      // Try to load the class
 170  0
                      Class c = ClassTools.getClass(pd[i].getPropertyType().getName());
 171  0
                      if (c == null)
 172   
                      {
 173  0
                         this.addUnsupportedProperty(pd[i]);
 174   
                      }
 175   
                      else
 176   
                      {
 177   
                         // Test if there is an editor
 178  0
                         Class clazz = pd[i].getPropertyEditorClass();
 179  0
                         if (clazz != null)
 180   
                         {
 181  0
                            propertyeditor = (PropertyEditor) clazz.newInstance();
 182   
                         }
 183   
 
 184   
                         // If it's an array, take
 185  0
                         if (pd[i].getPropertyType().isArray())
 186   
                         {
 187  0
                            Class componentType = pd[i].getPropertyType().getComponentType();
 188  0
                            propertyeditor = new ArrayEditor(componentType);
 189  0
                            this.addProperty(pd[i], propertyeditor);
 190   
                         }
 191   
                         else
 192   
                         {
 193  0
                            if (propertyeditor == null)
 194   
                            {
 195  0
                               propertyeditor = CustomPropertyEditorManager.findEditor(pd[i].getPropertyType());
 196   
                            }
 197  0
                            if (propertyeditor == null)
 198   
                            {
 199  0
                               propertyeditor = CustomPropertyEditorManager.findEditor(String.class);
 200   
                            }
 201  0
                            this.addProperty(pd[i], propertyeditor);
 202   
                         }
 203  0
                         gridbagconstraints.weighty = 1.0D;
 204   
                      }
 205   
                   }
 206   
                }
 207   
             }
 208   
             else
 209   
             {
 210  0
                for (StringTokenizer stringtokenizer = new StringTokenizer((String) beaninfo.getBeanDescriptor().getValue("propertyorder"), ":"); stringtokenizer.hasMoreTokens(); )
 211   
                {
 212  0
                   String s = stringtokenizer.nextToken();
 213  0
                   for (int k = 0; k < pd.length; k++)
 214   
                   {
 215  0
                      if (pd[k].getName().equals(s) && !pd[k].isHidden())
 216   
                      {
 217  0
                         PropertyEditor propertyeditor1 = null;
 218  0
                         Class clazz = pd[k].getPropertyEditorClass();
 219  0
                         if (clazz != null)
 220   
                         {
 221  0
                            propertyeditor1 = (PropertyEditor) clazz.newInstance();
 222   
                         }
 223   
 
 224   
                         // Try to load the class
 225  0
                         Class c = ClassTools.getClass(pd[k].getPropertyType().getName());
 226  0
                         if (c == null)
 227   
                         {
 228  0
                            this.addUnsupportedProperty(pd[k]);
 229   
                         }
 230   
                         else
 231   
                         {
 232   
                            // If it's an array, take
 233  0
                            if (pd[k].getPropertyType().isArray())
 234   
                            {
 235  0
                               Class componentType = pd[k].getPropertyType().getComponentType();
 236  0
                               propertyeditor1 = new ArrayEditor(componentType);
 237  0
                               this.addProperty(pd[k], propertyeditor1);
 238   
                            }
 239   
                            else
 240   
                            {
 241  0
                               if (propertyeditor1 == null)
 242   
                               {
 243  0
                                  propertyeditor1 = CustomPropertyEditorManager.findEditor(pd[k].getPropertyType());
 244   
                               }
 245  0
                               if (propertyeditor1 != null)
 246   
                               {
 247  0
                                  propertyeditor1 = CustomPropertyEditorManager.findEditor(String.class);
 248   
                               }
 249  0
                               this.addProperty(pd[k], propertyeditor1);
 250   
                            }
 251  0
                            gridbagconstraints.weighty = 1.0D;
 252   
                         }
 253   
                      }
 254   
                   }
 255   
                }
 256   
             }
 257   
          }
 258   
 
 259  0
          if (showMethods)
 260   
          {
 261  0
             md = beaninfo.getMethodDescriptors();
 262   
 
 263  0
             gridbagconstraints.weighty = 1.0D;
 264  0
             gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 265  0
             gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 266   
 
 267  0
             if (md != null)
 268   
             {
 269  0
                for (int j = 0; j < md.length; j++)
 270   
                {
 271  0
                   if (!md[j].getName().startsWith("get") && !md[j].getName().startsWith("set") && !md[j].getName().startsWith("is"))
 272   
                   {
 273  0
                      JButton jbutton = new JButton(md[j].getDisplayName());
 274  0
                      jbutton.setToolTipText(md[j].getShortDescription());
 275  0
                      beanGui.add(jbutton, gridbagconstraints);
 276  0
                      jbutton.addActionListener(new MethodInvoker(md[j]));
 277   
                   }
 278   
                }
 279   
             }
 280   
          }
 281   
 
 282  0
          gridbagconstraints.weighty = 0.0D;
 283  0
          gridbagconstraints.weightx = 1.0D;
 284  0
          gridbagconstraints.fill = GridBagConstraints.BOTH;
 285  0
          p.add(beanGui, gridbagconstraints);
 286   
 
 287   
          // Add a spacer
 288  0
          gridbagconstraints.weighty = 1.0D;
 289  0
          p.add(new JLabel(" "), gridbagconstraints);
 290   
 
 291  0
          this.validate();
 292  0
          this.repaint();
 293   
       }
 294   
       catch (Exception exception)
 295   
       {
 296  0
          System.out.println("Exception occurred");
 297  0
          exception.printStackTrace();
 298   
       }
 299   
    }
 300   
 
 301   
 
 302   
    /**
 303   
     * Adds a feature to the Property attribute of the GenericCustomizer object
 304   
     *
 305   
     * @param propertyeditor      The feature to be added to the Property attribute
 306   
     * @param propertydescriptor  The feature to be added to the Property attribute
 307   
     */
 308  0
    protected void addProperty(PropertyDescriptor propertydescriptor, PropertyEditor propertyeditor)
 309   
    {
 310  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 311  0
       gridbagconstraints.insets = new Insets(3, 3, 3, 3);
 312   
 
 313  0
       try
 314   
       {
 315  0
          Object obj = propertydescriptor.getReadMethod().invoke(object, new Object[0]);
 316  0
          if (obj != null)
 317   
          {
 318  0
             propertyeditor.setValue(obj);
 319   
          }
 320  0
          if (!obj.equals(propertyeditor.getValue()))
 321   
          {
 322  0
             propertydescriptor.getWriteMethod().invoke(object, new Object[]{
 323   
                propertyeditor.getValue()
 324   
                });
 325   
          }
 326   
       }
 327   
       catch (Exception _ex)
 328   
       {
 329   
       }
 330   
 
 331  0
       JLabel jlabel = new JLabel(propertydescriptor.getDisplayName() + " : ", SwingConstants.RIGHT);
 332  0
       jlabel.setToolTipText(propertydescriptor.getShortDescription());
 333   
 
 334  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 335  0
       gridbagconstraints.weightx = 0.0D;
 336  0
       gridbagconstraints.weighty = 1.0D;
 337  0
       gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 338  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 339   
 
 340  0
       this.beanGui.add(jlabel, gridbagconstraints);
 341  0
       Object obj1;
 342  0
       if (propertyeditor.supportsCustomEditor())
 343   
       {
 344  0
          obj1 = propertyeditor.getCustomEditor();
 345  0
          if (obj1 instanceof JComponent)
 346   
          {
 347  0
             if (previous != null)
 348   
             {
 349  0
                previous.setNextFocusableComponent(((Component) (obj1)));
 350   
             }
 351  0
             previous = (JComponent) obj1;
 352   
          }
 353   
       }
 354   
       else
 355   
       {
 356  0
          String as[] = propertyeditor.getTags();
 357  0
          if (as != null)
 358   
          {
 359  0
             obj1 = new GenericPropertyCustomizer(propertyeditor, as);
 360  0
             if (previous != null)
 361   
             {
 362  0
                previous.setNextFocusableComponent(((Component) (obj1)));
 363   
             }
 364  0
             previous = (JComponent) obj1;
 365   
          }
 366  0
          else if (propertydescriptor.getWriteMethod() != null)
 367   
          {
 368  0
             obj1 = new GenericPropertyCustomizer(propertyeditor);
 369  0
             if (previous != null)
 370   
             {
 371  0
                previous.setNextFocusableComponent(((Component) (obj1)));
 372   
             }
 373  0
             previous = (JComponent) obj1;
 374   
          }
 375   
          else
 376   
          {
 377  0
             final JLabel lbl = new JLabel(propertyeditor.getAsText());
 378  0
             final PropertyEditor pcEditor = propertyeditor;
 379  0
             obj1 = lbl;
 380  0
             pcEditor.addPropertyChangeListener(
 381   
                new PropertyChangeListener()
 382   
                {
 383  0
                   public void propertyChange(PropertyChangeEvent propertychangeevent)
 384   
                   {
 385  0
                      lbl.setText(pcEditor.getAsText());
 386   
                   }
 387   
                });
 388   
          }
 389   
       }
 390   
 
 391  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 392  0
       gridbagconstraints.weightx = 1.0D;
 393   
 
 394  0
       this.beanGui.add(((Component) (obj1)), gridbagconstraints);
 395   
 
 396  0
       if (propertydescriptor.getWriteMethod() != null)
 397   
       {
 398  0
          propertyeditor.addPropertyChangeListener(new BeanUpdater(propertydescriptor));
 399   
       }
 400  0
       try
 401   
       {
 402  0
          Method method = object.getClass().getMethod("addPropertyChangeListener", new Class[]{java.lang.String.class, java.beans.PropertyChangeListener.class});
 403  0
          method.invoke(object, new Object[]{propertydescriptor.getName(), new EditorUpdater(propertyeditor, propertydescriptor.getName())});
 404   
       }
 405   
       catch (Exception _ex)
 406   
       {
 407  0
          try
 408   
          {
 409  0
             Method method1 = object.getClass().getMethod("addPropertyChangeListener", new Class[]{java.beans.PropertyChangeListener.class});
 410  0
             method1.invoke(object, new Object[]{new EditorUpdater(propertyeditor, propertydescriptor)});
 411   
          }
 412   
          catch (Exception _ex2)
 413   
          {
 414  0
             System.out.println("Exception occurred");
 415  0
             _ex2.printStackTrace();
 416   
          }
 417   
       }
 418   
    }
 419   
 
 420   
 
 421   
    /**
 422   
     * Adds a feature to the UnsupportedProperty attribute of the SimpleCustomizer object
 423   
     *
 424   
     * @param propertydescriptor  The feature to be added to the UnsupportedProperty attribute
 425   
     */
 426  0
    protected void addUnsupportedProperty(PropertyDescriptor propertydescriptor)
 427   
    {
 428  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 429  0
       gridbagconstraints.insets = new Insets(3, 3, 3, 3);
 430   
 
 431  0
       JLabel jlabel = new JLabel(propertydescriptor.getName() + " : ", SwingConstants.RIGHT);
 432  0
       jlabel.setToolTipText(propertydescriptor.getShortDescription());
 433  0
       jlabel.setForeground(Color.black);
 434   
 
 435  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 436  0
       gridbagconstraints.weightx = 0.0D;
 437  0
       gridbagconstraints.weighty = 1.0D;
 438  0
       gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 439  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 440   
 
 441  0
       this.beanGui.add(jlabel, gridbagconstraints);
 442   
 
 443   
 //      JLabel lbl = new JLabel(resources.getString("customizer.text.unloadable.class") + " " + ClassTools.classDisplay(attributeInfo.getType()));
 444  0
       JLabel lbl = new JLabel("customizer.text.unloadable.class" + " " + ClassTools.classDisplay(propertydescriptor.getPropertyType().getName()));
 445  0
       lbl.setForeground(AwtToolkit.DARK_RED);
 446   
 
 447  0
       gridbagconstraints.weightx = 1.0D;
 448  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 449   
 
 450  0
       this.add(lbl, gridbagconstraints);
 451   
    }
 452   
 
 453   
 
 454   
    /**
 455   
     * Description of the Method
 456   
     *
 457   
     * @param name      Description of the Parameter
 458   
     * @param oldValue  Description of the Parameter
 459   
     * @param newValue  Description of the Parameter
 460   
     */
 461  0
    protected void updated(String name, Object oldValue, Object newValue)
 462   
    {
 463  0
       this.firePropertyChange(name, oldValue, newValue);
 464   
    }
 465   
 
 466   
 
 467   
    /**
 468   
     * Description of the Class
 469   
     *
 470   
     * @author    root
 471   
     * @version   $Revision: 1.10 $
 472   
     */
 473   
    protected class BeanUpdater implements PropertyChangeListener
 474   
    {
 475   
       /** Description of the Field */
 476   
       protected PropertyDescriptor pd;
 477   
 
 478   
 
 479   
       /**
 480   
        * Constructor for the BeanUpdater object
 481   
        *
 482   
        * @param propertydescriptor  Description of Parameter
 483   
        */
 484  0
       public BeanUpdater(PropertyDescriptor propertydescriptor)
 485   
       {
 486  0
          this.pd = propertydescriptor;
 487   
       }
 488   
 
 489   
 
 490   
       /**
 491   
        * Description of the Method
 492   
        *
 493   
        * @param event  Description of the Parameter
 494   
        */
 495  0
       public void propertyChange(PropertyChangeEvent event)
 496   
       {
 497  0
          try
 498   
          {
 499  0
             Object oldValue = pd.getReadMethod().invoke(object, new Object[0]);
 500  0
             Object newValue = ((PropertyEditor) event.getSource()).getValue();
 501  0
             pd.getWriteMethod().invoke(object, new Object[]{newValue});
 502  0
             GenericCustomizer.this.updated(pd.getName(), oldValue, newValue);
 503   
          }
 504   
          catch (InvocationTargetException invocationtargetexception)
 505   
          {
 506  0
             if (invocationtargetexception.getTargetException() instanceof PropertyVetoException)
 507   
             {
 508  0
                JOptionPane.showMessageDialog((Frame) SwingUtilities.windowForComponent(GenericCustomizer.this), "Could not change value:" + invocationtargetexception.getTargetException().getMessage(), "Error", 0);
 509   
             }
 510   
          }
 511   
          catch (Exception exception)
 512   
          {
 513  0
             System.err.println(exception);
 514   
          }
 515   
       }
 516   
    }
 517   
 
 518   
 
 519   
    /**
 520   
     * Description of the Class
 521   
     *
 522   
     * @author    root
 523   
     * @version   $Revision: 1.10 $
 524   
     */
 525   
    protected class EditorUpdater implements PropertyChangeListener
 526   
    {
 527   
       /** Description of the Field */
 528   
       protected PropertyEditor editor;
 529   
       /** Description of the Field */
 530   
       protected PropertyDescriptor pd;
 531   
       /** Description of the Field */
 532   
       protected String propName;
 533   
 
 534   
 
 535   
       /**
 536   
        * Constructor for the EditorUpdater object
 537   
        *
 538   
        * @param propertyeditor      Description of Parameter
 539   
        * @param propertydescriptor  Description of Parameter
 540   
        */
 541  0
       public EditorUpdater(PropertyEditor propertyeditor, PropertyDescriptor propertydescriptor)
 542   
       {
 543  0
          propName = null;
 544  0
          editor = propertyeditor;
 545  0
          pd = propertydescriptor;
 546   
       }
 547   
 
 548   
 
 549   
       /**
 550   
        * Constructor for the EditorUpdater object
 551   
        *
 552   
        * @param propertyeditor  Description of Parameter
 553   
        * @param s               Description of Parameter
 554   
        */
 555  0
       public EditorUpdater(PropertyEditor propertyeditor, String s)
 556   
       {
 557  0
          propName = null;
 558  0
          editor = propertyeditor;
 559  0
          propName = s;
 560   
       }
 561   
 
 562   
 
 563   
       /**
 564   
        * Description of the Method
 565   
        *
 566   
        * @param propertychangeevent  Description of Parameter
 567   
        */
 568  0
       public void propertyChange(PropertyChangeEvent propertychangeevent)
 569   
       {
 570  0
          if (propName != null && propertychangeevent.getPropertyName() != null && !propertychangeevent.getPropertyName().equals(propName))
 571   
          {
 572  0
             return;
 573   
          }
 574  0
          if (propertychangeevent.getPropertyName() != null)
 575   
          {
 576  0
             if (!editor.getValue().equals(propertychangeevent.getNewValue()))
 577   
             {
 578  0
                editor.setValue(propertychangeevent.getNewValue());
 579   
             }
 580   
          }
 581   
          else
 582   
          {
 583  0
             try
 584   
             {
 585  0
                Object obj = pd.getReadMethod().invoke(propertychangeevent.getSource(), new Object[0]);
 586  0
                if (obj != null && !obj.equals(editor.getValue()))
 587   
                {
 588  0
                   editor.setValue(obj);
 589   
                }
 590   
             }
 591   
             catch (Exception _ex)
 592   
             {
 593   
             }
 594   
          }
 595   
       }
 596   
    }
 597   
 
 598   
 
 599   
    /**
 600   
     * Description of the Class
 601   
     *
 602   
     * @author    root
 603   
     * @version   $Revision: 1.10 $
 604   
     */
 605   
    protected class MethodInvoker implements ActionListener
 606   
    {
 607   
       /** Description of the Field */
 608   
       protected MethodDescriptor methoddescriptor;
 609   
 
 610   
 
 611   
       /**
 612   
        * Constructor for the MethodInvoker object
 613   
        *
 614   
        * @param methoddescriptor  Description of Parameter
 615   
        */
 616  0
       public MethodInvoker(MethodDescriptor methoddescriptor)
 617   
       {
 618  0
          this.methoddescriptor = methoddescriptor;
 619   
       }
 620   
 
 621   
 
 622   
       /**
 623   
        * Description of the Method
 624   
        *
 625   
        * @param actionevent  Description of Parameter
 626   
        */
 627  0
       public void actionPerformed(ActionEvent actionevent)
 628   
       {
 629  0
          Object obj;
 630  0
          for (obj = p; !(obj instanceof Frame); obj = ((Component) (obj)).getParent())
 631   
          {
 632   
             ;
 633   
          }
 634  0
          if (methoddescriptor.getParameterDescriptors() == null
 635   
             && methoddescriptor.getMethod().getParameterTypes().length == 0
 636   
             || methoddescriptor.getParameterDescriptors() != null
 637   
             && methoddescriptor.getParameterDescriptors().length == 0)
 638   
          {
 639  0
             try
 640   
             {
 641  0
                methoddescriptor.getMethod().invoke(object, new Object[0]);
 642   
             }
 643   
             catch (InvocationTargetException invocationtargetexception)
 644   
             {
 645  0
                invocationtargetexception.getTargetException().printStackTrace();
 646  0
                JOptionPane.showMessageDialog(((Component) (obj)), invocationtargetexception.getTargetException().getMessage(), "Error", 0);
 647   
             }
 648   
             catch (Exception exception)
 649   
             {
 650  0
                System.err.println(exception);
 651  0
                JOptionPane.showMessageDialog(((Component) (obj)), "An exception occured. Check log for details", "Error", 0);
 652   
             }
 653   
          }
 654   
          else
 655   
          {
 656  0
             new GenericMethodDialog(object, methoddescriptor, (Frame) obj);
 657   
          }
 658   
       }
 659   
    }
 660   
 }
 661   
 
 662