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 TEXTAREACustomizer extends javax.swing.JPanel { 38 39 private Dialog dialog = null; 40 private DialogDescriptor descriptor = null; 41 private boolean dialogOK = false; 42 43 TEXTAREA textArea; 44 45 48 public TEXTAREACustomizer(TEXTAREA textArea) { 49 this.textArea = textArea; 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-TEXTAREA"); } 62 catch (Exception e) {} 63 64 descriptor = new DialogDescriptor 65 (this, NbBundle.getMessage(TEXTAREACustomizer.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 textArea.setName(name); 89 90 String value = jTextArea1.getText(); 91 textArea.setValue(value); 92 93 textArea.setDisabled(jCheckBox1.isSelected()); 94 textArea.setReadonly(jCheckBox2.isSelected()); 95 96 int rows = ((Integer )jSpinner1.getValue()).intValue(); 97 textArea.setRows(rows); 98 99 int cols = ((Integer )jSpinner2.getValue()).intValue(); 100 textArea.setCols(cols); 101 102 } 103 104 109 private void initComponents() { 111 java.awt.GridBagConstraints gridBagConstraints; 112 113 jLabel4 = new javax.swing.JLabel (); 114 jTextField1 = new javax.swing.JTextField (); 115 jLabel1 = new javax.swing.JLabel (); 116 jLabel3 = new javax.swing.JLabel (); 117 jCheckBox1 = new javax.swing.JCheckBox (); 118 jCheckBox2 = new javax.swing.JCheckBox (); 119 jLabel5 = new javax.swing.JLabel (); 120 jSpinner1 = new javax.swing.JSpinner (); 121 jSpinner2 = new javax.swing.JSpinner (); 122 jLabel2 = new javax.swing.JLabel (); 123 jScrollPane1 = new javax.swing.JScrollPane (); 124 jTextArea1 = new javax.swing.JTextArea (); 125 126 setLayout(new java.awt.GridBagLayout ()); 127 128 jLabel4.setLabelFor(jSpinner1); 129 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_Rows")); 130 gridBagConstraints = new java.awt.GridBagConstraints (); 131 gridBagConstraints.gridx = 0; 132 gridBagConstraints.gridy = 4; 133 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 134 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 135 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 136 add(jLabel4, gridBagConstraints); 137 jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_Rows")); 138 jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_Rows")); 139 140 jTextField1.setColumns(30); 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridx = 1; 143 gridBagConstraints.gridy = 0; 144 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 145 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 146 gridBagConstraints.weightx = 1.0; 147 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 148 add(jTextField1, gridBagConstraints); 149 150 jLabel1.setLabelFor(jTextField1); 151 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_Name")); 152 gridBagConstraints = new java.awt.GridBagConstraints (); 153 gridBagConstraints.gridx = 0; 154 gridBagConstraints.gridy = 0; 155 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 156 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 157 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 158 add(jLabel1, gridBagConstraints); 159 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_Name")); 160 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_Name")); 161 162 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_State")); 163 gridBagConstraints = new java.awt.GridBagConstraints (); 164 gridBagConstraints.gridx = 0; 165 gridBagConstraints.gridy = 2; 166 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 167 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 168 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 169 add(jLabel3, gridBagConstraints); 170 jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_State")); 171 jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_State")); 172 173 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_disabled")); 174 jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 175 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 176 gridBagConstraints = new java.awt.GridBagConstraints (); 177 gridBagConstraints.gridx = 1; 178 gridBagConstraints.gridy = 2; 179 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 180 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 181 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 182 add(jCheckBox1, gridBagConstraints); 183 jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_disabled")); 184 jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_disabled")); 185 186 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_readonly")); 187 jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 188 jCheckBox2.setMargin(new java.awt.Insets (0, 0, 0, 0)); 189 gridBagConstraints = new java.awt.GridBagConstraints (); 190 gridBagConstraints.gridx = 1; 191 gridBagConstraints.gridy = 3; 192 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 193 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 194 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 195 add(jCheckBox2, gridBagConstraints); 196 jCheckBox2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_readonly")); 197 jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_readonly")); 198 199 jLabel5.setLabelFor(jSpinner2); 200 org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_Columns")); 201 gridBagConstraints = new java.awt.GridBagConstraints (); 202 gridBagConstraints.gridx = 0; 203 gridBagConstraints.gridy = 5; 204 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 205 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 206 gridBagConstraints.insets = new java.awt.Insets (5, 12, 12, 0); 207 add(jLabel5, gridBagConstraints); 208 jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_Columns")); 209 jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_Columns")); 210 211 jSpinner1.setModel(new SpinnerNumberModel (textArea.getRows(), 1, Integer.MAX_VALUE, 1)); 212 jSpinner1.setEditor(new JSpinner.NumberEditor (jSpinner1, "#")); 213 jSpinner1.setValue(new Integer (textArea.getRows())); 214 gridBagConstraints = new java.awt.GridBagConstraints (); 215 gridBagConstraints.gridx = 1; 216 gridBagConstraints.gridy = 4; 217 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 218 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 219 add(jSpinner1, gridBagConstraints); 220 221 jSpinner2.setModel(new SpinnerNumberModel (textArea.getCols(), 1, Integer.MAX_VALUE, 1)); 222 jSpinner2.setEditor(new JSpinner.NumberEditor (jSpinner2, "#")); 223 jSpinner2.setValue(new Integer (textArea.getCols())); 224 gridBagConstraints = new java.awt.GridBagConstraints (); 225 gridBagConstraints.gridx = 1; 226 gridBagConstraints.gridy = 5; 227 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 228 gridBagConstraints.weightx = 1.0; 229 gridBagConstraints.weighty = 1.0; 230 gridBagConstraints.insets = new java.awt.Insets (5, 12, 12, 12); 231 add(jSpinner2, gridBagConstraints); 232 233 jLabel2.setLabelFor(jTextArea1); 234 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_Value")); 235 gridBagConstraints = new java.awt.GridBagConstraints (); 236 gridBagConstraints.gridx = 0; 237 gridBagConstraints.gridy = 1; 238 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 239 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 240 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 241 add(jLabel2, gridBagConstraints); 242 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_Value")); 243 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_Value")); 244 245 jTextArea1.setColumns(30); 246 jTextArea1.setRows(5); 247 jScrollPane1.setViewportView(jTextArea1); 248 249 gridBagConstraints = new java.awt.GridBagConstraints (); 250 gridBagConstraints.gridx = 1; 251 gridBagConstraints.gridy = 1; 252 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 253 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 254 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 255 add(jScrollPane1, gridBagConstraints); 256 257 } 259 260 private javax.swing.JCheckBox jCheckBox1; 262 private javax.swing.JCheckBox jCheckBox2; 263 private javax.swing.JLabel jLabel1; 264 private javax.swing.JLabel jLabel2; 265 private javax.swing.JLabel jLabel3; 266 private javax.swing.JLabel jLabel4; 267 private javax.swing.JLabel jLabel5; 268 private javax.swing.JScrollPane jScrollPane1; 269 private javax.swing.JSpinner jSpinner1; 270 private javax.swing.JSpinner jSpinner2; 271 private javax.swing.JTextArea jTextArea1; 272 private javax.swing.JTextField jTextField1; 273 275 } 276 | Popular Tags |