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 ULCustomizer extends javax.swing.JPanel { 37 38 private Dialog dialog = null; 39 private DialogDescriptor descriptor = null; 40 private boolean dialogOK = false; 41 42 UL ul; 43 44 47 public ULCustomizer(UL ul) { 48 this.ul = ul; 49 50 initComponents(); 51 52 if (ul.getType().equals(UL.DEFAULT)) 53 jRadioButton1.setSelected(true); 54 else if (ul.getType().equals(UL.DISC)) 55 jRadioButton2.setSelected(true); 56 else if (ul.getType().equals(UL.CIRCLE)) 57 jRadioButton3.setSelected(true); 58 else if (ul.getType().equals(UL.SQUARE)) 59 jRadioButton4.setSelected(true); 60 } 61 62 public boolean showDialog() { 63 64 dialogOK = false; 65 66 String displayName = ""; 67 try { 68 displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-UL"); } 70 catch (Exception e) {} 71 72 descriptor = new DialogDescriptor 73 (this, NbBundle.getMessage(ULCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 74 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 75 new ActionListener () { 76 public void actionPerformed(ActionEvent e) { 77 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 78 evaluateInput(); 79 dialogOK = true; 80 } 81 dialog.dispose(); 82 } 83 } 84 ); 85 86 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 87 dialog.setVisible(true); 88 89 return dialogOK; 90 } 91 92 private void evaluateInput() { 93 94 int count = ((Integer )jSpinner1.getValue()).intValue(); 95 ul.setCount(count); 96 97 String itemType = null; 98 99 if (jRadioButton1.isSelected()) 100 itemType = UL.DEFAULT; 101 if (jRadioButton2.isSelected()) 102 itemType = UL.DISC; 103 else if (jRadioButton3.isSelected()) 104 itemType = UL.CIRCLE; 105 else if (jRadioButton4.isSelected()) 106 itemType = UL.SQUARE; 107 108 ul.setType(itemType); 109 } 110 111 116 private void initComponents() { 118 java.awt.GridBagConstraints gridBagConstraints; 119 120 buttonGroup1 = new javax.swing.ButtonGroup (); 121 jLabel1 = new javax.swing.JLabel (); 122 jRadioButton1 = new javax.swing.JRadioButton (); 123 jRadioButton2 = new javax.swing.JRadioButton (); 124 jRadioButton3 = new javax.swing.JRadioButton (); 125 jRadioButton4 = new javax.swing.JRadioButton (); 126 jLabel2 = new javax.swing.JLabel (); 127 jSpinner1 = new javax.swing.JSpinner (); 128 129 setLayout(new java.awt.GridBagLayout ()); 130 131 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_Style")); 132 gridBagConstraints = new java.awt.GridBagConstraints (); 133 gridBagConstraints.gridx = 0; 134 gridBagConstraints.gridy = 1; 135 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 136 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 137 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 138 add(jLabel1, gridBagConstraints); 139 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_Style")); 140 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_Style")); 141 142 buttonGroup1.add(jRadioButton1); 143 jRadioButton1.setSelected(true); 144 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_default")); 145 jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 146 jRadioButton1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 147 gridBagConstraints = new java.awt.GridBagConstraints (); 148 gridBagConstraints.gridx = 1; 149 gridBagConstraints.gridy = 1; 150 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 151 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 152 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 18); 153 add(jRadioButton1, gridBagConstraints); 154 jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_default")); 155 jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_default")); 156 157 buttonGroup1.add(jRadioButton2); 158 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_disc")); 159 jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 160 jRadioButton2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 161 gridBagConstraints = new java.awt.GridBagConstraints (); 162 gridBagConstraints.gridx = 1; 163 gridBagConstraints.gridy = 2; 164 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 165 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 166 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 24); 167 add(jRadioButton2, gridBagConstraints); 168 jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_disc")); 169 jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_disc")); 170 171 buttonGroup1.add(jRadioButton3); 172 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton3, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_circle")); 173 jRadioButton3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 174 jRadioButton3.setMargin(new java.awt.Insets (0, 0, 0, 0)); 175 gridBagConstraints = new java.awt.GridBagConstraints (); 176 gridBagConstraints.gridx = 1; 177 gridBagConstraints.gridy = 3; 178 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 179 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 180 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 24); 181 add(jRadioButton3, gridBagConstraints); 182 jRadioButton3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_circle")); 183 jRadioButton3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_circle")); 184 185 buttonGroup1.add(jRadioButton4); 186 org.openide.awt.Mnemonics.setLocalizedText(jRadioButton4, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_square")); 187 jRadioButton4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 188 jRadioButton4.setMargin(new java.awt.Insets (0, 0, 0, 0)); 189 gridBagConstraints = new java.awt.GridBagConstraints (); 190 gridBagConstraints.gridx = 1; 191 gridBagConstraints.gridy = 4; 192 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 193 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 194 gridBagConstraints.weightx = 1.0; 195 gridBagConstraints.weighty = 1.0; 196 gridBagConstraints.insets = new java.awt.Insets (5, 12, 12, 24); 197 add(jRadioButton4, gridBagConstraints); 198 jRadioButton4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_square")); 199 jRadioButton4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_square")); 200 201 jLabel2.setLabelFor(jSpinner1); 202 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_Items")); 203 gridBagConstraints = new java.awt.GridBagConstraints (); 204 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 205 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 206 add(jLabel2, gridBagConstraints); 207 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_Items")); 208 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_Items")); 209 210 jSpinner1.setModel(new SpinnerNumberModel (ul.getCount(), 0, Integer.MAX_VALUE, 1)); 211 jSpinner1.setEditor(new JSpinner.NumberEditor (jSpinner1, "#")); 212 jSpinner1.setValue(new Integer (ul.getCount())); 213 gridBagConstraints = new java.awt.GridBagConstraints (); 214 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 215 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 18); 216 add(jSpinner1, gridBagConstraints); 217 218 } 220 221 private javax.swing.ButtonGroup buttonGroup1; 223 private javax.swing.JLabel jLabel1; 224 private javax.swing.JLabel jLabel2; 225 private javax.swing.JRadioButton jRadioButton1; 226 private javax.swing.JRadioButton jRadioButton2; 227 private javax.swing.JRadioButton jRadioButton3; 228 private javax.swing.JRadioButton jRadioButton4; 229 private javax.swing.JSpinner jSpinner1; 230 232 } 233 | Popular Tags |