1 12 13 package org.ejtools.jmx.browser.dialog; 14 15 16 17 import java.awt.Component ; 18 19 import java.awt.GridBagConstraints ; 20 21 import java.awt.GridBagLayout ; 22 23 import java.awt.GridLayout ; 24 25 import java.awt.Insets ; 26 27 import java.awt.event.ActionEvent ; 28 29 import java.awt.event.ActionListener ; 30 31 import java.util.ResourceBundle ; 32 33 34 35 import javax.swing.JButton ; 36 37 import javax.swing.JComboBox ; 38 39 import javax.swing.JDialog ; 40 41 import javax.swing.JLabel ; 42 43 import javax.swing.JPanel ; 44 45 import javax.swing.JTextField ; 46 47 import javax.swing.SwingConstants ; 48 49 50 51 60 61 public class CreateMBeanDialog extends JDialog 62 63 { 64 65 66 67 protected JTextField argTypes; 68 69 70 71 protected JTextField argValues; 72 73 74 75 protected JTextField classLoader; 76 77 78 79 protected JComboBox classes; 80 81 82 83 protected JComboBox domains; 84 85 86 87 protected Object objectName = null; 88 89 90 91 private static ResourceBundle resources = ResourceBundle.getBundle("org.ejtools.jmx.browser.Resources"); 92 93 94 95 96 97 110 111 public CreateMBeanDialog(Component parentComponent, Object [] domainValues, Object [] classValues) 112 113 { 114 115 super(); 116 117 this.setModal(true); 118 119 this.setTitle(resources.getString("create.dialog.title")); 120 121 122 123 JPanel main = new JPanel (new GridBagLayout ()); 124 125 GridBagConstraints constraints = new GridBagConstraints (); 126 127 constraints.insets = new Insets (5, 5, 5, 5); 128 129 130 131 constraints.gridwidth = GridBagConstraints.REMAINDER; 132 133 constraints.weightx = 1.0; 134 135 constraints.fill = GridBagConstraints.HORIZONTAL; 136 137 constraints.anchor = GridBagConstraints.WEST; 138 139 140 141 JLabel label = new JLabel (resources.getString("create.dialog.text.description")); 142 143 main.add(label, constraints); 144 145 146 147 constraints.gridwidth = GridBagConstraints.RELATIVE; 148 149 constraints.weightx = 0.0; 150 151 label = new JLabel (resources.getString("create.dialog.text.objectName") + " : ", SwingConstants.RIGHT); 152 153 main.add(label, constraints); 154 155 156 157 constraints.gridwidth = GridBagConstraints.REMAINDER; 158 159 constraints.weightx = 1.0; 160 161 this.domains = new JComboBox (domainValues); 162 163 this.domains.setEditable(true); 164 165 main.add(this.domains, constraints); 166 167 168 169 constraints.gridwidth = GridBagConstraints.RELATIVE; 170 171 constraints.weightx = 0.0; 172 173 label = new JLabel (resources.getString("create.dialog.text.className") + " : ", SwingConstants.RIGHT); 174 175 main.add(label, constraints); 176 177 178 179 constraints.gridwidth = GridBagConstraints.REMAINDER; 180 181 constraints.weightx = 1.0; 182 183 this.classes = new JComboBox (classValues); 184 185 this.classes.setEditable(true); 186 187 main.add(this.classes, constraints); 188 189 190 191 constraints.gridwidth = GridBagConstraints.RELATIVE; 192 193 constraints.weightx = 0.0; 194 195 label = new JLabel (resources.getString("create.dialog.text.classLoader") + " : ", SwingConstants.RIGHT); 196 197 main.add(label, constraints); 198 199 200 201 constraints.gridwidth = GridBagConstraints.REMAINDER; 202 203 constraints.weightx = 1.0; 204 205 this.classLoader = new JTextField (30); 206 207 main.add(this.classLoader, constraints); 208 209 210 211 constraints.gridwidth = GridBagConstraints.RELATIVE; 212 213 constraints.weightx = 0.0; 214 215 label = new JLabel (resources.getString("create.dialog.text.argValues") + " : ", SwingConstants.RIGHT); 216 217 main.add(label, constraints); 218 219 220 221 constraints.gridwidth = GridBagConstraints.REMAINDER; 222 223 constraints.weightx = 1.0; 224 225 this.argValues = new JTextField (30); 226 227 main.add(this.argValues, constraints); 228 229 230 231 constraints.gridwidth = GridBagConstraints.RELATIVE; 232 233 constraints.weightx = 0.0; 234 235 label = new JLabel (resources.getString("create.dialog.text.argTypes") + " : ", SwingConstants.RIGHT); 236 237 main.add(label, constraints); 238 239 240 241 constraints.gridwidth = GridBagConstraints.REMAINDER; 242 243 constraints.weightx = 1.0; 244 245 this.argTypes = new JTextField (30); 246 247 main.add(this.argTypes, constraints); 248 249 250 251 JPanel buttons = new JPanel (new GridLayout (1, 2, 2, 2)); 252 253 254 255 JButton buttonSelect = new JButton (resources.getString("create.dialog.button.create")); 256 257 buttons.add(buttonSelect); 258 259 buttonSelect.addActionListener( 260 261 new ActionListener () 262 263 { 264 265 public void actionPerformed(ActionEvent e) 266 267 { 268 269 objectName = domains.getEditor().getItem(); 270 271 CreateMBeanDialog.this.dispose(); 272 273 } 274 275 }); 276 277 278 279 JButton buttonCancel = new JButton (resources.getString("create.dialog.button.cancel")); 280 281 buttons.add(buttonCancel); 282 283 buttonCancel.addActionListener( 284 285 new ActionListener () 286 287 { 288 289 294 295 public void actionPerformed(ActionEvent e) 296 297 { 298 299 objectName = null; 300 301 CreateMBeanDialog.this.dispose(); 302 303 } 304 305 }); 306 307 308 309 constraints.fill = GridBagConstraints.NONE; 310 311 constraints.anchor = GridBagConstraints.SOUTH; 312 313 main.add(buttons, constraints); 314 315 316 317 this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); 318 319 this.getContentPane().add(main); 320 321 this.pack(); 322 323 this.setLocationRelativeTo(parentComponent); 324 325 } 326 327 328 329 330 331 340 341 public String getClassLoader() 342 343 { 344 345 return this.classLoader.getText(); 346 347 } 348 349 350 351 352 353 362 363 public String getObjectClass() 364 365 { 366 367 return this.classes.getEditor().getItem().toString(); 368 369 } 370 371 372 373 374 375 384 385 public Object getObjectName() 386 387 { 388 389 return this.objectName; 390 391 } 392 393 394 395 396 397 406 407 public String getParameters() 408 409 { 410 411 return this.argValues.getText(); 412 413 } 414 415 416 417 418 419 428 429 public String getSignature() 430 431 { 432 433 return this.argTypes.getText(); 434 435 } 436 437 } 438 439 | Popular Tags |