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 CHECKBOXCustomizer extends javax.swing.JPanel { 36 37 private Dialog dialog = null; 38 private DialogDescriptor descriptor = null; 39 private boolean dialogOK = false; 40 41 CHECKBOX checkbox; 42 43 public CHECKBOXCustomizer(CHECKBOX checkbox) { 44 this.checkbox = checkbox; 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-CHECKBOX"); } 57 catch (Exception e) {} 58 59 descriptor = new DialogDescriptor 60 (this, NbBundle.getMessage(CHECKBOXCustomizer.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 checkbox.setName(name); 84 85 String value = jTextField2.getText(); 86 checkbox.setValue(value); 87 88 checkbox.setSelected(jCheckBox1.isSelected()); 89 90 checkbox.setDisabled(jCheckBox2.isSelected()); 91 92 } 93 94 99 private void initComponents() { 101 java.awt.GridBagConstraints gridBagConstraints; 102 103 buttonGroup1 = new javax.swing.ButtonGroup (); 104 jTextField1 = new javax.swing.JTextField (); 105 jLabel1 = new javax.swing.JLabel (); 106 jLabel3 = new javax.swing.JLabel (); 107 jCheckBox1 = new javax.swing.JCheckBox (); 108 jCheckBox2 = new javax.swing.JCheckBox (); 109 jLabel5 = new javax.swing.JLabel (); 110 jTextField2 = new javax.swing.JTextField (); 111 jLabel2 = new javax.swing.JLabel (); 112 113 setLayout(new java.awt.GridBagLayout ()); 114 115 jTextField1.setColumns(30); 116 gridBagConstraints = new java.awt.GridBagConstraints (); 117 gridBagConstraints.gridx = 1; 118 gridBagConstraints.gridy = 0; 119 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 120 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 121 gridBagConstraints.weightx = 1.0; 122 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 123 add(jTextField1, gridBagConstraints); 124 125 jLabel1.setLabelFor(jTextField1); 126 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "LBL_CHECKBOX_Name")); 127 gridBagConstraints = new java.awt.GridBagConstraints (); 128 gridBagConstraints.gridx = 0; 129 gridBagConstraints.gridy = 0; 130 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 131 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 132 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 133 add(jLabel1, gridBagConstraints); 134 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSN_CHECKBOX_Name")); 135 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSD_CHECKBOX_Name")); 136 137 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "LBL_CHECKBOX_ValueHelp")); 138 gridBagConstraints = new java.awt.GridBagConstraints (); 139 gridBagConstraints.gridx = 1; 140 gridBagConstraints.gridy = 2; 141 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 142 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 143 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 144 add(jLabel3, gridBagConstraints); 145 jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSN_CHECKBOX_ValueHelp")); 146 jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSD_CHECKBOX_ValueHelp")); 147 148 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "LBL_CHECKBOX_selected")); 149 jCheckBox1.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 150 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 151 gridBagConstraints = new java.awt.GridBagConstraints (); 152 gridBagConstraints.gridx = 1; 153 gridBagConstraints.gridy = 3; 154 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 155 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 156 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 157 add(jCheckBox1, gridBagConstraints); 158 jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSN_CHECKBOX_selected")); 159 jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSD_CHECKBOX_selected")); 160 161 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "LBL_CHECKBOX_disabled")); 162 jCheckBox2.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (0, 0, 0, 0))); 163 jCheckBox2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 164 gridBagConstraints = new java.awt.GridBagConstraints (); 165 gridBagConstraints.gridx = 1; 166 gridBagConstraints.gridy = 4; 167 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 168 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 169 gridBagConstraints.weighty = 1.0; 170 gridBagConstraints.insets = new java.awt.Insets (5, 12, 12, 12); 171 add(jCheckBox2, gridBagConstraints); 172 jCheckBox2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSN_CHECKBOX_disabled")); 173 jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSD_CHECKBOX_disabled")); 174 175 org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "LBL_CHECKBOX_InitState")); 176 gridBagConstraints = new java.awt.GridBagConstraints (); 177 gridBagConstraints.gridx = 0; 178 gridBagConstraints.gridy = 3; 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(jLabel5, gridBagConstraints); 183 jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSN_CHECKBOX_InitState")); 184 jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSD_CHECKBOX_InitState")); 185 186 jTextField2.setColumns(30); 187 jTextField2.setText(checkbox.getValue()); 188 gridBagConstraints = new java.awt.GridBagConstraints (); 189 gridBagConstraints.gridx = 1; 190 gridBagConstraints.gridy = 1; 191 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 192 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 193 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 194 add(jTextField2, gridBagConstraints); 195 196 jLabel2.setLabelFor(jTextField2); 197 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "LBL_CHECKBOX_Value")); 198 gridBagConstraints = new java.awt.GridBagConstraints (); 199 gridBagConstraints.gridx = 0; 200 gridBagConstraints.gridy = 1; 201 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 202 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 203 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 204 add(jLabel2, gridBagConstraints); 205 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSN_CHECKBOX_Value")); 206 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CHECKBOXCustomizer.class, "ACSD_CHECKBOX_Value")); 207 208 } 209 211 212 private javax.swing.ButtonGroup buttonGroup1; 214 private javax.swing.JCheckBox jCheckBox1; 215 private javax.swing.JCheckBox jCheckBox2; 216 private javax.swing.JLabel jLabel1; 217 private javax.swing.JLabel jLabel2; 218 private javax.swing.JLabel jLabel3; 219 private javax.swing.JLabel jLabel5; 220 private javax.swing.JTextField jTextField1; 221 private javax.swing.JTextField jTextField2; 222 224 } 225 | Popular Tags |