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 36 public class OLCustomizer extends javax.swing.JPanel { 37 38 private Dialog dialog = null; 39 private DialogDescriptor descriptor = null; 40 private boolean dialogOK = false; 41 42 OL ol; 43 44 47 public OLCustomizer(OL ol) { 48 this.ol = ol; 49 50 initComponents(); 51 52 if (ol.getType().equals(OL.DEFAULT)) 53 jRadioButton1.setSelected(true); 54 else if (ol.getType().equals(OL.ARABIC_NUMBERS)) 55 jRadioButton2.setSelected(true); 56 else if (ol.getType().equals(OL.LOWER_ALPHA)) 57 jRadioButton3.setSelected(true); 58 else if (ol.getType().equals(OL.UPPER_ALPHA)) 59 jRadioButton4.setSelected(true); 60 else if (ol.getType().equals(OL.LOWER_ROMAN)) 61 jRadioButton5.setSelected(true); 62 else if (ol.getType().equals(OL.UPPER_ROMAN)) 63 jRadioButton6.setSelected(true); 64 } 65 66 public boolean showDialog() { 67 68 dialogOK = false; 69 70 String displayName = ""; 71 try { 72 displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-OL"); } 74 catch (Exception e) {} 75 76 descriptor = new DialogDescriptor 77 (this, NbBundle.getMessage(OLCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 78 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 79 new ActionListener () { 80 public void actionPerformed(ActionEvent e) { 81 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 82 evaluateInput(); 83 dialogOK = true; 84 } 85 dialog.dispose(); 86 } 87 } 88 ); 89 90 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 91 dialog.setVisible(true); 92 93 return dialogOK; 94 } 95 96 private void evaluateInput() { 97 98 int count = ((Integer )jSpinner1.getValue()).intValue(); 99 ol.setCount(count); 100 101 String itemType = null; 102 103 if (jRadioButton1.isSelected()) 104 itemType = OL.DEFAULT; 105 if (jRadioButton2.isSelected()) 106 itemType = OL.ARABIC_NUMBERS; 107 else if (jRadioButton3.isSelected()) 108 itemType = OL.LOWER_ALPHA; 109 else if (jRadioButton4.isSelected()) 110 itemType = OL.UPPER_ALPHA; 111 else if (jRadioButton5.isSelected()) 112 itemType = OL.LOWER_ROMAN; 113 else if (jRadioButton6.isSelected()) 114 itemType = OL.UPPER_ROMAN; 115 116 ol.setType(itemType); 117 } 118 119 124 private void initComponents() { 126 java.awt.GridBagConstraints gridBagConstraints; 127 128 buttonGroup1 = new javax.swing.ButtonGroup (); 129 jLabel1 = new javax.swing.JLabel (); 130 jRadioButton1 = new javax.swing.JRadioButton (); 131 jRadioButton2 = new javax.swing.JRadioButton (); 132 jRadioButton3 = new javax.swing.JRadioButton (); 133 jRadioButton4 = new javax.swing.JRadioButton (); 134 jRadioButton5 = new javax.swing.JRadioButton (); 135 jRadioButton6 = new javax.swing.JRadioButton (); 136 jLabel2 = new javax.swing.JLabel (); 137 jSpinner1 = new javax.swing.JSpinner (); 138 139 setLayout(new java.awt.GridBagLayout ()); 140 141 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(OLCustomizer.class, "LBL_OL_Style")); 142 gridBagConstraints = new java.awt.GridBagConstraints (); 143 gridBagConstraints.gridx = 0; 144 gridBagConstraints.gridy = 1; 145 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 146 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 147 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 148 add(jLabel1, gridBagConstraints); 149 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_Style")); 150 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_Style")); 151 152 buttonGroup1.add(jRadioButton1); 153 jRadioButton1.setSelected(true); 154 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1, org.openide.util.NbBundle.getMessage(OLCustomizer.class, "LBL_OL_default")); 155 jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 156 jRadioButton1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 157 gridBagConstraints = new java.awt.GridBagConstraints (); 158 gridBagConstraints.gridx = 1; 159 gridBagConstraints.gridy = 1; 160 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 161 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 162 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 18); 163 add(jRadioButton1, gridBagConstraints); 164 jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_default")); 165 jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_default")); 166 167 buttonGroup1.add(jRadioButton2); 168 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, "1, 2, 3, ..."); 169 jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 170 jRadioButton2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 171 gridBagConstraints = new java.awt.GridBagConstraints (); 172 gridBagConstraints.gridx = 1; 173 gridBagConstraints.gridy = 2; 174 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 175 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 176 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 24); 177 add(jRadioButton2, gridBagConstraints); 178 jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_arabic")); 179 jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_arabicnumbers")); 180 181 buttonGroup1.add(jRadioButton3); 182 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton3, "a, b, c, ..."); 183 jRadioButton3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 184 jRadioButton3.setMargin(new java.awt.Insets (0, 0, 0, 0)); 185 gridBagConstraints = new java.awt.GridBagConstraints (); 186 gridBagConstraints.gridx = 1; 187 gridBagConstraints.gridy = 3; 188 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 189 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 190 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 24); 191 add(jRadioButton3, gridBagConstraints); 192 jRadioButton3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_loweralpha")); 193 jRadioButton3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_loweralpha")); 194 195 buttonGroup1.add(jRadioButton4); 196 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton4, "A, B, C, ..."); 197 jRadioButton4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 198 jRadioButton4.setMargin(new java.awt.Insets (0, 0, 0, 0)); 199 gridBagConstraints = new java.awt.GridBagConstraints (); 200 gridBagConstraints.gridx = 1; 201 gridBagConstraints.gridy = 4; 202 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 203 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 204 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 24); 205 add(jRadioButton4, gridBagConstraints); 206 jRadioButton4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_upperalpha")); 207 jRadioButton4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_upperalpha")); 208 209 buttonGroup1.add(jRadioButton5); 210 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton5, "i, ii, iii, ..."); 211 jRadioButton5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 212 jRadioButton5.setMargin(new java.awt.Insets (0, 0, 0, 0)); 213 gridBagConstraints = new java.awt.GridBagConstraints (); 214 gridBagConstraints.gridx = 1; 215 gridBagConstraints.gridy = 5; 216 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 217 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 218 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 24); 219 add(jRadioButton5, gridBagConstraints); 220 jRadioButton5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_lowerroman")); 221 jRadioButton5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_lowerroman")); 222 223 buttonGroup1.add(jRadioButton6); 224 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton6, "I, II, III, ..."); 225 jRadioButton6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 226 jRadioButton6.setMargin(new java.awt.Insets (0, 0, 0, 0)); 227 gridBagConstraints = new java.awt.GridBagConstraints (); 228 gridBagConstraints.gridx = 1; 229 gridBagConstraints.gridy = 6; 230 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 231 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 232 gridBagConstraints.weightx = 1.0; 233 gridBagConstraints.weighty = 1.0; 234 gridBagConstraints.insets = new java.awt.Insets (5, 12, 12, 24); 235 add(jRadioButton6, gridBagConstraints); 236 jRadioButton6.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_upperroman")); 237 jRadioButton6.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_upperroman")); 238 239 jLabel2.setLabelFor(jSpinner1); 240 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(OLCustomizer.class, "LBL_OL_Items")); 241 gridBagConstraints = new java.awt.GridBagConstraints (); 242 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 243 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 244 add(jLabel2, gridBagConstraints); 245 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_Items")); 246 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_Items")); 247 248 jSpinner1.setModel(new SpinnerNumberModel (ol.getCount(), 0, Integer.MAX_VALUE, 1)); 249 jSpinner1.setEditor(new JSpinner.NumberEditor (jSpinner1, "#")); 250 jSpinner1.setValue(new Integer (ol.getCount())); 251 gridBagConstraints = new java.awt.GridBagConstraints (); 252 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 253 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 18); 254 add(jSpinner1, gridBagConstraints); 255 256 } 258 259 private javax.swing.ButtonGroup buttonGroup1; 261 private javax.swing.JLabel jLabel1; 262 private javax.swing.JLabel jLabel2; 263 private javax.swing.JRadioButton jRadioButton1; 264 private javax.swing.JRadioButton jRadioButton2; 265 private javax.swing.JRadioButton jRadioButton3; 266 private javax.swing.JRadioButton jRadioButton4; 267 private javax.swing.JRadioButton jRadioButton5; 268 private javax.swing.JRadioButton jRadioButton6; 269 private javax.swing.JSpinner jSpinner1; 270 272 } 273 | Popular Tags |