Public Member Functions | |
AttributeChangeDialog (CjdbcGui gui, ObjectName name, MBeanAttributeInfo info) | |
void | actionPerformed (ActionEvent e) |
Definition at line 55 of file AttributeChangeDialog.java.
|
Creates a new
Definition at line 74 of file AttributeChangeDialog.java. References org.objectweb.cjdbc.console.jmx.RmiJmxClient.getAttributeValue(), and org.objectweb.cjdbc.console.gui.CjdbcGui.getCurrentJmxClient(). 00076 { 00077 00078 super(gui, "Attribute Change", true); 00079 00080 this.info = info; 00081 this.gui = gui; 00082 this.objectName = name; 00083 GuiConstants.centerComponent(this, 400, 300); 00084 00085 this.setFont(GuiConstants.CENTER_PANE_FONT); 00086 00087 // Define the panels and areas 00088 GridBagLayout gbl = new GridBagLayout(); 00089 this.getContentPane().setLayout(gbl); 00090 GridBagConstraints gbc = new GridBagConstraints(); 00091 gbc.fill = GridBagConstraints.BOTH; 00092 gbc.weightx = 1.0; 00093 gbc.gridheight = 1; 00094 gbc.gridwidth = GridBagConstraints.REMAINDER; 00095 this.getContentPane().setBackground(Color.white); 00096 00097 JLabel objectName = new JLabel(name.toString()); 00098 objectName.setBorder(BorderFactory.createTitledBorder( 00099 GuiConstants.LINE_BORDER, "MBean Name")); 00100 gbl.setConstraints(objectName, gbc); 00101 this.getContentPane().add(objectName); 00102 00103 JLabel attribute = new JLabel(info.getName()); 00104 attribute.setBorder(BorderFactory.createTitledBorder( 00105 GuiConstants.LINE_BORDER, "Attribute Name (" + info.getType() + ")")); 00106 gbl.setConstraints(attribute, gbc); 00107 this.getContentPane().add(attribute); 00108 00109 JPanel values = new JPanel(); 00110 values.setBorder(BorderFactory.createTitledBorder(GuiConstants.LINE_BORDER, 00111 "Attribute Value")); 00112 values.setBackground(Color.white); 00113 values.setLayout(new GridLayout(2, 2)); 00114 values.add(new JLabel("Old Value")); 00115 00116 JTextField oldValue = new JTextField(); 00117 Object attributeValue = null; 00118 try 00119 { 00120 attributeValue = gui.getCurrentJmxClient().getAttributeValue(name, 00121 info.getName()); 00122 } 00123 catch (Exception e) 00124 { 00125 oldValue.setForeground(WARNING_COLOR); 00126 attributeValue = "<error>"; 00127 } 00128 finally 00129 { 00130 if (attributeValue == null) 00131 attributeValue = ""; 00132 } 00133 oldValue.setText(attributeValue.toString()); 00134 oldValue.setEditable(false); 00135 values.add(oldValue); 00136 values.add(new JLabel("New Value")); 00137 newValue = new JTextField(); 00138 if (!info.isWritable()) 00139 { 00140 newValue.setText(" "); 00141 newValue.setEnabled(false); 00142 } 00143 values.add(newValue); 00144 gbl.setConstraints(values, gbc); 00145 this.getContentPane().add(values); 00146 00147 JButton ok; 00148 if (!info.isWritable()) 00149 { 00150 ok = new JButton("Cannot change attribute value"); 00151 ok.setBackground(WARNING_COLOR); 00152 ok.setEnabled(false); 00153 } 00154 else 00155 { 00156 ok = new JButton("Change attribute value"); 00157 ok.setBackground(BUTTON_COLOR); 00158 ok.setEnabled(true); 00159 } 00160 ok.setActionCommand(GuiCommands.COMMAND_CONFIRM_ACTION); 00161 ok.addActionListener(this); 00162 gbl.setConstraints(ok, gbc); 00163 this.getContentPane().add(ok); 00164 00165 scrollPane = new JScrollPane(); 00166 scrollPane.setBackground(Color.white); 00167 scrollPane.setViewportBorder(BorderFactory.createTitledBorder( 00168 GuiConstants.LINE_BORDER, "Attribute Change Result")); 00169 area = new JTextArea(); 00170 area.setBackground(Color.white); 00171 scrollPane.getViewport().add(area); 00172 gbc.gridheight = GridBagConstraints.REMAINDER; 00173 gbc.weighty = 2.0; 00174 gbl.setConstraints(scrollPane, gbc); 00175 this.getContentPane().add(scrollPane); 00176 00177 this.validate(); 00178 00179 }
|
|
Definition at line 184 of file AttributeChangeDialog.java. References org.objectweb.cjdbc.console.gui.CjdbcGui.getCurrentJmxClient(), and org.objectweb.cjdbc.console.jmx.RmiJmxClient.setAttributeValue(). 00185 { 00186 if (!info.isWritable()) 00187 { 00188 area.setForeground(WARNING_COLOR); 00189 area.setText("This attribute cannot be changed"); 00190 } 00191 else 00192 { 00193 try 00194 { 00195 Object o = GuiConstants.convertType(newValue.getText(), info.getType()); 00196 gui.getCurrentJmxClient().setAttributeValue(objectName, info.getName(), 00197 o); 00198 area.setForeground(Color.BLACK); 00199 area.setText("Attribute value chaned"); 00200 } 00201 catch (Exception e1) 00202 { 00203 area.setForeground(WARNING_COLOR); 00204 area.setText(e1.getMessage()); 00205 } 00206 } 00207 }
|