KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > management > browser > ui > ManagedObjectDetailViewer


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.management.browser.ui;
8
9 import java.awt.Color JavaDoc;
10 import java.awt.Component JavaDoc;
11 import java.awt.GridBagConstraints JavaDoc;
12 import java.awt.GridBagLayout JavaDoc;
13 import java.awt.GridLayout JavaDoc;
14 import java.awt.Insets JavaDoc;
15 import java.awt.event.ActionEvent JavaDoc;
16 import java.awt.event.ActionListener JavaDoc;
17 import java.beans.PropertyChangeEvent JavaDoc;
18 import java.beans.PropertyChangeListener JavaDoc;
19 import java.beans.PropertyEditor JavaDoc;
20 import java.util.ArrayList JavaDoc;
21 import java.util.Arrays JavaDoc;
22 import java.util.Comparator JavaDoc;
23 import java.util.Hashtable JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26
27 import javax.management.Attribute JavaDoc;
28 import javax.management.MBeanAttributeInfo JavaDoc;
29 import javax.management.MBeanInfo JavaDoc;
30 import javax.management.MBeanOperationInfo JavaDoc;
31 import javax.management.MBeanParameterInfo JavaDoc;
32 import javax.swing.BorderFactory JavaDoc;
33 import javax.swing.JButton JavaDoc;
34 import javax.swing.JComponent JavaDoc;
35 import javax.swing.JLabel JavaDoc;
36 import javax.swing.JPanel JavaDoc;
37 import javax.swing.JTextArea JavaDoc;
38 import javax.swing.SwingConstants JavaDoc;
39
40 import org.apache.log4j.Logger;
41 import org.ejtools.adwt.AwtToolkit;
42 import org.ejtools.adwt.editor.ArrayEditor;
43 import org.ejtools.adwt.jmx.MBeanMethodDialog;
44 import org.ejtools.beans.CustomPropertyEditorManager;
45 import org.ejtools.jmx.MBeanSorter;
46 import org.ejtools.management.browser.model.ManagedObject;
47 import org.ejtools.util.ClassTools;
48
49 import com.dreambean.awt.GenericPropertyCustomizer;
50
51 /**
52  * Description of the Class
53  *
54  * @author letiemble
55  * @version $Revision: 1.7 $
56  */

