1 19 20 package org.netbeans.modules.web.core.palette.items; 21 import java.awt.Dialog ; 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.ActionListener ; 24 import javax.swing.DefaultComboBoxModel ; 25 import javax.swing.text.JTextComponent ; 26 import org.openide.DialogDescriptor; 27 import org.openide.DialogDisplayer; 28 import org.openide.util.NbBundle; 29 30 31 32 33 34 38 public class ForEachCustomizer extends javax.swing.JPanel { 39 40 private Dialog dialog = null; 41 private DialogDescriptor descriptor = null; 42 private boolean dialogOK = false; 43 44 ForEach forEach; 45 JTextComponent target; 46 47 public ForEachCustomizer(ForEach forEach, JTextComponent target) { 48 this.forEach = forEach; 49 this.target = target; 50 51 initComponents(); 52 53 } 54 55 public boolean showDialog() { 56 57 dialogOK = false; 58 59 String displayName = ""; 60 try { 61 displayName = NbBundle.getBundle("org.netbeans.modules.web.core.palette.items.resources.Bundle").getString("NAME_jsp-ForEach"); } 63 catch (Exception e) {} 64 65 descriptor = new DialogDescriptor 66 (this, NbBundle.getMessage(ForEachCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 67 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 68 new ActionListener () { 69 public void actionPerformed(ActionEvent e) { 70 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 71 evaluateInput(); 72 dialogOK = true; 73 } 74 dialog.dispose(); 75 } 76 } 77 ); 78 79 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 80 dialog.setVisible(true); 81 repaint(); 82 83 return dialogOK; 84 } 85 86 private void evaluateInput() { 87 88 89 String collection = jTextField1.getText(); 90 forEach.setCollection(collection); 91 92 String variable = jTextField2.getText(); 93 forEach.setVariable(variable); 94 95 forEach.setFixed(jCheckBox1.isSelected()); 96 97 String begin = jTextField3.getText(); 98 forEach.setBegin(begin); 99 100 String end = jTextField4.getText(); 101 forEach.setEnd(end); 102 103 String step = jTextField5.getText(); 104 forEach.setStep(step); 105 106 } 107 108 113 private void initComponents() { 115 java.awt.GridBagConstraints gridBagConstraints; 116 117 jFileChooser1 = new javax.swing.JFileChooser (); 118 jTextField1 = new javax.swing.JTextField (); 119 jLabel1 = new javax.swing.JLabel (); 120 jTextField2 = new javax.swing.JTextField (); 121 jLabel5 = new javax.swing.JLabel (); 122 jCheckBox1 = new javax.swing.JCheckBox (); 123 jLabel3 = new javax.swing.JLabel (); 124 jLabel6 = new javax.swing.JLabel (); 125 jLabel7 = new javax.swing.JLabel (); 126 jTextField3 = new javax.swing.JTextField (); 127 jTextField4 = new javax.swing.JTextField (); 128 jTextField5 = new javax.swing.JTextField (); 129 130 jFileChooser1.setCurrentDirectory(null); 131 132 setLayout(new java.awt.GridBagLayout ()); 133 134 jTextField1.setColumns(35); 135 gridBagConstraints = new java.awt.GridBagConstraints (); 136 gridBagConstraints.gridx = 1; 137 gridBagConstraints.gridy = 0; 138 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 139 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 140 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 141 add(jTextField1, gridBagConstraints); 142 143 jLabel1.setLabelFor(jTextField1); 144 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "LBL_ForEach_Collection")); 145 gridBagConstraints = new java.awt.GridBagConstraints (); 146 gridBagConstraints.gridx = 0; 147 gridBagConstraints.gridy = 0; 148 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 149 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 150 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 151 add(jLabel1, gridBagConstraints); 152 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSN_ForEach_Collection")); 153 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSD_ForEach_Collection")); 154 155 gridBagConstraints = new java.awt.GridBagConstraints (); 156 gridBagConstraints.gridx = 1; 157 gridBagConstraints.gridy = 1; 158 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 159 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 160 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 161 add(jTextField2, gridBagConstraints); 162 163 jLabel5.setLabelFor(jTextField2); 164 org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "LBL_ForEach_VariableHelp")); 165 gridBagConstraints = new java.awt.GridBagConstraints (); 166 gridBagConstraints.gridx = 0; 167 gridBagConstraints.gridy = 1; 168 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 169 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 170 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 171 add(jLabel5, gridBagConstraints); 172 jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSN_ForEach_VariableHelp")); 173 jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSD_ForEach_VariableHelp")); 174 175 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "LBL_ForEach_Fixed")); 176 jCheckBox1.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 177 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 178 jCheckBox1.addItemListener(new java.awt.event.ItemListener () { 179 public void itemStateChanged(java.awt.event.ItemEvent evt) { 180 jCheckBox1ItemStateChanged(evt); 181 } 182 }); 183 184 gridBagConstraints = new java.awt.GridBagConstraints (); 185 gridBagConstraints.gridx = 0; 186 gridBagConstraints.gridy = 2; 187 gridBagConstraints.gridwidth = 2; 188 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 189 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 190 add(jCheckBox1, gridBagConstraints); 191 jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSN_ForEach_Fixed")); 192 jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSD_ForEach_Fixed")); 193 194 jLabel3.setLabelFor(jTextField3); 195 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "LBL_ForEach_Begin")); 196 gridBagConstraints = new java.awt.GridBagConstraints (); 197 gridBagConstraints.gridx = 0; 198 gridBagConstraints.gridy = 3; 199 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 200 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 201 gridBagConstraints.insets = new java.awt.Insets (12, 24, 0, 0); 202 add(jLabel3, gridBagConstraints); 203 jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSN_ForEach_Begin")); 204 jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSD_ForEach_Begin")); 205 206 jLabel6.setLabelFor(jTextField4); 207 org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "LBL_ForEach_End")); 208 gridBagConstraints = new java.awt.GridBagConstraints (); 209 gridBagConstraints.gridx = 0; 210 gridBagConstraints.gridy = 4; 211 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 212 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 213 gridBagConstraints.insets = new java.awt.Insets (5, 24, 0, 0); 214 add(jLabel6, gridBagConstraints); 215 jLabel6.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSN_ForEach_End")); 216 jLabel6.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSD_ForEach_End")); 217 218 jLabel7.setLabelFor(jTextField5); 219 org.openide.awt.Mnemonics.setLocalizedText(jLabel7, org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "LBL_ForEach_Step")); 220 gridBagConstraints = new java.awt.GridBagConstraints (); 221 gridBagConstraints.gridx = 0; 222 gridBagConstraints.gridy = 5; 223 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 224 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 225 gridBagConstraints.weightx = 1.0; 226 gridBagConstraints.weighty = 1.0; 227 gridBagConstraints.insets = new java.awt.Insets (5, 24, 12, 0); 228 add(jLabel7, gridBagConstraints); 229 jLabel7.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSN_ForEach_Step")); 230 jLabel7.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ForEachCustomizer.class, "ACSD_ForEach_Step")); 231 232 jTextField3.setEditable(false); 233 gridBagConstraints = new java.awt.GridBagConstraints (); 234 gridBagConstraints.gridx = 1; 235 gridBagConstraints.gridy = 3; 236 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 237 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 238 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 239 add(jTextField3, gridBagConstraints); 240 241 jTextField4.setEditable(false); 242 gridBagConstraints = new java.awt.GridBagConstraints (); 243 gridBagConstraints.gridx = 1; 244 gridBagConstraints.gridy = 4; 245 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 246 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 247 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 248 add(jTextField4, gridBagConstraints); 249 250 jTextField5.setEditable(false); 251 gridBagConstraints = new java.awt.GridBagConstraints (); 252 gridBagConstraints.gridx = 1; 253 gridBagConstraints.gridy = 5; 254 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 255 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 256 gridBagConstraints.insets = new java.awt.Insets (5, 12, 12, 12); 257 add(jTextField5, gridBagConstraints); 258 259 } 260 262 private void jCheckBox1ItemStateChanged(java.awt.event.ItemEvent evt) { 264 if (jCheckBox1.isSelected()) { 265 jTextField3.setEditable(true); 266 jTextField4.setEditable(true); 267 jTextField5.setEditable(true); 268 } 269 else { 270 jTextField3.setEditable(false); 271 jTextField4.setEditable(false); 272 jTextField5.setEditable(false); 273 } 274 } 276 277 private javax.swing.JCheckBox jCheckBox1; 279 private javax.swing.JFileChooser jFileChooser1; 280 private javax.swing.JLabel jLabel1; 281 private javax.swing.JLabel jLabel3; 282 private javax.swing.JLabel jLabel5; 283 private javax.swing.JLabel jLabel6; 284 private javax.swing.JLabel jLabel7; 285 private javax.swing.JTextField jTextField1; 286 private javax.swing.JTextField jTextField2; 287 private javax.swing.JTextField jTextField3; 288 private javax.swing.JTextField jTextField4; 289 private javax.swing.JTextField jTextField5; 290 292 } 293 | Popular Tags |