1 19 20 package org.netbeans.modules.html.palette.items; 21 import java.awt.Dialog ; 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.ActionListener ; 24 import org.openide.DialogDescriptor; 25 import org.openide.DialogDisplayer; 26 import org.openide.util.NbBundle; 27 28 29 30 31 35 public class INPUTCustomizer extends javax.swing.JPanel { 36 37 private Dialog dialog = null; 38 private DialogDescriptor descriptor = null; 39 private boolean dialogOK = false; 40 41 INPUT input; 42 43 public INPUTCustomizer(INPUT input) { 44 this.input = input; 45 46 initComponents(); 47 } 48 49 public boolean showDialog() { 50 51 dialogOK = false; 52 53 String displayName = ""; 54 try { 55 displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-INPUT"); } 57 catch (Exception e) {} 58 59 descriptor = new DialogDescriptor 60 (this, NbBundle.getMessage(INPUTCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 61 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 62 new ActionListener () { 63 public void actionPerformed(ActionEvent e) { 64 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 65 evaluateInput(); 66 dialogOK = true; 67 } 68 dialog.dispose(); 69 } 70 } 71 ); 72 73 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 74 dialog.setVisible(true); 75 repaint(); 76 77 return dialogOK; 78 } 79 80 private void evaluateInput() { 81 82 String name = jTextField1.getText(); 83 input.setName(name); 84 85 String value = jTextField2.getText(); 86 input.setValue(value); 87 88 if (jRadioButton1.isSelected()) 89 input.setType(INPUT.TYPE_TEXT); 90 if (jRadioButton2.isSelected()) 91 input.setType(INPUT.TYPE_PASS); 92 else if (jRadioButton3.isSelected()) 93 input.setType(INPUT.TYPE_HIDDEN); 94 95 input.setDisabled(jCheckBox1.isSelected()); 96 input.setReadonly(jCheckBox2.isSelected()); 97 98 String width = jTextField4.getText(); 99 input.setWidth(width); 100 } 101 102 107 private void initComponents() { 109 java.awt.GridBagConstraints gridBagConstraints; 110 111 buttonGroup1 = new javax.swing.ButtonGroup (); 112 jLabel4 = new javax.swing.JLabel (); 113 jTextField1 = new javax.swing.JTextField (); 114 jLabel1 = new javax.swing.JLabel (); 115 jLabel2 = new javax.swing.JLabel (); 116 jLabel3 = new javax.swing.JLabel (); 117 jTextField4 = new javax.swing.JTextField (); 118 jRadioButton1 = new javax.swing.JRadioButton (); 119 jRadioButton2 = new javax.swing.JRadioButton (); 120 jRadioButton3 = new javax.swing.JRadioButton (); 121 jCheckBox1 = new javax.swing.JCheckBox (); 122 jCheckBox2 = new javax.swing.JCheckBox (); 123 jLabel5 = new javax.swing.JLabel (); 124 jTextField2 = new javax.swing.JTextField (); 125 126 setLayout(new java.awt.GridBagLayout ()); 127 128 jLabel4.setLabelFor(jTextField4); 129 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_Width")); 130 gridBagConstraints = new java.awt.GridBagConstraints (); 131 gridBagConstraints.gridx = 0; 132 gridBagConstraints.gridy = 7; 133 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 134 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 135 gridBagConstraints.weighty = 1.0; 136 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 0); 137 add(jLabel4, gridBagConstraints); 138 jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_Width")); 139 jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_Width")); 140 141 jTextField1.setColumns(30); 142 gridBagConstraints = new java.awt.GridBagConstraints (); 143 gridBagConstraints.gridx = 1; 144 gridBagConstraints.gridy = 0; 145 gridBagConstraints.gridwidth = 2; 146 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 147 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 148 gridBagConstraints.weightx = 1.0; 149 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 150 add(jTextField1, gridBagConstraints); 151 152 jLabel1.setLabelFor(jTextField1); 153 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_Name")); 154 gridBagConstraints = new java.awt.GridBagConstraints (); 155 gridBagConstraints.gridx = 0; 156 gridBagConstraints.gridy = 0; 157 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 158 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 159 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 160 add(jLabel1, gridBagConstraints); 161 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_Name")); 162 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_Name")); 163 164 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_Type")); 165 gridBagConstraints = new java.awt.GridBagConstraints (); 166 gridBagConstraints.gridx = 0; 167 gridBagConstraints.gridy = 2; 168 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 169 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 170 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 171 add(jLabel2, gridBagConstraints); 172 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_Type")); 173 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_Type")); 174 175 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_State")); 176 gridBagConstraints = new java.awt.GridBagConstraints (); 177 gridBagConstraints.gridx = 0; 178 gridBagConstraints.gridy = 5; 179 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 180 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 181 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 182 add(jLabel3, gridBagConstraints); 183 jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_State")); 184 jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_state")); 185 186 gridBagConstraints = new java.awt.GridBagConstraints (); 187 gridBagConstraints.gridx = 1; 188 gridBagConstraints.gridy = 7; 189 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 190 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 191 gridBagConstraints.weighty = 1.0; 192 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 12); 193 add(jTextField4, gridBagConstraints); 194 195 buttonGroup1.add(jRadioButton1); 196 jRadioButton1.setSelected(true); 197 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_text")); 198 jRadioButton1.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 199 jRadioButton1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 200 gridBagConstraints = new java.awt.GridBagConstraints (); 201 gridBagConstraints.gridx = 1; 202 gridBagConstraints.gridy = 2; 203 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 204 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 205 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 206 add(jRadioButton1, gridBagConstraints); 207 jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_text")); 208 jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_text")); 209 210 buttonGroup1.add(jRadioButton2); 211 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_password")); 212 jRadioButton2.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 213 jRadioButton2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 214 gridBagConstraints = new java.awt.GridBagConstraints (); 215 gridBagConstraints.gridx = 1; 216 gridBagConstraints.gridy = 3; 217 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 218 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 219 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 220 add(jRadioButton2, gridBagConstraints); 221 jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_password")); 222 jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_password")); 223 224 buttonGroup1.add(jRadioButton3); 225 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton3, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_hidden")); 226 jRadioButton3.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 227 jRadioButton3.setMargin(new java.awt.Insets (0, 0, 0, 0)); 228 gridBagConstraints = new java.awt.GridBagConstraints (); 229 gridBagConstraints.gridx = 1; 230 gridBagConstraints.gridy = 4; 231 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 232 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 233 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 234 add(jRadioButton3, gridBagConstraints); 235 jRadioButton3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_hidden")); 236 jRadioButton3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_hidden")); 237 238 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_disabled")); 239 jCheckBox1.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 240 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 241 gridBagConstraints = new java.awt.GridBagConstraints (); 242 gridBagConstraints.gridx = 1; 243 gridBagConstraints.gridy = 5; 244 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 245 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 246 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 247 add(jCheckBox1, gridBagConstraints); 248 jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_disabled")); 249 jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_disabled")); 250 251 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_readonly")); 252 jCheckBox2.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 253 jCheckBox2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 254 gridBagConstraints = new java.awt.GridBagConstraints (); 255 gridBagConstraints.gridx = 1; 256 gridBagConstraints.gridy = 6; 257 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 258 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 259 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 260 add(jCheckBox2, gridBagConstraints); 261 jCheckBox2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_readonly")); 262 jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_readonly")); 263 264 jLabel5.setLabelFor(jTextField2); 265 org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_Value")); 266 gridBagConstraints = new java.awt.GridBagConstraints (); 267 gridBagConstraints.gridx = 0; 268 gridBagConstraints.gridy = 1; 269 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 270 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 271 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 272 add(jLabel5, gridBagConstraints); 273 jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_Value")); 274 jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_Value")); 275 276 jTextField2.setColumns(30); 277 gridBagConstraints = new java.awt.GridBagConstraints (); 278 gridBagConstraints.gridx = 1; 279 gridBagConstraints.gridy = 1; 280 gridBagConstraints.gridwidth = 2; 281 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 282 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 283 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 284 add(jTextField2, gridBagConstraints); 285 286 } 287 289 290 private javax.swing.ButtonGroup buttonGroup1; 292 private javax.swing.JCheckBox jCheckBox1; 293 private javax.swing.JCheckBox jCheckBox2; 294 private javax.swing.JLabel jLabel1; 295 private javax.swing.JLabel jLabel2; 296 private javax.swing.JLabel jLabel3; 297 private javax.swing.JLabel jLabel4; 298 private javax.swing.JLabel jLabel5; 299 private javax.swing.JRadioButton jRadioButton1; 300 private javax.swing.JRadioButton jRadioButton2; 301 private javax.swing.JRadioButton jRadioButton3; 302 private javax.swing.JTextField jTextField1; 303 private javax.swing.JTextField jTextField2; 304 private javax.swing.JTextField jTextField4; 305 307 } 308 | Popular Tags |