57 public class ManagedObjectDetailViewer extends ManagedObjectViewer
58 {
59    /** Description of the Field */
60    private Hashtable JavaDoc invocationDialogs = null;
61    /** Description of the Field */
62    private JPanel JavaDoc mbeanAttributes = null;
63    /** Description of the Field */
64    private JPanel JavaDoc mbeanOperations = null;
65    /** Description of the Field */
66    private JPanel JavaDoc mbeanSummary = null;
67    /** Description of the Field */
68    private JComponent JavaDoc previous = null;
69    /** Description of the Field */
70    private ArrayList JavaDoc updaters;
71    /** Description of the Field */
72    private static Logger logger = Logger.getLogger(ManagedObjectDetailViewer.class);
73
74
75    /**Constructor for the ManagedObjectDetailViewer object */
76    public ManagedObjectDetailViewer()
77    {
78       super();
79    }
80
81
82    /**
83     *Constructor for the ManagedObjectDetailViewer object
84     *
85     * @param bean Description of the Parameter
86     */

87    public ManagedObjectDetailViewer(Object JavaDoc bean)
88    {
89       super(bean);
90    }
91
92
93    /**
94     * @param infos Description of the Parameter
95     * @return Description of the Return Value
96     */

97    public MBeanAttributeInfo JavaDoc[] filter(MBeanAttributeInfo JavaDoc[] infos)
98    {
99       ArrayList JavaDoc filteredInfos = new ArrayList JavaDoc();
100       ArrayList JavaDoc excludes = new ArrayList JavaDoc();
101       excludes.add(MO_ATTRIBUTE_EVENTPROVIDER);
102       excludes.add(MO_ATTRIBUTE_EVENTTYPES);
103       excludes.add(MO_ATTRIBUTE_STATEMANAGEABLE);
104       excludes.add(MO_ATTRIBUTE_STATISTICSPROVIDER);
105       excludes.add(MO_ATTRIBUTE_STATS);
106
107       for (int i = 0; i < infos.length; i++)
108       {
109          String JavaDoc name = infos[i].getName();
110          if (!excludes.contains(name.toLowerCase()))
111          {
112             filteredInfos.add(infos[i]);
113          }
114       }
115
116       MBeanAttributeInfo JavaDoc[] result = (MBeanAttributeInfo JavaDoc[]) filteredInfos.toArray(new MBeanAttributeInfo JavaDoc[0]);
117       Arrays.sort(result,
118          new Comparator JavaDoc()
119          {
120             public int compare(Object JavaDoc o1, Object JavaDoc o2)
121             {
122                MBeanAttributeInfo JavaDoc info1 = (MBeanAttributeInfo JavaDoc) o1;
123                MBeanAttributeInfo JavaDoc info2 = (MBeanAttributeInfo JavaDoc) o2;
124                return info1.getName().compareTo(info2.getName());
125             }
126
127
128             public boolean equals(Object JavaDoc obj)
129             {
130                // Should never be used
131
return false;
132             }
133          });
134
135       return result;
136    }
137
138
139    /**
140     * Sets the object attribute of the ManagedObjectDetailViewer object
141     *
142     * @param bean The new object value
143     */

144    public void setObject(Object JavaDoc bean)
145    {
146       try
147       {
148          this.panel.removeAll();
149
150          if (bean == null)
151          {
152             this.validate();
153             this.repaint();
154             return;
155          }
156
157          this.object = (ManagedObject) bean;
158          MBeanInfo JavaDoc beaninfo = this.object.getMBeanInfo();
159
160          GridBagConstraints JavaDoc gridbagconstraints = new GridBagConstraints JavaDoc();
161          gridbagconstraints.insets = new Insets JavaDoc(3, 3, 3, 3);
162          gridbagconstraints.anchor = GridBagConstraints.NORTH;
163          gridbagconstraints.weightx = 1.0D;
164          gridbagconstraints.weighty = 0.0D;
165          gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
166          gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
167
168          this.buildSummaryPanel(beaninfo);
169          this.panel.add(this.mbeanSummary, gridbagconstraints);
170
171          this.buildAttributesPanel(beaninfo);
172          this.panel.add(this.mbeanAttributes, gridbagconstraints);
173
174          gridbagconstraints.weighty = 1.0D;
175          this.buildOperationsPanel(beaninfo);
176          this.panel.add(this.mbeanOperations, gridbagconstraints);
177
178          this.validate();
179          this.repaint();
180       }
181       catch (Exception JavaDoc e)
182       {
183          logger.error("Error while setting object" + e);
184       }
185    }
186
187
188    /**
189     * Description of the Method
190     *
191     * @param text Description of the Parameter
192     * @param toolTip Description of the Parameter
193     * @param value Description of the Parameter
194     */

195    protected void add(String JavaDoc text, String JavaDoc toolTip, String JavaDoc value)
196    {
197       JLabel JavaDoc label;
198
199       GridBagConstraints JavaDoc gridbagconstraints = new GridBagConstraints JavaDoc();
200       gridbagconstraints.insets = new Insets JavaDoc(0, 0, 0, 0);
201       gridbagconstraints.anchor = GridBagConstraints.NORTH;
202       gridbagconstraints.weightx = 0.0D;
203       gridbagconstraints.weighty = 1.0D;
204       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
205
206       gridbagconstraints.weightx = 0.0D;
207       gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
208       label = new JLabel JavaDoc(text + " : ", SwingConstants.RIGHT);
209       label.setToolTipText(toolTip);
210       label.setForeground(AwtToolkit.DARK_BLUE);
211       this.mbeanSummary.add(label, gridbagconstraints);
212
213       gridbagconstraints.weightx = 1.0D;
214       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
215       label = new JLabel JavaDoc(value, SwingConstants.LEFT);
216       label.setForeground(Color.black);
217       this.mbeanSummary.add(label, gridbagconstraints);
218
219    }
220
221
222    /**
223     * Adds a feature to the Property attribute of the GenericCustomizer object
224     *
225     * @param propertyeditor The feature to be added to the Property attribute
226     * @param attributeInfo The feature to be added to the Property attribute
227     */

228    protected void addProperty(PropertyEditor JavaDoc propertyeditor, MBeanAttributeInfo JavaDoc attributeInfo)
229    {
230       GridBagConstraints JavaDoc gridbagconstraints = new GridBagConstraints JavaDoc();
231       gridbagconstraints.insets = new Insets JavaDoc(2, 2, 2, 2);
232
233       try
234       {
235          if (attributeInfo.isReadable())
236          {
237             propertyeditor.setValue(object.getAttribute(attributeInfo.getName()));
238          }
239       }
240       catch (Throwable JavaDoc throwable)
241       {
242          logger.warn("Can't read the property from MBean", throwable);
243       }
244
245       // Create the attribute label
246
JLabel JavaDoc label = new JLabel JavaDoc(attributeInfo.getName() + " : ", SwingConstants.RIGHT);
247       label.setToolTipText(attributeInfo.getDescription());
248       label.setForeground(AwtToolkit.DARK_BLUE);
249
250       Object JavaDoc obj1;
251       if (propertyeditor.supportsCustomEditor())
252       {
253          obj1 = propertyeditor.getCustomEditor();
254          if (obj1 instanceof JComponent JavaDoc)
255          {
256             if (previous != null)
257             {
258                previous.setNextFocusableComponent(((Component JavaDoc) (obj1)));
259             }
260             previous = (JComponent JavaDoc) obj1;
261          }
262       }
263       else
264       {
265          String JavaDoc[] tags = propertyeditor.getTags();
266          if (tags != null)
267          {
268             obj1 = new GenericPropertyCustomizer(propertyeditor, tags);
269             if (previous != null)
270             {
271                previous.setNextFocusableComponent((Component JavaDoc) (obj1));
272             }
273             previous = (JComponent JavaDoc) obj1;
274          }
275          else
276          {
277             if (attributeInfo.isWritable())
278             {
279                obj1 = new GenericPropertyCustomizer(propertyeditor);
280                if (previous != null)
281                {
282                   previous.setNextFocusableComponent((Component JavaDoc) (obj1));
283                }
284                previous = (JComponent JavaDoc) obj1;
285             }
286             else
287             {
288                String JavaDoc content = "" + propertyeditor.getAsText();
289                //
290
// ToDo : Put in constant
291
//
292
if (content.indexOf('\n') >= 0)
293                {
294                   final JTextArea JavaDoc area = new JTextArea JavaDoc(propertyeditor.getAsText());
295                   area.setEditable(false);
296                   final PropertyEditor JavaDoc pcEditor = propertyeditor;
297                   obj1 = area;
298                   pcEditor.addPropertyChangeListener(
299                      new PropertyChangeListener JavaDoc()
300                      {
301                         public void propertyChange(PropertyChangeEvent JavaDoc evt)
302                         {
303                            area.setText(pcEditor.getAsText());
304                         }
305                      });
306                }
307                else
308                {
309                   final JLabel JavaDoc lbl = new JLabel JavaDoc(propertyeditor.getAsText());
310                   final PropertyEditor JavaDoc pcEditor = propertyeditor;
311                   obj1 = lbl;
312                   pcEditor.addPropertyChangeListener(
313                      new PropertyChangeListener JavaDoc()
314                      {
315                         public void propertyChange(PropertyChangeEvent JavaDoc evt)
316                         {
317                            lbl.setText(pcEditor.getAsText());
318                         }
319                      });
320                }
321             }
322          }
323       }
324
325       gridbagconstraints.anchor = GridBagConstraints.NORTH;
326       gridbagconstraints.weighty = 1.0D;
327       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
328
329       gridbagconstraints.weightx = 0.0D;
330       gridbagconstraints.gridwidth = 1;
331       this.mbeanAttributes.add(label, gridbagconstraints);
332
333       gridbagconstraints.weightx = 1.0D;
334       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
335       this.mbeanAttributes.add(((Component JavaDoc) (obj1)), gridbagconstraints);
336
337       // Allow attribute to be update
338
Updater updater = new Updater(propertyeditor, attributeInfo);
339       this.getUpdaters().add(updater);
340    }
341
342
343    /**
344     * Adds a feature to the UnsupportedProperty attribute of the GenericMBeanCustomizer object
345     *
346     * @param attributeInfo The feature to be added to the UnsupportedProperty attribute
347     */

348    protected void addUnsupportedProperty(MBeanAttributeInfo JavaDoc attributeInfo)
349    {
350       GridBagConstraints JavaDoc gridbagconstraints = new GridBagConstraints JavaDoc();
351       gridbagconstraints.insets = new Insets JavaDoc(2, 2, 2, 2);
352
353       JLabel JavaDoc jlabel = new JLabel JavaDoc(attributeInfo.getName() + " :", SwingConstants.RIGHT);
354       jlabel.setToolTipText(attributeInfo.getDescription());
355       jlabel.setForeground(Color.black);
356
357       gridbagconstraints.anchor = GridBagConstraints.NORTH;
358       gridbagconstraints.weightx = 0.0D;
359       gridbagconstraints.weighty = 1.0D;
360       gridbagconstraints.gridwidth = 1;
361       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
362
363       this.mbeanAttributes.add(jlabel, gridbagconstraints);
364
365       JLabel JavaDoc lbl = new JLabel JavaDoc(resources.getString("customizer.tab.detail.text.unloadable.class") + " " + ClassTools.classDisplay(attributeInfo.getType()));
366       lbl.setForeground(AwtToolkit.DARK_RED);
367
368       gridbagconstraints.weightx = 1.0D;
369       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
370
371       this.mbeanAttributes.add(lbl, gridbagconstraints);
372    }
373
374
375    /**
376     * Description of the Method
377     *
378     * @param info Description of the Parameter
379     */

380    protected void buildAttributesPanel(MBeanInfo JavaDoc info)
381    {
382       GridBagConstraints JavaDoc gridbagconstraints = new GridBagConstraints JavaDoc();
383       gridbagconstraints.insets = new Insets JavaDoc(0, 0, 0, 0);
384       gridbagconstraints.anchor = GridBagConstraints.NORTH;
385       gridbagconstraints.weightx = 0.0D;
386       gridbagconstraints.weighty = 1.0D;
387       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
388
389       this.mbeanAttributes = new JPanel JavaDoc(new GridBagLayout JavaDoc());
390
391       MBeanAttributeInfo JavaDoc[] infosArray = this.filter(info.getAttributes());
392       if (infosArray.length == 0)
393       {
394         return;
395       }
396       List JavaDoc infos = Arrays.asList(infosArray);
397       MBeanSorter.sortByName(infos);
398       
399       this.mbeanAttributes.setBorder(BorderFactory.createTitledBorder(resources.getString("customizer.tab.detail.text.attributes")));
400       for (int i = 0; i < infos.size(); i++)
401       {
402         MBeanAttributeInfo JavaDoc attributeInfo = (MBeanAttributeInfo JavaDoc) infos.get(i);
403         PropertyEditor JavaDoc propertyeditor = null;
404          Class JavaDoc c = ClassTools.getClass(attributeInfo.getType());
405
406          if (c == null)
407          {
408             this.addUnsupportedProperty(attributeInfo);
409          }
410          else
411          {
412             if (c.isArray())
413             {
414                Class JavaDoc componentType = c.getComponentType();
415                propertyeditor = new ArrayEditor(componentType);
416                this.addProperty(propertyeditor, attributeInfo);
417             }
418             else
419             {
420                propertyeditor = CustomPropertyEditorManager.findEditor(c);
421                if (propertyeditor == null)
422                {
423                   propertyeditor = CustomPropertyEditorManager.findEditor(String JavaDoc.class);
424                }
425                this.addProperty(propertyeditor, attributeInfo);
426             }
427             gridbagconstraints.weighty = 1.0D;
428          }
429       }
430
431       gridbagconstraints.weightx = 1.0D;
432       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
433
434       JPanel JavaDoc buttonPanel = new JPanel JavaDoc(new GridLayout JavaDoc(1, 2, 1, 1));
435       JButton JavaDoc button1 = new JButton JavaDoc(resources.getString("customizer.tab.detail.button.refresh"));
436       button1.addActionListener(
437          new ActionListener JavaDoc()
438          {
439             public void actionPerformed(ActionEvent JavaDoc e)
440             {
441                try
442                {
443                   Iterator JavaDoc it = getUpdaters().iterator();
444                   while (it.hasNext())
445                   {
446                      Updater updater = (Updater) it.next();
447                      updater.updateFromBean();
448                   }
449                }
450                catch (Exception JavaDoc ex)
451                {
452                   logger.error("Error while refreshing" + ex);
453                }
454             }
455          }
456          );
457       JButton JavaDoc button2 = new JButton JavaDoc(resources.getString("customizer.tab.detail.button.update"));
458       button2.addActionListener(
459          new ActionListener JavaDoc()
460          {
461             public void actionPerformed(ActionEvent JavaDoc e)
462             {
463                try
464                {
465                   Iterator JavaDoc it = updaters.iterator();
466                   while (it.hasNext())
467                   {
468                      Updater updater = (Updater) it.next();
469                      updater.updateFromEditor();
470                      updater.updateFromBean();
471                   }
472                }
473                catch (Exception JavaDoc ex)
474                {
475                   logger.error("Error while updating" + ex);
476                }
477             }
478          }
479          );
480       buttonPanel.add(button1);
481       buttonPanel.add(button2);
482       this.mbeanAttributes.add(buttonPanel, gridbagconstraints);
483    }
484
485
486    /**
487     * Description of the Method
488     *
489     * @param info Description of the Parameter
490     */

491    protected void buildOperationsPanel(MBeanInfo JavaDoc info)
492    {
493       GridBagConstraints JavaDoc gridbagconstraints = new GridBagConstraints JavaDoc();
494       gridbagconstraints.insets = new Insets JavaDoc(0, 0, 0, 0);
495       gridbagconstraints.anchor = GridBagConstraints.NORTH;
496       gridbagconstraints.weightx = 1.0D;
497       gridbagconstraints.weighty = 1.0D;
498       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
499       gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
500
501       this.mbeanOperations = new JPanel JavaDoc(new GridBagLayout JavaDoc());
502
503       MBeanOperationInfo JavaDoc[] infosArray = info.getOperations();
504       if (infosArray.length == 0)
505       {
506         return;
507       }
508       List JavaDoc infos = Arrays.asList(infosArray);
509       MBeanSorter.sortByName(infos);
510
511       this.mbeanOperations.setBorder(BorderFactory.createTitledBorder(resources.getString("customizer.tab.detail.text.operations")));
512       for (int i = 0; i < infos.size(); i++)
513       {
514         MBeanOperationInfo JavaDoc operationInfo = (MBeanOperationInfo JavaDoc) infos.get(i);
515         
516          gridbagconstraints.weightx = 0.0D;
517          gridbagconstraints.gridwidth = 1;
518          String JavaDoc returnType = ClassTools.classDisplay(operationInfo.getReturnType() + " ");
519          JLabel JavaDoc label = new JLabel JavaDoc(returnType, SwingConstants.RIGHT);
520          label.setForeground(AwtToolkit.DARK_BLUE);
521          this.mbeanOperations.add(label, gridbagconstraints);
522
523          StringBuffer JavaDoc display = new StringBuffer JavaDoc();
524          display.append(operationInfo.getName());
525          display.append("(");
526          MBeanParameterInfo JavaDoc[] parameters = operationInfo.getSignature();
527          if (parameters.length > 0)
528          {
529             for (int j = 0; j < parameters.length; j++)
530             {
531                if (j > 0)
532                {
533                   display.append(", ");
534                }
535                display.append(ClassTools.classDisplay(parameters[j].getType()));
536             }
537          }
538          display.append(")");
539
540          gridbagconstraints.weightx = 1.0D;
541          gridbagconstraints.gridwidth = GridBagConstraints.RELATIVE;
542          label = new JLabel JavaDoc(display.toString(), SwingConstants.LEFT);
543          label.setToolTipText(operationInfo.getDescription());
544          label.setForeground(Color.black);
545          this.mbeanOperations.add(label, gridbagconstraints);
546
547          gridbagconstraints.weightx = 0.0D;
548          gridbagconstraints.gridwidth = GridBagConstraints.REMAINDER;
549          JButton JavaDoc button = new JButton JavaDoc(resources.getString("customizer.tab.detail.button.invoke"));
550          final MBeanMethodDialog dialog = new MBeanMethodDialog(this.object, operationInfo, null);
551
552          if (this.invocationDialogs == null)
553          {
554             this.invocationDialogs = new Hashtable JavaDoc();
555          }
556          this.invocationDialogs.put(operationInfo.getName(), dialog);
557
558          button.addActionListener(
559             new ActionListener JavaDoc()
560             {
561                public void actionPerformed(ActionEvent JavaDoc e)
562                {
563                   dialog.show();
564                }
565             }
566             );
567          this.mbeanOperations.add(button, gridbagconstraints);
568       }
569    }
570
571
572    /**
573     * Description of the Method
574     *
575     * @param info Description of the Parameter
576     */

577    protected void buildSummaryPanel(MBeanInfo JavaDoc info)
578    {
579       GridBagConstraints JavaDoc gridbagconstraints = new GridBagConstraints JavaDoc();
580       gridbagconstraints.insets = new Insets JavaDoc(0, 0, 0, 0);
581       gridbagconstraints.anchor = GridBagConstraints.NORTH;
582       gridbagconstraints.weightx = 0.0D;
583       gridbagconstraints.weighty = 1.0D;
584       gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
585
586       this.mbeanSummary = new JPanel JavaDoc(new GridBagLayout JavaDoc());
587       this.mbeanSummary.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), this.object.getCanonicalName()));
588
589       // ====================
590
// Misc infos
591
// ====================
592
this.add(
593          resources.getString("customizer.tab.detail.text.mo.name"),
594          resources.getString("customizer.tab.detail.tooltip.mo.name"),
595          object.getName());
596       this.add(
597          resources.getString("customizer.tab.detail.text.mo.type"),
598          resources.getString("customizer.tab.detail.tooltip.mo.type"),
599          object.getJ2EEType());
600
601       // ====================
602
// Misc infos
603
// ====================
604
this.add(
605          resources.getString("customizer.tab.detail.text.class.name"),
606          resources.getString("customizer.tab.detail.tooltip.class.name"),
607          info.getClassName());
608       this.add(
609          resources.getString("customizer.tab.detail.text.class.description"),
610          resources.getString("customizer.tab.detail.tooltip.class.description"),
611          info.getDescription());
612
613       // ====================
614
// Capabilities infos
615
// ====================
616
this.add(
617          resources.getString("customizer.tab.detail.text.mo.state.manageable"),
618          resources.getString("customizer.tab.detail.tooltip.mo.state.manageable"),
619          "" + this.object.isStateManageable());
620       this.add(
621          resources.getString("customizer.tab.detail.text.mo.event.provider"),
622          resources.getString("customizer.tab.detail.tooltip.mo.event.provider"),
623          "" + this.object.isEventProvider());
624       this.add(
625          resources.getString("customizer.tab.detail.text.mo.statistics.provider"),
626          resources.getString("customizer.tab.detail.tooltip.mo.statistics.provider"),
627          "" + this.object.isStatisticsProvider());
628    }
629
630
631    /**
632     * Returns the updaters.
633     *
634     * @return Vector
635     */

