| 1 package org.sape.carbon.services.console; 2 3 import javax.management.MBeanAttributeInfo ; 4 import javax.management.MBeanServer ; 5 import javax.management.ObjectName ; 6 7 14 public class AttributesPanel extends javax.swing.JPanel { 15 16 private ObjectName objectName; 17 private MBeanServer server; 18 19 20 public AttributesPanel(ObjectName objectName, MBeanServer server) { 21 this.objectName = objectName; 22 this.server = server; 23 24 initComponents(); 25 } 26 27 public void addRow(AttributePanel row) { 28 this.attributesPane.add(row); 29 } 30 31 36 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 38 39 buttonPanel = new javax.swing.JPanel (); 40 refreshButton = new javax.swing.JButton (); 41 saveButton = new javax.swing.JButton (); 42 jButton1 = new javax.swing.JButton (); 43 attributesScrollPane = new javax.swing.JScrollPane (); 44 attributesPane = new javax.swing.JPanel (); 45 46 setLayout(new java.awt.BorderLayout ()); 47 48 buttonPanel.setLayout(new java.awt.GridBagLayout ()); 49 50 refreshButton.setIcon(new javax.swing.ImageIcon (getClass().getResource("/rsrc/icons/Refresh24.gif"))); 51 refreshButton.setText("Refresh"); 52 refreshButton.addActionListener(new java.awt.event.ActionListener () { 53 public void actionPerformed(java.awt.event.ActionEvent evt) { 54 refreshButtonActionPerformed(evt); 55 } 56 }); 57 58 gridBagConstraints = new java.awt.GridBagConstraints (); 59 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 60 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 61 buttonPanel.add(refreshButton, gridBagConstraints); 62 63 saveButton.setIcon(new javax.swing.ImageIcon (getClass().getResource("/rsrc/icons/Save24.gif"))); 64 saveButton.setText("Save"); 65 saveButton.addActionListener(new java.awt.event.ActionListener () { 66 public void actionPerformed(java.awt.event.ActionEvent evt) { 67 saveButtonActionPerformed(evt); 68 } 69 }); 70 71 gridBagConstraints = new java.awt.GridBagConstraints (); 72 gridBagConstraints.gridx = 2; 73 gridBagConstraints.gridy = 0; 74 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 75 gridBagConstraints.weightx = 1.0; 76 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 77 buttonPanel.add(saveButton, gridBagConstraints); 78 79 jButton1.setIcon(new javax.swing.ImageIcon (getClass().getResource("/rsrc/icons/Graph24.gif"))); 80 jButton1.setText("Graph Selected"); 81 jButton1.addActionListener(new java.awt.event.ActionListener () { 82 public void actionPerformed(java.awt.event.ActionEvent evt) { 83 jButton1ActionPerformed(evt); 84 } 85 }); 86 87 gridBagConstraints = new java.awt.GridBagConstraints (); 88 gridBagConstraints.gridx = 1; 89 gridBagConstraints.gridy = 0; 90 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 91 buttonPanel.add(jButton1, gridBagConstraints); 92 93 add(buttonPanel, java.awt.BorderLayout.SOUTH); 94 95 attributesPane.setLayout(new javax.swing.BoxLayout (attributesPane, javax.swing.BoxLayout.Y_AXIS)); 96 97 attributesScrollPane.setViewportView(attributesPane); 98 99 add(attributesScrollPane, java.awt.BorderLayout.CENTER); 100 101 } 103 private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) { int count = this.attributesPane.getComponentCount(); 106 for (int i = 0; i < count; i++) { 107 AttributePanel panel = 108 (AttributePanel) this.attributesPane.getComponent(i); 109 panel.refresh(); 110 111 } 112 } 114 private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) { int count = this.attributesPane.getComponentCount(); 117 for (int i = 0; i < count; i++) { 118 AttributePanel panel = 119 (AttributePanel) this.attributesPane.getComponent(i); 120 121 } 122 123 } 125 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int count = this.attributesPane.getComponentCount(); 128 129 131 int found = 0; 132 for (int i = 0; i < count; i++) { 133 AttributePanel panel = 134 (AttributePanel) this.attributesPane.getComponent(i); 135 136 if (panel.isShouldGraph()) { 137 found++; 138 } 139 } 140 MBeanAttributeInfo [] attributeInfos = new MBeanAttributeInfo [found]; 141 found = 0; 142 for (int i = 0; i < count; i++) { 143 AttributePanel panel = 144 (AttributePanel) this.attributesPane.getComponent(i); 145 146 if (panel.isShouldGraph()) { 147 MBeanAttributeInfo info = panel.getAttributeInfo(); 148 attributeInfos[found++] = info; 149 } 150 } 151 152 AttributeGraph attrGraph = 153 new AttributeGraph(this.objectName, attributeInfos, this.server); 154 attrGraph.show(); 155 } 157 158 private javax.swing.JButton jButton1; 160 private javax.swing.JScrollPane attributesScrollPane; 161 private javax.swing.JButton refreshButton; 162 private javax.swing.JButton saveButton; 163 private javax.swing.JPanel buttonPanel; 164 private javax.swing.JPanel attributesPane; 165 167 } 168 | Popular Tags |