1 19 20 package org.netbeans.modules.j2ee.ejbjarproject.ui.wizards; 21 22 import java.io.File ; 23 import java.text.MessageFormat ; 24 25 import javax.swing.JButton ; 26 import javax.swing.event.DocumentEvent ; 27 import javax.swing.event.DocumentListener ; 28 29 import org.openide.util.NbBundle; 30 31 import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; 32 33 public class ImportBuildfile extends javax.swing.JPanel implements DocumentListener { 34 35 private JButton ok; 36 private String filePath; 37 38 39 public ImportBuildfile(String filePath, JButton okButton) { 40 initComponents(); 41 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportBuildfile.class, "ACS_IW_BuildFileDialog_A11YDesc")); 43 ok = okButton; 44 this.filePath = filePath; 45 ok.setEnabled(false); 46 47 String fileName = filePath + File.separator + GeneratedFilesHelper.BUILD_XML_PATH; 48 String msg = MessageFormat.format(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildfileDesc_Label"), new String [] {fileName}); jLabelDesc.setText(msg); 50 jTextFieldBuildName.getDocument().addDocumentListener(this); 51 jTextFieldBuildName.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_ProposedName_TextField")); } 53 54 59 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 61 62 jLabelDesc = new javax.swing.JLabel (); 63 jLabelBuildName = new javax.swing.JLabel (); 64 jTextFieldBuildName = new javax.swing.JTextField (); 65 jLabelCreatedFile = new javax.swing.JLabel (); 66 jTextFieldCreatedFile = new javax.swing.JTextField (); 67 68 setLayout(new java.awt.GridBagLayout ()); 69 70 gridBagConstraints = new java.awt.GridBagConstraints (); 71 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 72 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 73 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 74 gridBagConstraints.insets = new java.awt.Insets (12, 12, 11, 11); 75 add(jLabelDesc, gridBagConstraints); 76 77 jLabelBuildName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildFilename_LabelMnemonic").charAt(0)); 78 jLabelBuildName.setLabelFor(jTextFieldBuildName); 79 jLabelBuildName.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_BuildFilename_Label")); 80 gridBagConstraints = new java.awt.GridBagConstraints (); 81 gridBagConstraints.gridx = 0; 82 gridBagConstraints.gridy = 1; 83 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 84 gridBagConstraints.insets = new java.awt.Insets (0, 12, 11, 11); 85 add(jLabelBuildName, gridBagConstraints); 86 87 gridBagConstraints = new java.awt.GridBagConstraints (); 88 gridBagConstraints.gridx = 1; 89 gridBagConstraints.gridy = 1; 90 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 91 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 92 gridBagConstraints.weightx = 1.0; 93 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 94 add(jTextFieldBuildName, gridBagConstraints); 95 jTextFieldBuildName.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "ACS_LBL_IW_BuildFilename_A11YDesc")); 96 97 jLabelCreatedFile.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_CreatedFile_LabelMnemonic").charAt(0)); 98 jLabelCreatedFile.setLabelFor(jTextFieldCreatedFile); 99 jLabelCreatedFile.setText(NbBundle.getMessage(ImportBuildfile.class, "LBL_IW_CreatedFile_Label")); 100 gridBagConstraints = new java.awt.GridBagConstraints (); 101 gridBagConstraints.gridx = 0; 102 gridBagConstraints.gridy = 2; 103 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 104 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 105 gridBagConstraints.weighty = 1.0; 106 gridBagConstraints.insets = new java.awt.Insets (0, 12, 11, 11); 107 add(jLabelCreatedFile, gridBagConstraints); 108 109 jTextFieldCreatedFile.setEditable(false); 110 gridBagConstraints = new java.awt.GridBagConstraints (); 111 gridBagConstraints.gridx = 1; 112 gridBagConstraints.gridy = 2; 113 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 114 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 115 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 116 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 117 gridBagConstraints.weighty = 1.0; 118 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 119 add(jTextFieldCreatedFile, gridBagConstraints); 120 jTextFieldCreatedFile.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportBuildfile.class, "ACS_LBL_IW_CreatedFile_A11YDesc")); 121 122 } 124 private javax.swing.JLabel jLabelBuildName; 126 private javax.swing.JLabel jLabelCreatedFile; 127 private javax.swing.JLabel jLabelDesc; 128 private javax.swing.JTextField jTextFieldBuildName; 129 private javax.swing.JTextField jTextFieldCreatedFile; 130 132 protected String getBuildName() { 133 return jTextFieldBuildName.getText().trim(); 134 } 135 136 public void changedUpdate(DocumentEvent e) { 138 updateButton(); 139 } 140 141 public void insertUpdate(DocumentEvent e) { 142 updateButton(); 143 } 144 145 public void removeUpdate(DocumentEvent e) { 146 updateButton(); 147 } 148 150 private void updateButton() { 151 jTextFieldCreatedFile.setText(filePath + File.separator + jTextFieldBuildName.getText()); 152 153 if (jTextFieldBuildName.getText().trim().length() == 0 || jTextFieldBuildName.getText().trim().equals(GeneratedFilesHelper.BUILD_XML_PATH)) 154 ok.setEnabled(false); 155 else 156 ok.setEnabled(true); 157 } 158 } 159 | Popular Tags |