636    protected ArrayList JavaDoc getUpdaters()
637    {
638       if (this.updaters == null)
639       {
640          this.updaters = new ArrayList JavaDoc();
641       }
642       return this.updaters;
643    }
644
645
646    /**
647     * Description of the Method
648     *
649     * @param s Description of Parameter
650     * @param obj Description of Parameter
651     * @param obj1 Description of Parameter
652     */

653    protected void updated(String JavaDoc s, Object JavaDoc obj, Object JavaDoc obj1)
654    {
655       this.firePropertyChange(s, obj, obj1);
656    }
657
658
659    /**
660     * Description of the Class
661     *
662     * @author letiembl
663     * @version $Revision: 1.7 $
664     * @created 21 novembre 2002
665     */

666    protected class Updater
667    {
668       /** Description of the Field */
669       protected PropertyEditor JavaDoc editor;
670       /** Description of the Field */
671       protected MBeanAttributeInfo JavaDoc info;
672
673
674       /**
675        * Constructor for the EditorUpdater object
676        *
677        * @param editor Description of Parameter
678        * @param info Description of Parameter
679        */

680       public Updater(PropertyEditor JavaDoc editor, MBeanAttributeInfo JavaDoc info)
681       {
682          this.editor = editor;
683          this.info = info;
684       }
685
686
687       /** Description of the Method */
688       public void updateFromBean()
689       {
690          if (this.info.isReadable())
691          {
692             try
693             {
694                this.editor.setValue(ManagedObjectDetailViewer.this.object.getAttribute(this.info.getName()));
695             }
696             catch (Exception JavaDoc e)
697             {
698                logger.error("Error while updating from remote", e);
699             }
700          }
701       }
702
703
704       /** Description of the Method */
705       public void updateFromEditor()
706       {
707          if (this.info.isWritable())
708          {
709             try
710             {
711                Object JavaDoc newValue = this.editor.getValue();
712                if ((newValue != null) && (this.info.isReadable()))
713                {
714                   Object JavaDoc oldValue = ManagedObjectDetailViewer.this.object.getAttribute(this.info.getName());
715                   if (!newValue.equals(oldValue))
716                   {
717                      Attribute JavaDoc attr = new Attribute JavaDoc(this.info.getName(), newValue);
718                      ManagedObjectDetailViewer.this.object.setAttribute(attr);
719                   }
720                }
721             }
722             catch (Exception JavaDoc e)
723             {
724                logger.error("Error while updating from editor", e);
725             }
726          }
727       }
728    }
729 }
730
731
Popular Tags