1 19 20 package org.netbeans.modules.ruby.rubyproject.ui.customizer; 21 22 import java.awt.Component ; 23 import java.awt.Dialog ; 24 import java.awt.Font ; 25 import java.awt.event.ActionEvent ; 26 import java.awt.event.ActionListener ; 27 import java.awt.event.MouseEvent ; 28 import java.io.File ; 29 import java.text.Collator ; 30 import java.util.Comparator ; 31 import java.util.HashMap ; 32 import java.util.Iterator ; 33 import java.util.Map ; 34 import java.util.SortedSet ; 35 import java.util.TreeSet ; 36 import javax.swing.DefaultComboBoxModel ; 37 import javax.swing.DefaultListCellRenderer ; 38 import javax.swing.JButton ; 39 import javax.swing.JFileChooser ; 40 import javax.swing.JLabel ; 41 import javax.swing.JList ; 42 import javax.swing.JPanel ; 43 import javax.swing.JTextField ; 44 import javax.swing.event.ChangeEvent ; 45 import javax.swing.event.ChangeListener ; 46 import javax.swing.event.DocumentEvent ; 47 import javax.swing.event.DocumentListener ; 48 import org.netbeans.modules.ruby.rubyproject.RubyProject; 49 import org.netbeans.modules.ruby.rubyproject.SourceRoots; 50 import org.openide.DialogDescriptor; 51 import org.openide.DialogDisplayer; 52 import org.openide.NotifyDescriptor; 53 import org.openide.awt.MouseUtils; 54 import org.openide.filesystems.FileUtil; 55 import org.openide.util.HelpCtx; 56 import org.openide.util.NbBundle; 57 import org.openide.util.Utilities; 58 59 public class CustomizerRun extends JPanel implements HelpCtx.Provider { 60 61 private RubyProject project; 62 63 private JTextField [] data; 64 private JLabel [] dataLabels; 65 private String [] keys; 66 private Map <String ,Map <String ,String >> configs; 67 RubyProjectProperties uiProperties; 68 69 public CustomizerRun( RubyProjectProperties uiProperties ) { 70 this.uiProperties = uiProperties; 71 initComponents(); 72 73 this.project = uiProperties.getProject(); 74 75 configs = uiProperties.RUN_CONFIGS; 76 77 data = new JTextField [] { 78 jTextFieldMainClass, 79 jTextFieldArgs, 80 jTextVMOptions, 81 jTextWorkingDirectory, 82 }; 83 dataLabels = new JLabel [] { 84 jLabelMainClass, 85 jLabelArgs, 86 jLabelVMOptions, 87 jLabelWorkingDirectory, 88 }; 89 keys = new String [] { 90 RubyProjectProperties.MAIN_CLASS, 91 RubyProjectProperties.APPLICATION_ARGS, 92 RubyProjectProperties.RUN_JVM_ARGS, 93 RubyProjectProperties.RUN_WORK_DIR, 94 }; 95 assert data.length == keys.length; 96 97 configChanged(uiProperties.activeConfig); 98 99 configCombo.setRenderer(new DefaultListCellRenderer () { 100 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 101 String config = (String ) value; 102 String label; 103 if (config == null) { 104 label = null; 106 } else if (config.length() > 0) { 107 Map <String ,String > m = configs.get(config); 108 label = m != null ? m.get("$label") : null; 109 if (label == null) { 110 label = config; 111 } 112 } else { 113 label = NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.default"); 114 } 115 return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus); 116 } 117 }); 118 119 for (int i = 0; i < data.length; i++) { 120 final JTextField field = data[i]; 121 final String prop = keys[i]; 122 final JLabel label = dataLabels[i]; 123 field.getDocument().addDocumentListener(new DocumentListener () { 124 Font basefont = label.getFont(); 125 Font boldfont = basefont.deriveFont(Font.BOLD); 126 { 127 updateFont(); 128 } 129 public void insertUpdate(DocumentEvent e) { 130 changed(); 131 } 132 public void removeUpdate(DocumentEvent e) { 133 changed(); 134 } 135 public void changedUpdate(DocumentEvent e) {} 136 void changed() { 137 String config = (String ) configCombo.getSelectedItem(); 138 if (config.length() == 0) { 139 config = null; 140 } 141 String v = field.getText(); 142 if (v != null && config != null && v.equals(configs.get(null).get(prop))) { 143 v = null; 145 } 146 configs.get(config).put(prop, v); 147 updateFont(); 148 } 149 void updateFont() { 150 String v = field.getText(); 151 String config = (String ) configCombo.getSelectedItem(); 152 if (config.length() == 0) { 153 config = null; 154 } 155 String def = configs.get(null).get(prop); 156 label.setFont(config != null && !Utilities.compareObjects(v != null ? v : "", def != null ? def : "") ? boldfont : basefont); 157 } 158 }); 159 } 160 161 jButtonMainClass.addActionListener( new MainClassListener( project.getSourceRoots(), jTextFieldMainClass ) ); 162 } 163 164 public HelpCtx getHelpCtx() { 165 return new HelpCtx( CustomizerRun.class ); 166 } 167 168 173 private void initComponents() { 175 java.awt.GridBagConstraints gridBagConstraints; 176 177 configSep = new javax.swing.JSeparator (); 178 configPanel = new javax.swing.JPanel (); 179 configLabel = new javax.swing.JLabel (); 180 configCombo = new javax.swing.JComboBox (); 181 configNew = new javax.swing.JButton (); 182 configDel = new javax.swing.JButton (); 183 mainPanel = new javax.swing.JPanel (); 184 jLabelMainClass = new javax.swing.JLabel (); 185 jTextFieldMainClass = new javax.swing.JTextField (); 186 jButtonMainClass = new javax.swing.JButton (); 187 jLabelArgs = new javax.swing.JLabel (); 188 jTextFieldArgs = new javax.swing.JTextField (); 189 jLabelWorkingDirectory = new javax.swing.JLabel (); 190 jTextWorkingDirectory = new javax.swing.JTextField (); 191 jButtonWorkingDirectoryBrowse = new javax.swing.JButton (); 192 jLabelVMOptions = new javax.swing.JLabel (); 193 jTextVMOptions = new javax.swing.JTextField (); 194 jLabelVMOptionsExample = new javax.swing.JLabel (); 195 196 setLayout(new java.awt.GridBagLayout ()); 197 gridBagConstraints = new java.awt.GridBagConstraints (); 198 gridBagConstraints.gridx = 0; 199 gridBagConstraints.gridy = 1; 200 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 201 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 202 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 0); 203 add(configSep, gridBagConstraints); 204 205 configPanel.setLayout(new java.awt.GridBagLayout ()); 206 207 configLabel.setLabelFor(configCombo); 208 org.openide.awt.Mnemonics.setLocalizedText(configLabel, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configLabel")); gridBagConstraints = new java.awt.GridBagConstraints (); 210 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 211 gridBagConstraints.insets = new java.awt.Insets (2, 0, 2, 0); 212 configPanel.add(configLabel, gridBagConstraints); 213 214 configCombo.setModel(new javax.swing.DefaultComboBoxModel (new String [] { "<default>" })); 215 configCombo.addActionListener(new java.awt.event.ActionListener () { 216 public void actionPerformed(java.awt.event.ActionEvent evt) { 217 configComboActionPerformed(evt); 218 } 219 }); 220 gridBagConstraints = new java.awt.GridBagConstraints (); 221 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 222 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 223 gridBagConstraints.weightx = 1.0; 224 gridBagConstraints.insets = new java.awt.Insets (2, 6, 2, 0); 225 configPanel.add(configCombo, gridBagConstraints); 226 227 org.openide.awt.Mnemonics.setLocalizedText(configNew, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configNew")); configNew.addActionListener(new java.awt.event.ActionListener () { 229 public void actionPerformed(java.awt.event.ActionEvent evt) { 230 configNewActionPerformed(evt); 231 } 232 }); 233 gridBagConstraints = new java.awt.GridBagConstraints (); 234 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 235 gridBagConstraints.insets = new java.awt.Insets (2, 6, 2, 0); 236 configPanel.add(configNew, gridBagConstraints); 237 238 org.openide.awt.Mnemonics.setLocalizedText(configDel, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.configDelete")); configDel.addActionListener(new java.awt.event.ActionListener () { 240 public void actionPerformed(java.awt.event.ActionEvent evt) { 241 configDelActionPerformed(evt); 242 } 243 }); 244 gridBagConstraints = new java.awt.GridBagConstraints (); 245 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 246 gridBagConstraints.insets = new java.awt.Insets (2, 6, 2, 0); 247 configPanel.add(configDel, gridBagConstraints); 248 249 gridBagConstraints = new java.awt.GridBagConstraints (); 250 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 251 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 252 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 0); 253 add(configPanel, gridBagConstraints); 254 255 mainPanel.setLayout(new java.awt.GridBagLayout ()); 256 257 jLabelMainClass.setLabelFor(jTextFieldMainClass); 258 org.openide.awt.Mnemonics.setLocalizedText(jLabelMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JLabel")); gridBagConstraints = new java.awt.GridBagConstraints (); 260 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 261 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 262 mainPanel.add(jLabelMainClass, gridBagConstraints); 263 gridBagConstraints = new java.awt.GridBagConstraints (); 264 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 265 gridBagConstraints.weightx = 1.0; 266 gridBagConstraints.insets = new java.awt.Insets (0, 12, 5, 0); 267 mainPanel.add(jTextFieldMainClass, gridBagConstraints); 268 jTextFieldMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldMainClass")); 270 org.openide.awt.Mnemonics.setLocalizedText(jButtonMainClass, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_MainClass_JButton")); gridBagConstraints = new java.awt.GridBagConstraints (); 272 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 273 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 274 gridBagConstraints.insets = new java.awt.Insets (0, 6, 5, 0); 275 mainPanel.add(jButtonMainClass, gridBagConstraints); 276 jButtonMainClass.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jButtonMainClass")); 278 jLabelArgs.setLabelFor(jTextFieldArgs); 279 org.openide.awt.Mnemonics.setLocalizedText(jLabelArgs, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Args_JLabel")); gridBagConstraints = new java.awt.GridBagConstraints (); 281 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 282 gridBagConstraints.insets = new java.awt.Insets (0, 0, 12, 0); 283 mainPanel.add(jLabelArgs, gridBagConstraints); 284 gridBagConstraints = new java.awt.GridBagConstraints (); 285 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 286 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 287 gridBagConstraints.weightx = 1.0; 288 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 0); 289 mainPanel.add(jTextFieldArgs, gridBagConstraints); 290 jTextFieldArgs.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerRun.class).getString("AD_jTextFieldArgs")); 292 jLabelWorkingDirectory.setLabelFor(jTextWorkingDirectory); 293 org.openide.awt.Mnemonics.setLocalizedText(jLabelWorkingDirectory, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory")); gridBagConstraints = new java.awt.GridBagConstraints (); 295 gridBagConstraints.gridy = 2; 296 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 297 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 298 mainPanel.add(jLabelWorkingDirectory, gridBagConstraints); 299 gridBagConstraints = new java.awt.GridBagConstraints (); 300 gridBagConstraints.gridy = 2; 301 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 302 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 303 gridBagConstraints.weightx = 1.0; 304 gridBagConstraints.insets = new java.awt.Insets (0, 12, 5, 0); 305 mainPanel.add(jTextWorkingDirectory, gridBagConstraints); 306 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/ruby/rubyproject/ui/customizer/Bundle"); jTextWorkingDirectory.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_Working_Directory")); 309 org.openide.awt.Mnemonics.setLocalizedText(jButtonWorkingDirectoryBrowse, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse")); jButtonWorkingDirectoryBrowse.addActionListener(new java.awt.event.ActionListener () { 311 public void actionPerformed(java.awt.event.ActionEvent evt) { 312 jButtonWorkingDirectoryBrowseActionPerformed(evt); 313 } 314 }); 315 gridBagConstraints = new java.awt.GridBagConstraints (); 316 gridBagConstraints.gridy = 2; 317 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 318 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 319 gridBagConstraints.insets = new java.awt.Insets (0, 6, 5, 0); 320 mainPanel.add(jButtonWorkingDirectoryBrowse, gridBagConstraints); 321 jButtonWorkingDirectoryBrowse.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_Working_Directory_Browse")); 323 jLabelVMOptions.setLabelFor(jTextVMOptions); 324 org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptions, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options")); gridBagConstraints = new java.awt.GridBagConstraints (); 326 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 327 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 328 mainPanel.add(jLabelVMOptions, gridBagConstraints); 329 gridBagConstraints = new java.awt.GridBagConstraints (); 330 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 331 gridBagConstraints.weightx = 1.0; 332 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 333 mainPanel.add(jTextVMOptions, gridBagConstraints); 334 jTextVMOptions.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_CustomizeRun_Run_VM_Options")); 336 jLabelVMOptionsExample.setLabelFor(jTextFieldMainClass); 337 org.openide.awt.Mnemonics.setLocalizedText(jLabelVMOptionsExample, org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_VM_Options_Example")); gridBagConstraints = new java.awt.GridBagConstraints (); 339 gridBagConstraints.gridx = 1; 340 gridBagConstraints.gridy = 4; 341 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 342 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 343 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 344 gridBagConstraints.weighty = 1.0; 345 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 0); 346 mainPanel.add(jLabelVMOptionsExample, gridBagConstraints); 347 jLabelVMOptionsExample.getAccessibleContext().setAccessibleDescription(bundle.getString("LBL_CustomizeRun_Run_VM_Options_Example")); 349 gridBagConstraints = new java.awt.GridBagConstraints (); 350 gridBagConstraints.gridx = 0; 351 gridBagConstraints.gridy = 2; 352 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 353 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 354 gridBagConstraints.weightx = 1.0; 355 gridBagConstraints.weighty = 1.0; 356 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 0); 357 add(mainPanel, gridBagConstraints); 358 } 360 private void configDelActionPerformed(java.awt.event.ActionEvent evt) { String config = (String ) configCombo.getSelectedItem(); 362 assert config != null; 363 configs.put(config, null); 364 configChanged(null); 365 uiProperties.activeConfig = null; 366 } 368 private void configNewActionPerformed(java.awt.event.ActionEvent evt) { NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine( 370 NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.input.prompt"), 371 NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.input.title")); 372 if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.OK_OPTION) { 373 return; 374 } 375 String name = d.getInputText(); 376 String config = name.replaceAll("[^a-zA-Z0-9_.-]", "_"); if (configs.get(config) != null) { 378 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( 379 NbBundle.getMessage(CustomizerRun.class, "CustomizerRun.input.duplicate", config), 380 NotifyDescriptor.WARNING_MESSAGE)); 381 return; 382 } 383 Map <String ,String > m = new HashMap <String ,String >(); 384 if (!name.equals(config)) { 385 m.put("$label", name); } 387 configs.put(config, m); 388 configChanged(config); 389 uiProperties.activeConfig = config; 390 } 392 private void configComboActionPerformed(java.awt.event.ActionEvent evt) { String config = (String ) configCombo.getSelectedItem(); 394 if (config.length() == 0) { 395 config = null; 396 } 397 configChanged(config); 398 uiProperties.activeConfig = config; 399 } 401 private void jButtonWorkingDirectoryBrowseActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (); 403 FileUtil.preventFileChooserSymlinkTraversal(chooser, null); 404 chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY); 405 chooser.setMultiSelectionEnabled(false); 406 407 String workDir = jTextWorkingDirectory.getText(); 408 if (workDir.equals("")) { 409 workDir = FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath(); 410 } 411 chooser.setSelectedFile(new File (workDir)); 412 chooser.setDialogTitle(NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Run_Working_Directory_Browse_Title")); 413 if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { File file = FileUtil.normalizeFile(chooser.getSelectedFile()); 415 jTextWorkingDirectory.setText(file.getAbsolutePath()); 416 } 417 } 419 private void configChanged(String activeConfig) { 420 DefaultComboBoxModel model = new DefaultComboBoxModel (); 421 model.addElement(""); 422 SortedSet <String > alphaConfigs = new TreeSet <String >(new Comparator <String >() { 423 Collator coll = Collator.getInstance(); 424 public int compare(String s1, String s2) { 425 return coll.compare(label(s1), label(s2)); 426 } 427 private String label(String c) { 428 Map <String ,String > m = configs.get(c); 429 String label = m.get("$label"); return label != null ? label : c; 431 } 432 }); 433 for (Map.Entry <String ,Map <String ,String >> entry : configs.entrySet()) { 434 String config = entry.getKey(); 435 if (config != null && entry.getValue() != null) { 436 alphaConfigs.add(config); 437 } 438 } 439 for (String c : alphaConfigs) { 440 model.addElement(c); 441 } 442 configCombo.setModel(model); 443 configCombo.setSelectedItem(activeConfig != null ? activeConfig : ""); 444 Map <String ,String > m = configs.get(activeConfig); 445 Map <String ,String > def = configs.get(null); 446 if (m != null) { 447 for (int i = 0; i < data.length; i++) { 448 String v = m.get(keys[i]); 449 if (v == null) { 450 v = def.get(keys[i]); 452 } 453 data[i].setText(v); 454 } 455 } configDel.setEnabled(activeConfig != null); 457 } 458 459 460 private javax.swing.JComboBox configCombo; 462 private javax.swing.JButton configDel; 463 private javax.swing.JLabel configLabel; 464 private javax.swing.JButton configNew; 465 private javax.swing.JPanel configPanel; 466 private javax.swing.JSeparator configSep; 467 private javax.swing.JButton jButtonMainClass; 468 private javax.swing.JButton jButtonWorkingDirectoryBrowse; 469 private javax.swing.JLabel jLabelArgs; 470 private javax.swing.JLabel jLabelMainClass; 471 private javax.swing.JLabel jLabelVMOptions; 472 private javax.swing.JLabel jLabelVMOptionsExample; 473 private javax.swing.JLabel jLabelWorkingDirectory; 474 private javax.swing.JTextField jTextFieldArgs; 475 private javax.swing.JTextField jTextFieldMainClass; 476 private javax.swing.JTextField jTextVMOptions; 477 private javax.swing.JTextField jTextWorkingDirectory; 478 private javax.swing.JPanel mainPanel; 479 481 482 484 private class MainClassListener implements ActionListener { 485 486 private final JButton okButton; 487 private SourceRoots sourceRoots; 488 private JTextField mainClassTextField; 489 490 MainClassListener( SourceRoots sourceRoots, JTextField mainClassTextField ) { 491 this.sourceRoots = sourceRoots; 492 this.mainClassTextField = mainClassTextField; 493 this.okButton = new JButton (NbBundle.getMessage (CustomizerRun.class, "LBL_ChooseMainClass_OK")); 494 this.okButton.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage (CustomizerRun.class, "AD_ChooseMainClass_OK")); 495 } 496 497 499 501 public void actionPerformed( ActionEvent e ) { 502 503 505 final MainClassChooser panel = new MainClassChooser (sourceRoots.getRoots()); 506 Object [] options = new Object [] { 507 okButton, 508 DialogDescriptor.CANCEL_OPTION 509 }; 510 panel.addChangeListener (new ChangeListener () { 511 public void stateChanged(ChangeEvent e) { 512 if (e.getSource () instanceof MouseEvent && MouseUtils.isDoubleClick (((MouseEvent )e.getSource ()))) { 513 okButton.doClick (); 515 } else { 516 okButton.setEnabled (panel.getSelectedMainClass () != null); 517 } 518 } 519 }); 520 okButton.setEnabled (false); 521 DialogDescriptor desc = new DialogDescriptor ( 522 panel, 523 NbBundle.getMessage (CustomizerRun.class, "LBL_ChooseMainClass_Title" ), 524 true, 525 options, 526 options[0], 527 DialogDescriptor.BOTTOM_ALIGN, 528 null, 529 null); 530 Dialog dlg = DialogDisplayer.getDefault ().createDialog (desc); 532 dlg.setVisible (true); 533 if (desc.getValue() == options[0]) { 534 mainClassTextField.setText (panel.getSelectedMainClass ()); 535 } 536 dlg.dispose(); 537 } 538 539 } 540 541 } 542 | Popular Tags |