Clover coverage report - AdWT - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:14:10 CET
file stats: LOC: 885   Methods: 21
NCLOC: 608   Classes: 5
 
 Source file Conditionals Statements Methods TOTAL
GenericMBeanCustomizer.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.Component;
 10   
 import java.awt.Container;
 11   
 import java.awt.Frame;
 12   
 import java.awt.GridBagConstraints;
 13   
 import java.awt.GridBagLayout;
 14   
 import java.awt.GridLayout;
 15   
 import java.awt.Insets;
 16   
 import java.awt.event.ActionEvent;
 17   
 import java.awt.event.ActionListener;
 18   
 import java.beans.Customizer;
 19   
 import java.beans.PropertyChangeEvent;
 20   
 import java.beans.PropertyChangeListener;
 21   
 import java.beans.PropertyEditor;
 22   
 import java.lang.reflect.Method;
 23   
 
 24   
 import javax.management.Attribute;
 25   
 import javax.management.MBeanAttributeInfo;
 26   
 import javax.management.MBeanConstructorInfo;
 27   
 import javax.management.MBeanInfo;
 28   
 import javax.management.MBeanNotificationInfo;
 29   
 import javax.management.MBeanOperationInfo;
 30   
 import javax.management.MBeanParameterInfo;
 31   
 import javax.swing.BorderFactory;
 32   
 import javax.swing.JButton;
 33   
 import javax.swing.JComponent;
 34   
 import javax.swing.JLabel;
 35   
 import javax.swing.JOptionPane;
 36   
 import javax.swing.JPanel;
 37   
 import javax.swing.JScrollPane;
 38   
 import javax.swing.SwingConstants;
 39   
 import javax.swing.SwingUtilities;
 40   
 
 41   
 import org.ejtools.jmx.MBeanAccessor;
 42   
 import org.ejtools.util.ClassTools;
 43   
 
 44   
 import com.dreambean.awt.GenericPropertyCustomizer;
 45   
 
 46   
 /**
 47   
  * Description of the Class
 48   
  *
 49   
  * @author    Laurent Etiemble
 50   
  * @version   $Revision: 1.8 $
 51   
  * @todo      Protected method to choose PropertyEditor by Class and Name
 52   
  * @todo      Constructor Info
 53   
  * @todo      Notification Info
 54   
  * @todo      Layout for Contructor Attribute Operation and Notification
 55   
  * @todo      Non Supported classes displayed
 56   
  * @todo      Result of Command put into an Output List
 57   
  */
 58   
 public class GenericMBeanCustomizer extends JScrollPane implements Customizer
 59   
 {
 60   
    /** Description of the Field */
 61   
    private JPanel mbeanConstructors = null;
 62   
    /** Description of the Field */
 63   
    private JPanel mbeanInfo = null;
 64   
    /** Description of the Field */
 65   
    private JPanel mbeanNotifications = null;
 66   
    /** Description of the Field */
 67   
    private JPanel mbeanOperations = null;
 68   
    /** Description of the Field */
 69   
    private MBeanAccessor object;
 70   
    /** Description of the Field */
 71   
    private JPanel p;
 72   
    /** Description of the Field */
 73   
    private JComponent previous;
 74   
 
 75   
 
 76   
 
 77   
    /** Constructor for the GenericCustomizer object */
 78  0
    public GenericMBeanCustomizer()
 79   
    {
 80  0
       super(new JPanel());
 81  0
       previous = null;
 82  0
       this.p = (JPanel) getViewport().getView();
 83  0
       this.p.setLayout(new GridBagLayout());
 84   
    }
 85   
 
 86   
 
 87   
    /**
 88   
     * Constructor for the GenericCustomizer object
 89   
     *
 90   
     * @param obj  Description of Parameter
 91   
     */
 92  0
    public GenericMBeanCustomizer(Object obj)
 93   
    {
 94  0
       this();
 95  0
       this.setObject(obj);
 96   
    }
 97   
 
 98   
 
 99   
    /**
 100   
     * Adds a feature to the ArrayProperty attribute of the GenericCustomizer object
 101   
     *
 102   
     * @param propertyeditor  The feature to be added to the ArrayProperty attribute
 103   
     * @param attributeInfo   The feature to be added to the ArrayProperty attribute
 104   
     */
 105  0
    public void addArrayProperty(PropertyEditor propertyeditor, MBeanAttributeInfo attributeInfo)
 106   
    {
 107  0
       Object obj = null;
 108  0
       Object[] array = null;
 109  0
       JPanel jpanel = null;
 110   
 
 111  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 112  0
       gridbagconstraints.insets = new Insets(3, 3, 3, 3);
 113   
 
 114  0
       try
 115   
       {
 116  0
          if (attributeInfo.isReadable())
 117   
          {
 118  0
             obj = object.getAttribute(attributeInfo.getName());
 119   
          }
 120  0
          if (obj != null)
 121   
          {
 122  0
             array = (Object[]) obj;
 123   
          }
 124   
       }
 125   
       catch (Throwable _ex)
 126   
       {
 127   
       }
 128   
 
 129  0
       JLabel jlabel = new JLabel(attributeInfo.getName() + " :", SwingConstants.RIGHT);
 130  0
       jlabel.setToolTipText(attributeInfo.getDescription());
 131   
 
 132  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 133  0
       gridbagconstraints.weightx = 0.0D;
 134  0
       gridbagconstraints.weighty = 1.0D;
 135  0
       gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 136  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 137   
 
 138   
 //      beanGui.add(jlabel, gridbagconstraints);
 139   
 
 140  0
       if (array == null)
 141   
       {
 142  0
          jpanel = new JPanel();
 143   
       }
 144   
       else
 145   
       {
 146  0
          jpanel = new JPanel(new GridLayout(array.length, 1));
 147  0
          for (int i = 0; i < array.length; i++)
 148   
          {
 149  0
             try
 150   
             {
 151  0
                PropertyEditor propertyeditor1 = (PropertyEditor) propertyeditor.getClass().newInstance();
 152  0
                propertyeditor1.setValue(array[i]);
 153   
 
 154  0
                Object obj1;
 155   
 
 156  0
                if (propertyeditor1.supportsCustomEditor())
 157   
                {
 158  0
                   obj1 = propertyeditor1.getCustomEditor();
 159  0
                   if (obj1 instanceof JComponent)
 160   
                   {
 161  0
                      if (previous != null)
 162   
                      {
 163  0
                         previous.setNextFocusableComponent(((Component) (obj1)));
 164   
                      }
 165  0
                      previous = (JComponent) obj1;
 166   
                   }
 167   
                }
 168   
                else
 169   
                {
 170  0
                   String as[] = propertyeditor1.getTags();
 171  0
                   if (as != null)
 172   
                   {
 173  0
                      obj1 = new GenericPropertyCustomizer(propertyeditor1, as);
 174  0
                      if (previous != null)
 175   
                      {
 176  0
                         previous.setNextFocusableComponent(((Component) (obj1)));
 177   
                      }
 178  0
                      previous = (JComponent) obj1;
 179   
                   }
 180   
                   else
 181   
                   {
 182  0
                      final JLabel lbl = new JLabel(propertyeditor1.getAsText());
 183  0
                      final PropertyEditor pcEditor = propertyeditor1;
 184  0
                      obj1 = lbl;
 185  0
                      pcEditor.addPropertyChangeListener(
 186   
                         new PropertyChangeListener()
 187   
                         {
 188  0
                            public void propertyChange(PropertyChangeEvent evt)
 189   
                            {
 190  0
                               lbl.setText(pcEditor.getAsText());
 191   
                            }
 192   
                         });
 193   
                   }
 194   
                }
 195  0
                jpanel.add((Component) obj1);
 196   
             }
 197   
             catch (Exception _ex)
 198   
             {
 199   
             }
 200   
          }
 201   
       }
 202   
 
 203  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 204  0
       gridbagconstraints.weightx = 1.0D;
 205   
 //      beanGui.add(jpanel, gridbagconstraints);
 206   
    }
 207   
 
 208   
 
 209   
    /**
 210   
     * Adds a feature to the Property attribute of the GenericCustomizer object
 211   
     *
 212   
     * @param propertyeditor  The feature to be added to the Property attribute
 213   
     * @param attributeInfo   The feature to be added to the Property attribute
 214   
     */
 215  0
    public void addProperty(PropertyEditor propertyeditor, MBeanAttributeInfo attributeInfo)
 216   
    {
 217  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 218  0
       gridbagconstraints.insets = new Insets(3, 3, 3, 3);
 219   
 
 220  0
       try
 221   
       {
 222  0
          if (attributeInfo.isReadable())
 223   
          {
 224  0
             propertyeditor.setValue(object.getAttribute(attributeInfo.getName()));
 225   
          }
 226   
       }
 227   
       catch (Throwable _ex)
 228   
       {
 229   
       }
 230   
 
 231  0
       JLabel jlabel = new JLabel(attributeInfo.getName() + " :", SwingConstants.RIGHT);
 232  0
       jlabel.setToolTipText(attributeInfo.getDescription());
 233   
 
 234  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 235  0
       gridbagconstraints.weightx = 0.0D;
 236  0
       gridbagconstraints.weighty = 1.0D;
 237  0
       gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 238  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 239   
 
 240   
 //      beanGui.add(jlabel, gridbagconstraints);
 241   
 
 242  0
       Object obj1;
 243  0
       if (propertyeditor.supportsCustomEditor())
 244   
       {
 245  0
          obj1 = propertyeditor.getCustomEditor();
 246  0
          if (obj1 instanceof JComponent)
 247   
          {
 248  0
             if (previous != null)
 249   
             {
 250  0
                previous.setNextFocusableComponent(((Component) (obj1)));
 251   
             }
 252  0
             previous = (JComponent) obj1;
 253   
          }
 254   
       }
 255   
       else
 256   
       {
 257  0
          String[] tags = propertyeditor.getTags();
 258  0
          if (tags != null)
 259   
          {
 260  0
             obj1 = new GenericPropertyCustomizer(propertyeditor, tags);
 261  0
             if (previous != null)
 262   
             {
 263  0
                previous.setNextFocusableComponent((Component) (obj1));
 264   
             }
 265  0
             previous = (JComponent) obj1;
 266   
          }
 267   
          else
 268   
          {
 269  0
             if (attributeInfo.isWritable())
 270   
             {
 271  0
                obj1 = new GenericPropertyCustomizer(propertyeditor);
 272  0
                if (previous != null)
 273   
                {
 274  0
                   previous.setNextFocusableComponent((Component) (obj1));
 275   
                }
 276  0
                previous = (JComponent) obj1;
 277   
             }
 278   
             else
 279   
             {
 280  0
                final JLabel lbl = new JLabel(propertyeditor.getAsText());
 281  0
                final PropertyEditor pcEditor = propertyeditor;
 282  0
                obj1 = lbl;
 283  0
                pcEditor.addPropertyChangeListener(
 284   
                   new PropertyChangeListener()
 285   
                   {
 286  0
                      public void propertyChange(PropertyChangeEvent evt)
 287   
                      {
 288  0
                         lbl.setText(pcEditor.getAsText());
 289   
                      }
 290   
                   });
 291   
             }
 292   
          }
 293   
       }
 294   
 
 295  0
       gridbagconstraints.weightx = 1.0D;
 296  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 297  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 298   
 
 299   
 //      beanGui.add(((Component) (obj1)), gridbagconstraints);
 300   
 
 301  0
       if (attributeInfo.isWritable())
 302   
       {
 303  0
          propertyeditor.addPropertyChangeListener(new BeanUpdater(attributeInfo));
 304   
       }
 305   
 
 306  0
       try
 307   
       {
 308  0
          Method method = object.getClass().getMethod("addPropertyChangeListener", new Class[]{java.lang.String.class, java.beans.PropertyChangeListener.class});
 309  0
          method.invoke(object, new Object[]{attributeInfo.getName(), new EditorUpdater(propertyeditor, attributeInfo.getName())});
 310   
       }
 311   
       catch (Exception _ex)
 312   
       {
 313  0
          try
 314   
          {
 315  0
             Method method1 = object.getClass().getMethod("addPropertyChangeListener", new Class[]{java.beans.PropertyChangeListener.class});
 316  0
             method1.invoke(object, new Object[]{new EditorUpdater(propertyeditor, attributeInfo)});
 317   
          }
 318   
          catch (Exception _ex2)
 319   
          {
 320   
          }
 321   
       }
 322   
    }
 323   
 
 324   
 
 325   
    /**
 326   
     * Adds a feature to the UnsupportedProperty attribute of the GenericMBeanCustomizer object
 327   
     *
 328   
     * @param attributeInfo  The feature to be added to the UnsupportedProperty attribute
 329   
     */
 330  0
    public void addUnsupportedProperty(MBeanAttributeInfo attributeInfo)
 331   
    {
 332  0
       System.out.println("In addUnsupportedProperty " + attributeInfo.getType());
 333   
 
 334  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 335  0
       gridbagconstraints.insets = new Insets(3, 3, 3, 3);
 336   
 
 337  0
       JLabel jlabel = new JLabel(attributeInfo.getName() + " :", SwingConstants.RIGHT);
 338  0
       jlabel.setToolTipText(attributeInfo.getDescription());
 339   
 
 340  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 341  0
       gridbagconstraints.weightx = 0.0D;
 342  0
       gridbagconstraints.weighty = 1.0D;
 343  0
       gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 344  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 345   
 
 346   
 //      beanGui.add(jlabel, gridbagconstraints);
 347   
 
 348  0
       JLabel lbl = new JLabel("Unloadabled class " + attributeInfo.getType());
 349   
 
 350  0
       gridbagconstraints.weightx = 1.0D;
 351  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 352   
 
 353   
 //      beanGui.add(lbl, gridbagconstraints);
 354   
    }
 355   
 
 356   
 
 357   
    /**
 358   
     * Sets the Object attribute of the GenericCustomizer object
 359   
     *
 360   
     * @param obj  The new Object value
 361   
     */
 362  0
    public void setObject(Object obj)
 363   
    {
 364  0
       try
 365   
       {
 366  0
          this.p.removeAll();
 367   
 
 368  0
          if (obj == null)
 369   
          {
 370  0
             this.validate();
 371  0
             this.repaint();
 372  0
             return;
 373   
          }
 374   
 
 375  0
          this.object = (MBeanAccessor) obj;
 376  0
          MBeanInfo beaninfo = object.getMBeanInfo();
 377   
 
 378  0
          GridBagConstraints gridbagconstraints = new GridBagConstraints();
 379  0
          gridbagconstraints.insets = new Insets(3, 3, 3, 3);
 380  0
          gridbagconstraints.anchor = GridBagConstraints.NORTH;
 381  0
          gridbagconstraints.weightx = 1.0D;
 382  0
          gridbagconstraints.weighty = 0.0D;
 383  0
          gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 384  0
          gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 385   
 
 386  0
          this.buildInfosPanel(beaninfo, object);
 387  0
          this.buildConstructorsPanel(beaninfo);
 388  0
          this.buildNotificationsPanel(beaninfo);
 389  0
          this.buildOperationsPanel(beaninfo);
 390   
 
 391  0
          this.p.add(mbeanInfo, gridbagconstraints);
 392  0
          if (mbeanConstructors != null)
 393   
          {
 394  0
             this.p.add(mbeanConstructors, gridbagconstraints);
 395   
          }
 396  0
          if (mbeanNotifications != null)
 397   
          {
 398  0
             this.p.add(mbeanNotifications, gridbagconstraints);
 399   
          }
 400  0
          if (mbeanOperations != null)
 401   
          {
 402  0
             this.p.add(mbeanOperations, gridbagconstraints);
 403   
          }
 404   
 
 405   
          // Add a spacer
 406  0
          gridbagconstraints.weighty = 1.0D;
 407  0
          gridbagconstraints.fill = GridBagConstraints.BOTH;
 408  0
          this.p.add(new JLabel(" "), gridbagconstraints);
 409   
 
 410  0
          validate();
 411  0
          repaint();
 412   
       }
 413   
       catch (Exception exception)
 414   
       {
 415  0
          System.out.println("Exception occurred");
 416  0
          exception.printStackTrace();
 417   
       }
 418   
    }
 419   
 
 420   
 
 421   
    /**
 422   
     * Description of the Method
 423   
     *
 424   
     * @param s     Description of Parameter
 425   
     * @param obj   Description of Parameter
 426   
     * @param obj1  Description of Parameter
 427   
     */
 428  0
    protected void updated(String s, Object obj, Object obj1)
 429   
    {
 430  0
       firePropertyChange(s, obj, obj1);
 431   
    }
 432   
 
 433   
 
 434   
    /**
 435   
     * Description of the Method
 436   
     *
 437   
     * @param info  Description of the Parameter
 438   
     */
 439  0
    private void buildConstructorsPanel(MBeanInfo info)
 440   
    {
 441  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 442  0
       gridbagconstraints.insets = new Insets(2, 2, 2, 2);
 443  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 444  0
       gridbagconstraints.weightx = 1.0D;
 445  0
       gridbagconstraints.weighty = 1.0D;
 446  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 447  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 448   
 
 449  0
       MBeanConstructorInfo[] infos = info.getConstructors();
 450  0
       if (infos.length == 0)
 451   
       {
 452  0
          return;
 453   
       }
 454  0
       this.mbeanConstructors = new JPanel(new GridBagLayout());
 455  0
       this.mbeanConstructors.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Constructors"));
 456  0
       for (int i = 0; i < infos.length; i++)
 457   
       {
 458  0
          StringBuffer display = new StringBuffer();
 459  0
          display.append(infos[i].getName());
 460  0
          display.append("(");
 461  0
          MBeanParameterInfo[] parameters = infos[i].getSignature();
 462  0
          if (parameters.length > 0)
 463   
          {
 464  0
             for (int j = 0; j < parameters.length; j++)
 465   
             {
 466  0
                if (j > 0)
 467   
                {
 468  0
                   display.append(", ");
 469   
                }
 470  0
                display.append(ClassTools.classDisplay(parameters[j].getType()));
 471   
             }
 472   
          }
 473  0
          display.append(")");
 474   
 
 475  0
          JLabel label = new JLabel(display.toString(), SwingConstants.LEFT);
 476  0
          label.setToolTipText(infos[i].getDescription());
 477  0
          this.mbeanConstructors.add(label, gridbagconstraints);
 478   
       }
 479   
    }
 480   
 
 481   
 
 482   
    /**
 483   
     * Description of the Method
 484   
     *
 485   
     * @param info    Description of the Parameter
 486   
     * @param object  Description of the Parameter
 487   
     */
 488  0
    private void buildInfosPanel(MBeanInfo info, MBeanAccessor object)
 489   
    {
 490  0
       JLabel label = null;
 491  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 492  0
       gridbagconstraints.insets = new Insets(2, 2, 2, 2);
 493  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 494  0
       gridbagconstraints.weightx = 0.0D;
 495  0
       gridbagconstraints.weighty = 1.0D;
 496  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 497   
 
 498  0
       this.mbeanInfo = new JPanel(new GridBagLayout());
 499  0
       this.mbeanInfo.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), object.getCanonicalName()));
 500   
 
 501  0
       gridbagconstraints.weightx = 0.0D;
 502  0
       gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 503  0
       label = new JLabel("ClassName : ", SwingConstants.RIGHT);
 504  0
       label.setToolTipText("Class Name of the MBean");
 505  0
       label.setForeground(AwtToolkit.DARK_BLUE);
 506  0
       this.mbeanInfo.add(label, gridbagconstraints);
 507   
 
 508  0
       gridbagconstraints.weightx = 1.0D;
 509  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 510  0
       label = new JLabel(info.getClassName(), SwingConstants.LEFT);
 511  0
       this.mbeanInfo.add(label, gridbagconstraints);
 512   
 
 513  0
       gridbagconstraints.weightx = 0.0D;
 514  0
       gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 515  0
       label = new JLabel("Description : ", SwingConstants.RIGHT);
 516  0
       label.setToolTipText("Description of the MBean");
 517  0
       label.setForeground(AwtToolkit.DARK_BLUE);
 518  0
       this.mbeanInfo.add(label, gridbagconstraints);
 519   
 
 520  0
       gridbagconstraints.weightx = 1.0D;
 521  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 522  0
       label = new JLabel(info.getDescription(), SwingConstants.LEFT);
 523  0
       this.mbeanInfo.add(label, gridbagconstraints);
 524   
    }
 525   
 
 526   
 
 527   
    /**
 528   
     * Description of the Method
 529   
     *
 530   
     * @param info  Description of the Parameter
 531   
     */
 532  0
    private void buildNotificationsPanel(MBeanInfo info)
 533   
    {
 534  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 535  0
       gridbagconstraints.insets = new Insets(2, 2, 2, 2);
 536  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 537  0
       gridbagconstraints.weightx = 0.0D;
 538  0
       gridbagconstraints.weighty = 1.0D;
 539  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 540   
 
 541  0
       MBeanNotificationInfo[] infos = info.getNotifications();
 542  0
       if (infos.length == 0)
 543   
       {
 544  0
          return;
 545   
       }
 546  0
       this.mbeanNotifications = new JPanel(new GridBagLayout());
 547  0
       this.mbeanNotifications.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Notifications"));
 548  0
       for (int i = 0; i < infos.length; i++)
 549   
       {
 550  0
          gridbagconstraints.weightx = 0.0D;
 551  0
          gridbagconstraints.gridheight = infos[i].getNotifTypes().length;
 552  0
          gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 553  0
          JLabel label = new JLabel(infos[i].getName(), SwingConstants.RIGHT);
 554  0
          label.setToolTipText(infos[i].getDescription());
 555  0
          label.setForeground(AwtToolkit.DARK_BLUE);
 556  0
          this.mbeanNotifications.add(label, gridbagconstraints);
 557   
 
 558  0
          gridbagconstraints.weightx = 1.0D;
 559  0
          gridbagconstraints.gridheight = 1;
 560  0
          gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 561  0
          for (int j = 0; j < infos[i].getNotifTypes().length; j++)
 562   
          {
 563  0
             label = new JLabel(infos[i].getNotifTypes()[j], SwingConstants.LEFT);
 564  0
             this.mbeanNotifications.add(label, gridbagconstraints);
 565   
          }
 566   
       }
 567  0
       if (infos.length > 0)
 568   
       {
 569  0
          JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 5, 5));
 570  0
          JButton button1 = new JButton("Register");
 571  0
          JButton button2 = new JButton("Unregister");
 572  0
          buttonPanel.add(button1);
 573  0
          buttonPanel.add(button2);
 574  0
          this.mbeanNotifications.add(buttonPanel, gridbagconstraints);
 575   
       }
 576   
    }
 577   
 
 578   
 
 579   
    /**
 580   
     * Description of the Method
 581   
     *
 582   
     * @param info  Description of the Parameter
 583   
     */
 584  0
    private void buildOperationsPanel(MBeanInfo info)
 585   
    {
 586  0
       GridBagConstraints gridbagconstraints = new GridBagConstraints();
 587  0
       gridbagconstraints.insets = new Insets(2, 2, 2, 2);
 588  0
       gridbagconstraints.anchor = GridBagConstraints.NORTH;
 589  0
       gridbagconstraints.weightx = 1.0D;
 590  0
       gridbagconstraints.weighty = 1.0D;
 591  0
       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
 592  0
       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 593   
 
 594  0
       MBeanOperationInfo[] infos = info.getOperations();
 595  0
       if (infos.length == 0)
 596   
       {
 597  0
          return;
 598   
       }
 599  0
       this.mbeanOperations = new JPanel(new GridBagLayout());
 600  0
       this.mbeanOperations.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Operations"));
 601  0
       for (int i = 0; i < infos.length; i++)
 602   
       {
 603  0
          gridbagconstraints.weightx = 0.0D;
 604  0
          gridbagconstraints.gridwidth = 1;
 605  0
          String returnType = ClassTools.classDisplay(infos[i].getReturnType());
 606  0
          JLabel label = new JLabel(returnType, SwingConstants.RIGHT);
 607  0
          label.setForeground(AwtToolkit.DARK_BLUE);
 608  0
          this.mbeanOperations.add(label, gridbagconstraints);
 609   
 
 610  0
          StringBuffer display = new StringBuffer();
 611  0
          display.append(infos[i].getName());
 612  0
          display.append("(");
 613  0
          MBeanParameterInfo[] parameters = infos[i].getSignature();
 614  0
          if (parameters.length > 0)
 615   
          {
 616  0
             for (int j = 0; j < parameters.length; j++)
 617   
             {
 618  0
                if (j > 0)
 619   
                {
 620  0
                   display.append(", ");
 621   
                }
 622  0
                display.append(ClassTools.classDisplay(parameters[j].getType()));
 623   
             }
 624   
          }
 625  0
          display.append(")");
 626   
 
 627  0
          gridbagconstraints.weightx = 1.0D;
 628  0
          gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
 629  0
          label = new JLabel(display.toString(), SwingConstants.LEFT);
 630  0
          label.setToolTipText(infos[i].getDescription());
 631  0
          this.mbeanOperations.add(label, gridbagconstraints);
 632   
 
 633  0
          gridbagconstraints.weightx = 0.0D;
 634  0
          gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
 635  0
          JButton button = new JButton("Execute");
 636  0
          this.mbeanOperations.add(button, gridbagconstraints);
 637   
       }
 638   
    }
 639   
 
 640   
 
 641   
    /**
 642   
     * Description of the Class
 643   
     *
 644   
     * @author    laurent
 645   
     * @version   $Revision: 1.8 $
 646   
     */
 647   
    class BeanUpdater implements PropertyChangeListener
 648   
    {
 649   
       /** Description of the Field */
 650   
       MBeanAttributeInfo info;
 651   
 
 652   
 
 653   
       /**
 654   
        * Constructor for the BeanUpdater object
 655   
        *
 656   
        * @param info  Description of Parameter
 657   
        */
 658  0
       public BeanUpdater(MBeanAttributeInfo info)
 659   
       {
 660  0
          this.info = info;
 661   
       }
 662   
 
 663   
 
 664   
       /**
 665   
        * Description of the Method
 666   
        *
 667   
        * @param event  Description of Parameter
 668   
        */
 669  0
       public void propertyChange(PropertyChangeEvent event)
 670   
       {
 671  0
          Object old = null;
 672  0
          try
 673   
          {
 674  0
             if (info.isReadable())
 675   
             {
 676  0
                old = object.getAttribute(info.getName());
 677   
             }
 678  0
             Object obj = ((PropertyEditor) event.getSource()).getValue();
 679   
 
 680  0
             object.setAttribute(new Attribute(info.getName(), obj));
 681  0
             updated(info.getName(), old, obj);
 682   
          }
 683   
          /*
 684   
           * AS Adapt to the JMXConnector exceptions
 685   
           * catch( InvocationTargetException e ) {
 686   
           * if( e.getTargetException() instanceof PropertyVetoException ) {
 687   
           * JOptionPane.showMessageDialog(
 688   
           * (Frame) SwingUtilities.windowForComponent( GenericMBeanCustomizer.this ),
 689   
           * "Could not change value:" + e.getTargetException().getMessage(),
 690   
           * "Error",
 691   
           * JOptionPane.ERROR_MESSAGE
 692   
           * );
 693   
           * }
 694   
           * }
 695   
           */
 696   
          catch (Exception e)
 697   
          {
 698  0
             System.err.println(e);
 699   
          }
 700   
       }
 701   
    }
 702   
 
 703   
 
 704   
    /**
 705   
     * This class makes sure that the customizer is updated with the object changes
 706   
     *
 707   
     * @author    andreass
 708   
     * @version   $Revision: 1.8 $
 709   
     */
 710   
    class EditorUpdater implements PropertyChangeListener
 711   
    {
 712   
       /** Description of the Field */
 713   
       PropertyEditor editor;
 714   
       /** Description of the Field */
 715   
       MBeanAttributeInfo info;
 716   
       /** Description of the Field */
 717   
       String name;
 718   
 
 719   
 
 720   
       /**
 721   
        * Constructor for the EditorUpdater object
 722   
        *
 723   
        * @param editor  Description of Parameter
 724   
        * @param info    Description of Parameter
 725   
        */
 726  0
       public EditorUpdater(PropertyEditor editor, MBeanAttributeInfo info)
 727   
       {
 728  0
          this.editor = editor;
 729  0
          this.info = info;
 730  0
          this.name = info.getName();
 731   
       }
 732   
 
 733   
 
 734   
       /**
 735   
        * Constructor for the EditorUpdater object
 736   
        *
 737   
        * @param editor  Description of Parameter
 738   
        * @param name    Description of Parameter
 739   
        */
 740  0
       public EditorUpdater(PropertyEditor editor, String name)
 741   
       {
 742  0
          this.editor = editor;
 743  0
          this.name = name;
 744   
       }
 745   
 
 746   
 
 747   
       /**
 748   
        * Description of the Method
 749   
        *
 750   
        * @param event  Description of Parameter
 751   
        */
 752  0
       public void propertyChange(PropertyChangeEvent event)
 753   
       {
 754  0
          System.out.println("$$$ Attribute has been changed " + event);
 755  0
          System.out.println("$$$ Attribute has been changed " + name + "/" + event.getPropertyName());
 756   
 
 757  0
          if (name != null && event.getPropertyName() != null)
 758   
          {
 759  0
             if (!event.getPropertyName().equals(name))
 760   
             {
 761  0
                return;
 762   
             }
 763   
          }
 764  0
          if (event.getPropertyName() != null)
 765   
          {
 766  0
             if (!editor.getValue().equals(event.getNewValue()))
 767   
             {
 768  0
                editor.setValue(event.getNewValue());
 769   
             }
 770   
          }
 771   
          else
 772   
          {
 773  0
             try
 774   
             {
 775  0
                Object value = object.getAttribute(event.getSource() + "");
 776  0
                if (editor != null && !editor.equals(editor.getValue()))
 777   
                {
 778  0
                   editor.setValue(value);
 779   
                }
 780   
             }
 781   
             catch (Exception e)
 782   
             {
 783   
             }
 784   
          }
 785   
       }
 786   
    }
 787   
 
 788   
 
 789   
    /**
 790   
     * Description of the Class
 791   
     *
 792   
     * @author    letiembl
 793   
     * @version   $Revision: 1.8 $
 794   
     */
 795   
    class MethodInvoker implements ActionListener
 796   
    {
 797   
       /** Description of the Field */
 798   
       MBeanOperationInfo info;
 799   
 
 800   
 
 801   
       /**
 802   
        * Constructor for the MethodInvoker object
 803   
        *
 804   
        * @param info  Description of Parameter
 805   
        */
 806  0
       MethodInvoker(MBeanOperationInfo info)
 807   
       {
 808  0
          this.info = info;
 809   
       }
 810   
 
 811   
 
 812   
       /**
 813   
        * Description of the Method
 814   
        *
 815   
        * @param e  Description of Parameter
 816   
        */
 817  0
       public void actionPerformed(ActionEvent e)
 818   
       {
 819  0
          Container frame = SwingUtilities.getAncestorOfClass(Frame.class, p);
 820   
 
 821   
          // No parameters->invoke right away
 822  0
          MBeanParameterInfo[] parameters = info.getSignature();
 823  0
          if (parameters.length == 0)
 824   
          {
 825  0
             try
 826   
             {
 827  0
                Object obj1 = object.invoke(info.getName(), new Object[]{}, new String[]{});
 828   
 
 829  0
                if (obj1 != null)
 830   
                {
 831  0
                   JOptionPane.showMessageDialog(frame, obj1.toString(), "Result", 1);
 832   
                }
 833   
             }
 834   
             catch (Exception ex)
 835   
             {
 836  0
                System.err.println(ex);
 837  0
                JOptionPane.showMessageDialog(frame, "An exception occured. Check log for details", "Error", JOptionPane.ERROR_MESSAGE);
 838   
             }
 839   
          }
 840   
          else
 841   
          {
 842   
 
 843  0
             new GenericMBeanMethodDialog(
 844   
                object,
 845   
                object.getObjectName(),
 846   
                info,
 847   
                (Frame) frame
 848   
                );
 849   
 
 850   
          }
 851   
       }
 852   
    }
 853   
 
 854   
 
 855   
    /**
 856   
     * Description of the Class
 857   
     *
 858   
     * @author    laurent
 859   
     * @version   $Revision: 1.8 $
 860   
     */
 861   
    class UnregisterInvoker implements ActionListener
 862   
    {
 863   
       /**
 864   
        * Description of the Method
 865   
        *
 866   
        * @param e  Description of the Parameter
 867   
        */
 868  0
       public void actionPerformed(ActionEvent e)
 869   
       {
 870  0
          Container frame = SwingUtilities.getAncestorOfClass(Frame.class, p);
 871   
 
 872  0
          try
 873   
          {
 874  0
             object.unregisterMBean();
 875   
          }
 876   
          catch (Exception ex)
 877   
          {
 878  0
             System.err.println(ex);
 879  0
             JOptionPane.showMessageDialog(frame, "An exception occured. Check log for details", "Error", JOptionPane.ERROR_MESSAGE);
 880   
          }
 881   
       }
 882   
    }
 883   
 }
 884   
 
 885