View Javadoc
1 package net.sf.panoptes.view.configurator; 2 3 import javax.management.Attribute; 4 import javax.management.MBeanParameterInfo; 5 6 import net.sf.panoptes.model.component.jmx.MBeanComponent; 7 import net.sf.panoptes.model.component.jmx.Operation; 8 import net.sf.panoptes.model.node.*; 9 10 import org.eclipse.swt.SWT; 11 import org.eclipse.swt.custom.SashForm; 12 import org.eclipse.swt.layout.FillLayout; 13 import org.eclipse.swt.layout.GridData; 14 import org.eclipse.swt.layout.GridLayout; 15 import org.eclipse.swt.widgets.Button; 16 import org.eclipse.swt.widgets.Composite; 17 import org.eclipse.swt.widgets.Event; 18 import org.eclipse.swt.widgets.Label; 19 import org.eclipse.swt.widgets.Listener; 20 import org.eclipse.swt.widgets.Table; 21 import org.eclipse.swt.widgets.TableColumn; 22 import org.eclipse.swt.widgets.TableItem; 23 //import com.sun.org.omg.CORBA.OperationDescription; 24 25 /*** 26 * IntrospectorPanel.java 27 * 28 * Simple NodeConfigurator for MBeanComponent introspection. 29 * 30 * @see net.sf.panoptes.model.component.jmx.MBeanComponent 31 * @author Dag Liodden 32 * @version 0.1 33 */ 34 public class IntrospectorPanel extends NodeConfigurator { 35 36 private MBeanComponent mBean = null; 37 Table opTable; 38 Table propTable; 39 Label beanDescriptionLabel; 40 41 /*** 42 * Constructor for IntrospectorPanel. 43 * @param parent 44 * @param style 45 */ 46 public IntrospectorPanel(Composite parent, int style) { 47 super(parent, style); 48 49 this.setLayout(new FillLayout()); 50 51 SashForm sash = new SashForm(this, SWT.VERTICAL); 52 53 Composite top = new Composite(sash, SWT.NULL); 54 top.setLayout(new GridLayout()); 55 beanDescriptionLabel = new Label(top, SWT.NULL); 56 beanDescriptionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 57 58 Button btnRefresh = new Button(top, SWT.NULL); 59 // btnRefresh.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 60 btnRefresh.setText("Refresh"); 61 btnRefresh.addListener(SWT.Selection, new Listener() { 62 public void handleEvent(Event arg0) { 63 mBean.refresh(); 64 setBean(mBean); 65 } 66 }); 67 68 Label l = new Label(top, SWT.NULL); 69 l.setText("Properties:"); 70 l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 71 72 propTable = new Table(top, SWT.BORDER | SWT.FULL_SELECTION); 73 propTable.setLinesVisible(true); 74 propTable.setHeaderVisible(true); 75 propTable.setLayoutData(new GridData(GridData.FILL_BOTH)); 76 77 TableColumn tc; 78 tc = new TableColumn(propTable, SWT.NULL); 79 tc.setText("Name"); 80 tc.setWidth(150); 81 82 tc = new TableColumn(propTable, SWT.NULL); 83 tc.setText("Value"); 84 tc.setWidth(200); 85 86 final Composite bottom = new Composite(sash, SWT.NULL); 87 bottom.setLayout(new GridLayout()); 88 l = new Label(bottom, SWT.NULL); 89 l.setText("Operations:"); 90 l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 91 92 Table t; 93 94 opTable = new Table(bottom, SWT.BORDER | SWT.FULL_SELECTION); 95 opTable.setLinesVisible(true); 96 opTable.setHeaderVisible(true); 97 opTable.setLayoutData(new GridData(GridData.FILL_BOTH)); 98 99 tc = new TableColumn(opTable, SWT.NULL); 100 tc.setText("Name"); 101 tc.setWidth(150); 102 103 tc = new TableColumn(opTable, SWT.NULL); 104 tc.setText("Parameters"); 105 tc.setWidth(200); 106 107 tc = new TableColumn(opTable, SWT.NULL); 108 tc.setText("Returntype"); 109 tc.setWidth(100); 110 111 tc = new TableColumn(opTable, SWT.NULL); 112 tc.setText(""); 113 tc.setWidth(100); 114 115 116 } 117 118 public void setNode(INode configurable) { 119 setBean((MBeanComponent) configurable); 120 } 121 122 public void setBean(MBeanComponent mBean) { 123 this.mBean = mBean; 124 opTable.removeAll(); 125 propTable.removeAll(); 126 127 try { 128 beanDescriptionLabel.setText(mBean.getObjectName().toString()); 129 130 Attribute[] atts = mBean.getAttributes(); 131 for (int i = 0; i < atts.length; i++) { 132 Attribute a = atts[i]; 133 TableItem ti = new TableItem(propTable, SWT.NULL); 134 ti.setText(0, a.getName()); 135 136 Object value = mBean.getAttributeValue(a.getName()); 137 String strValue = value == null ? "null" : value.toString(); 138 ti.setText(1, strValue); 139 } 140 141 Operation[] ops = mBean.getOperations(); 142 for (int i = 0; i < ops.length; i++) { 143 TableItem ti = new TableItem(opTable, SWT.NULL); 144 ti.setData(ops[i]); 145 Operation op = ops[i]; 146 ti.setText(0, op.getName()); 147 ti.setText(2, op.getReturnType()); 148 149 MBeanParameterInfo[] params = op.getParameterInfo(); 150 StringBuffer s = new StringBuffer(); 151 if (params.length == 0) 152 s = new StringBuffer("void"); 153 else 154 for (int j = 0; j < params.length; j++) { 155 s.append(params[j].getType() + ", "); 156 } 157 ti.setText(1, s.toString()); 158 } 159 160 } catch (RuntimeException e) { 161 e.printStackTrace(); 162 } 163 } 164 165 }

This page was automatically generated by Maven