Public Member Functions | |
OperationCallDialog (CjdbcGui gui, ObjectName name, MBeanOperationInfo info) throws HeadlessException | |
void | actionPerformed (ActionEvent event) |
Package Attributes | |
CjdbcGui | gui |
ObjectName | objectN |
MBeanOperationInfo | info |
Definition at line 60 of file OperationCallDialog.java.
|
Creates a new
Definition at line 79 of file OperationCallDialog.java. 00081 { 00082 super(gui, "Operation Call Dialog", true); 00083 GuiConstants.centerComponent(this, 400, 500); 00084 this.gui = gui; 00085 this.objectN = name; 00086 this.info = info; 00087 00088 // Define the panels and areas 00089 GridBagLayout gbl = new GridBagLayout(); 00090 this.getContentPane().setLayout(gbl); 00091 this.setFont(GuiConstants.CENTER_PANE_FONT); 00092 GridBagConstraints gbc = new GridBagConstraints(); 00093 gbc.fill = GridBagConstraints.BOTH; 00094 gbc.weightx = 1.0; 00095 gbc.gridheight = 1; 00096 gbc.gridwidth = GridBagConstraints.REMAINDER; 00097 this.getContentPane().setBackground(Color.white); 00098 00099 JLabel objectName = new JLabel(name.toString()); 00100 objectName.setBorder(BorderFactory.createTitledBorder( 00101 GuiConstants.LINE_BORDER, "MBean Name")); 00102 gbl.setConstraints(objectName, gbc); 00103 this.getContentPane().add(objectName); 00104 00105 scrollPane = new JScrollPane(); 00106 scrollPane.setBackground(Color.white); 00107 scrollPane.setViewportBorder(BorderFactory.createTitledBorder( 00108 GuiConstants.LINE_BORDER, "Operation Result")); 00109 area = new JTextArea(); 00110 area.setBackground(Color.white); 00111 scrollPane.getViewport().add(area); 00112 00113 JLabel operation = new JLabel(info.getName()); 00114 operation.setBorder(BorderFactory.createTitledBorder( 00115 GuiConstants.LINE_BORDER, "Operation Name")); 00116 gbl.setConstraints(operation, gbc); 00117 this.getContentPane().add(operation); 00118 00119 JPanel operationPane = new JPanel(); 00120 operationPane.setBackground(Color.white); 00121 operationPane.setBorder(BorderFactory.createTitledBorder( 00122 GuiConstants.LINE_BORDER, "MBean parameters")); 00123 params = info.getSignature(); 00124 length = params.length; 00125 GridLayout gl = new GridLayout(info.getSignature().length, 2); 00126 operationPane.setLayout(gl); 00127 fields = new JTextField[length]; 00128 for (int i = 0; i < length; i++) 00129 { 00130 operationPane.add(new JLabel(params[i].getType())); 00131 fields[i] = new JTextField(""); 00132 operationPane.add(fields[i]); 00133 } 00134 gbl.setConstraints(operationPane, gbc); 00135 this.getContentPane().add(operationPane); 00136 00137 JButton ok = new JButton("Run Jmx operation"); 00138 ok.setBackground(new Color(198, 226, 255)); 00139 ok.setActionCommand(GuiCommands.COMMAND_CONFIRM_ACTION); 00140 ok.addActionListener(this); 00141 gbl.setConstraints(ok, gbc); 00142 this.getContentPane().add(ok); 00143 00144 gbc.gridheight = GridBagConstraints.REMAINDER; 00145 gbc.weighty = 2.0; 00146 gbl.setConstraints(scrollPane, gbc); 00147 this.getContentPane().add(scrollPane); 00148 00149 this.validate(); 00150 00151 }
|
|
Definition at line 156 of file OperationCallDialog.java. References org.objectweb.cjdbc.console.gui.CjdbcGui.getCurrentJmxClient(), org.objectweb.cjdbc.console.jmx.RmiJmxClient.invokeOperation(), and org.objectweb.cjdbc.console.jmx.RmiJmxClient.isSubjectSet(). 00157 { 00158 try 00159 { 00160 area.setForeground(Color.BLACK); 00161 if (gui.getCurrentJmxClient().isSubjectSet() == false 00162 && JmxConstants.mbeanNeedAuthentication(objectN)) 00163 new SetSubjectDialog(gui); 00164 Object[] args = new Object[length]; 00165 for (int i = 0; i < length; i++) 00166 { 00167 args[i] = getParameter(i); 00168 } 00169 Object result = gui.getCurrentJmxClient().invokeOperation(objectN, info, 00170 args); 00171 if (result != null) 00172 area.setText(result.toString()); 00173 else 00174 area.setText("Command did not return a result"); 00175 00176 area.validate(); 00177 scrollPane.validate(); 00178 } 00179 catch (Exception e) 00180 { 00181 area.setForeground(Color.RED); 00182 area.setText(e.getMessage()); 00183 JTextAreaWriter areaWriter = new JTextAreaWriter(area); 00184 PrintWriter writer = new PrintWriter(areaWriter); 00185 e.printStackTrace(writer); 00186 } 00187 }
|