1 19 20 package org.netbeans.modules.tomcat5.customizer; 21 import java.awt.Font ; 22 import java.io.File ; 23 import javax.accessibility.AccessibleContext ; 24 import javax.swing.JFileChooser ; 25 import javax.swing.JSpinner ; 26 import javax.swing.JTextField ; 27 import org.openide.util.NbBundle; 28 import org.openide.util.Utilities; 29 30 35 public class CustomizerStartup extends javax.swing.JPanel { 36 37 private CustomizerDataSupport custData; 38 39 40 public CustomizerStartup(CustomizerDataSupport custData) { 41 this.custData = custData; 42 initComponents(); 43 if (Utilities.isWindows()) { 44 jCheckBox4.setEnabled(false); 46 } else { 47 jRadioButton1.setEnabled(false); 49 jTextField4.setEnabled(false); 50 } 51 52 updateCustomScriptComponents(); 53 54 JTextField jSpinner1TextField = ((JSpinner.NumberEditor )jSpinner1.getEditor()).getTextField(); 55 56 AccessibleContext ac = jSpinner1TextField.getAccessibleContext(); 57 ac.setAccessibleName(NbBundle.getMessage(CustomizerStartup.class, "ACSN_SocketPortNum")); 58 ac.setAccessibleDescription(NbBundle.getMessage(CustomizerStartup.class, "ACSD_SocketPortNum")); 59 60 Font font = jTextField1.getFont(); 62 jSpinner1TextField.setFont(font); 63 64 jCheckBox1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_CustomScript").charAt(0)); 66 jCheckBox4.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_ForceShutdown").charAt(0)); 67 jRadioButton1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_SharedMemName").charAt(0)); 68 jRadioButton2.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_SocketPort").charAt(0)); 69 } 70 71 76 private void initComponents() { 78 java.awt.GridBagConstraints gridBagConstraints; 79 80 buttonGroup1 = new javax.swing.ButtonGroup (); 81 jLabel1 = new javax.swing.JLabel (); 82 jTextField1 = new javax.swing.JTextField (); 83 jCheckBox1 = new javax.swing.JCheckBox (); 84 jLabel4 = new javax.swing.JLabel (); 85 jCheckBox4 = new javax.swing.JCheckBox (); 86 jRadioButton1 = new javax.swing.JRadioButton (); 87 jRadioButton2 = new javax.swing.JRadioButton (); 88 jTextField4 = new javax.swing.JTextField (); 89 browseButton = new javax.swing.JButton (); 90 jLabel2 = new javax.swing.JLabel (); 91 jSpinner1 = new javax.swing.JSpinner (); 92 93 setLayout(new java.awt.GridBagLayout ()); 94 95 jLabel1.setLabelFor(jTextField1); 96 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_StartupScript")); 97 gridBagConstraints = new java.awt.GridBagConstraints (); 98 gridBagConstraints.gridx = 0; 99 gridBagConstraints.gridy = 1; 100 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 101 gridBagConstraints.insets = new java.awt.Insets (5, 17, 0, 0); 102 add(jLabel1, gridBagConstraints); 103 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_CatalinaScript")); 104 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_CatalinaScript")); 105 106 jTextField1.setColumns(20); 107 jTextField1.setDocument(custData.getScriptPathModel()); 108 gridBagConstraints = new java.awt.GridBagConstraints (); 109 gridBagConstraints.gridx = 1; 110 gridBagConstraints.gridy = 1; 111 gridBagConstraints.gridwidth = 2; 112 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 113 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 114 gridBagConstraints.weightx = 1.0; 115 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 0); 116 add(jTextField1, gridBagConstraints); 117 jTextField1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_Script")); 118 jTextField1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_Script")); 119 120 jCheckBox1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_CustomScript").charAt(0)); 121 jCheckBox1.setText(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_CustomScript")); 122 jCheckBox1.setModel(custData.getCustomScriptModel()); 123 jCheckBox1.addChangeListener(new javax.swing.event.ChangeListener () { 124 public void stateChanged(javax.swing.event.ChangeEvent evt) { 125 jCheckBox1StateChanged(evt); 126 } 127 }); 128 129 gridBagConstraints = new java.awt.GridBagConstraints (); 130 gridBagConstraints.gridx = 0; 131 gridBagConstraints.gridy = 0; 132 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 133 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 134 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 135 add(jCheckBox1, gridBagConstraints); 136 jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_CustomScript")); 137 jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_CustomScript")); 138 139 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_DebugTransport")); 140 gridBagConstraints = new java.awt.GridBagConstraints (); 141 gridBagConstraints.gridx = 0; 142 gridBagConstraints.gridy = 3; 143 gridBagConstraints.gridwidth = 2; 144 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 145 gridBagConstraints.insets = new java.awt.Insets (11, 12, 0, 0); 146 add(jLabel4, gridBagConstraints); 147 jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSN_DebugTrans")); 148 jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSN_DebugTrans")); 149 150 jCheckBox4.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_ForceShutdown").charAt(0)); 151 jCheckBox4.setText(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_ForceShutdown")); 152 jCheckBox4.setModel(custData.getForceStopModel()); 153 gridBagConstraints = new java.awt.GridBagConstraints (); 154 gridBagConstraints.gridx = 0; 155 gridBagConstraints.gridy = 2; 156 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 157 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 158 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 159 add(jCheckBox4, gridBagConstraints); 160 jCheckBox4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_ForceStop")); 161 jCheckBox4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_ForceStop")); 162 163 buttonGroup1.add(jRadioButton1); 164 jRadioButton1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_SharedMemName").charAt(0)); 165 jRadioButton1.setText(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_SharedMemName")); 166 jRadioButton1.setModel(custData.getSharedMemModel()); 167 gridBagConstraints = new java.awt.GridBagConstraints (); 168 gridBagConstraints.gridx = 0; 169 gridBagConstraints.gridy = 4; 170 gridBagConstraints.gridwidth = 2; 171 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 172 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 173 add(jRadioButton1, gridBagConstraints); 174 jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSN_SharedMem")); 175 jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSD_SharedMem")); 176 177 buttonGroup1.add(jRadioButton2); 178 jRadioButton2.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_SocketPort").charAt(0)); 179 jRadioButton2.setText(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_SocketPort")); 180 jRadioButton2.setModel(custData.getSocketModel()); 181 gridBagConstraints = new java.awt.GridBagConstraints (); 182 gridBagConstraints.gridx = 0; 183 gridBagConstraints.gridy = 5; 184 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 185 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 186 add(jRadioButton2, gridBagConstraints); 187 jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSN_SocketPort")); 188 jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSD_SocektPort")); 189 190 jTextField4.setColumns(15); 191 jTextField4.setDocument(custData.getSharedMemNameModel()); 192 gridBagConstraints = new java.awt.GridBagConstraints (); 193 gridBagConstraints.gridx = 2; 194 gridBagConstraints.gridy = 4; 195 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 196 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 197 gridBagConstraints.weightx = 1.0; 198 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 0); 199 add(jTextField4, gridBagConstraints); 200 jTextField4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSD_SharedMemName")); 201 202 org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_BrowseCatalinaScript")); 203 browseButton.setEnabled(false); 204 browseButton.addActionListener(new java.awt.event.ActionListener () { 205 public void actionPerformed(java.awt.event.ActionEvent evt) { 206 browseButtonActionPerformed(evt); 207 } 208 }); 209 210 gridBagConstraints = new java.awt.GridBagConstraints (); 211 gridBagConstraints.gridx = 3; 212 gridBagConstraints.gridy = 1; 213 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 214 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 12); 215 add(browseButton, gridBagConstraints); 216 browseButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_Browse")); 217 browseButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_Browse")); 218 219 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_NoteChangesTakeAffect")); 220 gridBagConstraints = new java.awt.GridBagConstraints (); 221 gridBagConstraints.gridx = 0; 222 gridBagConstraints.gridy = 6; 223 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 224 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 225 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 226 gridBagConstraints.weighty = 1.0; 227 gridBagConstraints.insets = new java.awt.Insets (5, 12, 12, 0); 228 add(jLabel2, gridBagConstraints); 229 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_Note")); 230 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_Note")); 231 232 jSpinner1.setFont(new java.awt.Font ("Dialog", 0, 12)); 233 jSpinner1.setModel(custData.getDebugPortModel()); 234 jSpinner1.setEditor(new JSpinner.NumberEditor (jSpinner1, "#")); 235 gridBagConstraints = new java.awt.GridBagConstraints (); 236 gridBagConstraints.gridx = 2; 237 gridBagConstraints.gridy = 5; 238 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 239 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 0); 240 add(jSpinner1, gridBagConstraints); 241 242 } 244 private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser; 246 File script = new File (jTextField1.getText().trim()); 247 File currentFolder = script.isDirectory() ? script 248 : script.getParentFile(); 249 if (currentFolder != null && currentFolder.exists()) { 250 chooser = new JFileChooser (currentFolder); 251 } else { 252 chooser = new JFileChooser (); 253 } 254 int returnVal = chooser.showOpenDialog(null); 255 if (returnVal == JFileChooser.APPROVE_OPTION) { 256 jTextField1.setText(chooser.getSelectedFile().getAbsolutePath()); 257 } 258 } 260 private void jCheckBox1StateChanged(javax.swing.event.ChangeEvent evt) { updateCustomScriptComponents(); 262 } 264 private void updateCustomScriptComponents() { 265 boolean enabled = jCheckBox1.isSelected(); 266 jLabel1.setEnabled(enabled); 267 jTextField1.setEnabled(enabled); 268 browseButton.setEnabled(enabled); 269 } 270 271 private javax.swing.JButton browseButton; 273 private javax.swing.ButtonGroup buttonGroup1; 274 private javax.swing.JCheckBox jCheckBox1; 275 private javax.swing.JCheckBox jCheckBox4; 276 private javax.swing.JLabel jLabel1; 277 private javax.swing.JLabel jLabel2; 278 private javax.swing.JLabel jLabel4; 279 private javax.swing.JRadioButton jRadioButton1; 280 private javax.swing.JRadioButton jRadioButton2; 281 private javax.swing.JSpinner jSpinner1; 282 private javax.swing.JTextField jTextField1; 283 private javax.swing.JTextField jTextField4; 284 286 } 287 | Popular Tags |