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 javax.swing.JSpinner ; 25 import javax.swing.SpinnerNumberModel ; 26 import org.openide.DialogDescriptor; 27 import org.openide.DialogDisplayer; 28 import org.openide.util.NbBundle; 29 30 31 32 33 37 public class SELECTCustomizer extends javax.swing.JPanel { 38 39 private Dialog dialog = null; 40 private DialogDescriptor descriptor = null; 41 private boolean dialogOK = false; 42 43 SELECT select; 44 45 48 public SELECTCustomizer(SELECT select) { 49 this.select = select; 50 51 initComponents(); 52 } 53 54 public boolean showDialog() { 55 56 dialogOK = false; 57 58 String displayName = ""; 59 try { 60 displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-SELECT"); } 62 catch (Exception e) {} 63 64 descriptor = new DialogDescriptor 65 (this, NbBundle.getMessage(SELECTCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 66 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 67 new ActionListener () { 68 public void actionPerformed(ActionEvent e) { 69 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 70 evaluateInput(); 71 dialogOK = true; 72 } 73 dialog.dispose(); 74 } 75 } 76 ); 77 78 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 79 dialog.setVisible(true); 80 repaint(); 81 82 return dialogOK; 83 } 84 85 private void evaluateInput() { 86 87 String name = jTextField1.getText(); 88 select.setName(name); 89 90 int options = ((Integer )jSpinner1.getValue()).intValue(); 91 select.setOptions(options); 92 93 int optionsVisible = ((Integer )jSpinner2.getValue()).intValue(); 94 select.setOptionsVisible(optionsVisible); 95 96 select.setMultiple(jCheckBox1.isSelected()); 97 98 select.setDisabled(jCheckBox2.isSelected()); 99 100 } 101 102 107 private void initComponents() { 109 java.awt.GridBagConstraints gridBagConstraints; 110 111 jTextField1 = new javax.swing.JTextField (); 112 jLabel1 = new javax.swing.JLabel (); 113 jLabel3 = new javax.swing.JLabel (); 114 jLabel2 = new javax.swing.JLabel (); 115 jLabel4 = new javax.swing.JLabel (); 116 jCheckBox1 = new javax.swing.JCheckBox (); 117 jCheckBox2 = new javax.swing.JCheckBox (); 118 jSpinner1 = new javax.swing.JSpinner (); 119 jLabel5 = new javax.swing.JLabel (); 120 jSpinner2 = new javax.swing.JSpinner (); 121 122 setLayout(new java.awt.GridBagLayout ()); 123 124 jTextField1.setColumns(30); 125 gridBagConstraints = new java.awt.GridBagConstraints (); 126 gridBagConstraints.gridx = 1; 127 gridBagConstraints.gridy = 0; 128 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 129 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 130 gridBagConstraints.weightx = 1.0; 131 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 132 add(jTextField1, gridBagConstraints); 133 134 jLabel1.setLabelFor(jTextField1); 135 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_Name")); 136 gridBagConstraints = new java.awt.GridBagConstraints (); 137 gridBagConstraints.gridx = 0; 138 gridBagConstraints.gridy = 0; 139 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 140 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 141 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 142 add(jLabel1, gridBagConstraints); 143 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_Name")); 144 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_Name")); 145 146 jLabel3.setLabelFor(jSpinner2); 147 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_VisOptions")); 148 gridBagConstraints = new java.awt.GridBagConstraints (); 149 gridBagConstraints.gridx = 0; 150 gridBagConstraints.gridy = 2; 151 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 152 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 153 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 154 add(jLabel3, gridBagConstraints); 155 jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_VisOptions")); 156 jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_VisOptions")); 157 158 jLabel2.setLabelFor(jSpinner1); 159 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_Options")); 160 gridBagConstraints = new java.awt.GridBagConstraints (); 161 gridBagConstraints.gridx = 0; 162 gridBagConstraints.gridy = 1; 163 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 164 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 165 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 166 add(jLabel2, gridBagConstraints); 167 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_Options")); 168 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_Options")); 169 170 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_Multi")); 171 gridBagConstraints = new java.awt.GridBagConstraints (); 172 gridBagConstraints.gridx = 0; 173 gridBagConstraints.gridy = 3; 174 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 175 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 176 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 177 add(jLabel4, gridBagConstraints); 178 jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_Multi")); 179 jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_Multi")); 180 181 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_allowed")); 182 jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 183 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 184 gridBagConstraints = new java.awt.GridBagConstraints (); 185 gridBagConstraints.gridx = 1; 186 gridBagConstraints.gridy = 3; 187 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 188 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 189 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 190 add(jCheckBox1, gridBagConstraints); 191 jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_allowed")); 192 jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_allowed")); 193 194 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_disabled")); 195 jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 196 jCheckBox2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 197 gridBagConstraints = new java.awt.GridBagConstraints (); 198 gridBagConstraints.gridx = 1; 199 gridBagConstraints.gridy = 4; 200 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 201 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 202 gridBagConstraints.weighty = 1.0; 203 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 12); 204 add(jCheckBox2, gridBagConstraints); 205 jCheckBox2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_disabled")); 206 jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_disabled")); 207 208 jSpinner1.setModel(new SpinnerNumberModel (select.getOptions(), 0, Integer.MAX_VALUE, 1)); 209 jSpinner1.setEditor(new JSpinner.NumberEditor (jSpinner1, "#")); 210 jSpinner1.setValue(new Integer (select.getOptions())); 211 gridBagConstraints = new java.awt.GridBagConstraints (); 212 gridBagConstraints.gridx = 1; 213 gridBagConstraints.gridy = 1; 214 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 215 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 216 add(jSpinner1, gridBagConstraints); 217 218 org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_State")); 219 gridBagConstraints = new java.awt.GridBagConstraints (); 220 gridBagConstraints.gridx = 0; 221 gridBagConstraints.gridy = 4; 222 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 223 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 224 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 0); 225 add(jLabel5, gridBagConstraints); 226 jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_State")); 227 jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_State")); 228 229 jSpinner2.setModel(new SpinnerNumberModel (select.getOptionsVisible(), 1, Integer.MAX_VALUE, 1)); 230 jSpinner2.setEditor(new JSpinner.NumberEditor (jSpinner2, "#")); 231 jSpinner2.setValue(new Integer (select.getOptionsVisible())); 232 gridBagConstraints = new java.awt.GridBagConstraints (); 233 gridBagConstraints.gridx = 1; 234 gridBagConstraints.gridy = 2; 235 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 236 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 237 add(jSpinner2, gridBagConstraints); 238 239 } 241 242 private javax.swing.JCheckBox jCheckBox1; 244 private javax.swing.JCheckBox jCheckBox2; 245 private javax.swing.JLabel jLabel1; 246 private javax.swing.JLabel jLabel2; 247 private javax.swing.JLabel jLabel3; 248 private javax.swing.JLabel jLabel4; 249 private javax.swing.JLabel jLabel5; 250 private javax.swing.JSpinner jSpinner1; 251 private javax.swing.JSpinner jSpinner2; 252 private javax.swing.JTextField jTextField1; 253 255 } 256 | Popular Tags |