2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.html.palette.items;
43
import java.awt.Dialog;
44
import java.awt.event.ActionEvent;
45
import java.awt.event.ActionListener;
46
import javax.swing.JSpinner;
47
import javax.swing.SpinnerNumberModel;
48
import org.openide.DialogDescriptor;
49
import org.openide.DialogDisplayer;
50
import org.openide.util.NbBundle;
57
* @author Libor Kotouc
59
public class TEXTAREACustomizer extends javax.swing.JPanel {
61
private Dialog dialog = null;
62
private DialogDescriptor descriptor = null;
63
private boolean dialogOK = false;
68
* Creates new form TEXTAREACustomizer
70
public TEXTAREACustomizer(TEXTAREA textArea) {
71
this.textArea = textArea;
76
public boolean showDialog() {
80
String displayName = "";
82
displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-TEXTAREA"); // NOI18N
84
catch (Exception e) {}
86
descriptor = new DialogDescriptor
87
(this, NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true,
88
DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
89
new ActionListener() {
90
public void actionPerformed(ActionEvent e) {
91
if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
100
dialog = DialogDisplayer.getDefault().createDialog(descriptor);
101
dialog.setVisible(true);
107
private void evaluateInput() {
109
String name = jTextField1.getText();
110
textArea.setName(name);
112
String value = jTextArea1.getText();
113
textArea.setValue(value);
115
textArea.setDisabled(jCheckBox1.isSelected());
116
textArea.setReadonly(jCheckBox2.isSelected());
118
int rows = ((Integer)jSpinner1.getValue()).intValue();
119
textArea.setRows(rows);
121
int cols = ((Integer)jSpinner2.getValue()).intValue();
122
textArea.setCols(cols);
126
/** This method is called from within the constructor to
127
* initialize the form.
128
* WARNING: Do NOT modify this code. The content of this method is
129
* always regenerated by the Form Editor.
131
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
132
private void initComponents() {
133
java.awt.GridBagConstraints gridBagConstraints;
135
jLabel4 = new javax.swing.JLabel();
136
jTextField1 = new javax.swing.JTextField();
137
jLabel1 = new javax.swing.JLabel();
138
jLabel3 = new javax.swing.JLabel();
139
jCheckBox1 = new javax.swing.JCheckBox();
140
jCheckBox2 = new javax.swing.JCheckBox();
141
jLabel5 = new javax.swing.JLabel();
142
jSpinner1 = new javax.swing.JSpinner();
143
jSpinner2 = new javax.swing.JSpinner();
144
jLabel2 = new javax.swing.JLabel();
145
jScrollPane1 = new javax.swing.JScrollPane();
146
jTextArea1 = new javax.swing.JTextArea();
148
setLayout(new java.awt.GridBagLayout());
150
jLabel4.setLabelFor(jSpinner1);
151
org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_Rows"));
152
gridBagConstraints = new java.awt.GridBagConstraints();
153
gridBagConstraints.gridx = 0;
154
gridBagConstraints.gridy = 4;
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(jLabel4, gridBagConstraints);
159
jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_Rows"));
160
jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_Rows"));
162
jTextField1.setColumns(30);
163
gridBagConstraints = new java.awt.GridBagConstraints();
164
gridBagConstraints.gridx = 1;
165
gridBagConstraints.gridy = 0;
166
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
167
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
168
gridBagConstraints.weightx = 1.0;
169
gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
170
add(jTextField1, gridBagConstraints);
172
jLabel1.setLabelFor(jTextField1);
173
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_Name"));
174
gridBagConstraints = new java.awt.GridBagConstraints();
175
gridBagConstraints.gridx = 0;
176
gridBagConstraints.gridy = 0;
177
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
178
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
179
gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
180
add(jLabel1, gridBagConstraints);
181
jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_Name"));
182
jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_Name"));
184
org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_State"));
185
gridBagConstraints = new java.awt.GridBagConstraints();
186
gridBagConstraints.gridx = 0;
187
gridBagConstraints.gridy = 2;
188
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
189
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
190
gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
191
add(jLabel3, gridBagConstraints);
192
jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_State"));
193
jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_State"));
195
org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_disabled"));
196
jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
197
jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
198
gridBagConstraints = new java.awt.GridBagConstraints();
199
gridBagConstraints.gridx = 1;
200
gridBagConstraints.gridy = 2;
201
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
202
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
203
gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
204
add(jCheckBox1, gridBagConstraints);
205
jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_disabled"));
206
jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_disabled"));
208
org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_readonly"));
209
jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
210
jCheckBox2.setMargin(new java.awt.Insets(0, 0, 0, 0));
211
gridBagConstraints = new java.awt.GridBagConstraints();
212
gridBagConstraints.gridx = 1;
213
gridBagConstraints.gridy = 3;
214
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
215
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
216
gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 12);
217
add(jCheckBox2, gridBagConstraints);
218
jCheckBox2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_readonly"));
219
jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_readonly"));
221
jLabel5.setLabelFor(jSpinner2);
222
org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_Columns"));
223
gridBagConstraints = new java.awt.GridBagConstraints();
224
gridBagConstraints.gridx = 0;
225
gridBagConstraints.gridy = 5;
226
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
227
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
228
gridBagConstraints.insets = new java.awt.Insets(5, 12, 12, 0);
229
add(jLabel5, gridBagConstraints);
230
jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_Columns"));
231
jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_Columns"));
233
jSpinner1.setModel(new SpinnerNumberModel(textArea.getRows(), 1, Integer.MAX_VALUE, 1));
234
jSpinner1.setEditor(new JSpinner.NumberEditor(jSpinner1, "#"));
235
jSpinner1.setValue(new Integer(textArea.getRows()));
236
gridBagConstraints = new java.awt.GridBagConstraints();
237
gridBagConstraints.gridx = 1;
238
gridBagConstraints.gridy = 4;
239
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
240
gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
241
add(jSpinner1, gridBagConstraints);
243
jSpinner2.setModel(new SpinnerNumberModel(textArea.getCols(), 1, Integer.MAX_VALUE, 1));
244
jSpinner2.setEditor(new JSpinner.NumberEditor(jSpinner2, "#"));
245
jSpinner2.setValue(new Integer(textArea.getCols()));
246
gridBagConstraints = new java.awt.GridBagConstraints();
247
gridBagConstraints.gridx = 1;
248
gridBagConstraints.gridy = 5;
249
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
250
gridBagConstraints.weightx = 1.0;
251
gridBagConstraints.weighty = 1.0;
252
gridBagConstraints.insets = new java.awt.Insets(5, 12, 12, 12);
253
add(jSpinner2, gridBagConstraints);
255
jLabel2.setLabelFor(jTextArea1);
256
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "LBL_TEXTAREA_Value"));
257
gridBagConstraints = new java.awt.GridBagConstraints();
258
gridBagConstraints.gridx = 0;
259
gridBagConstraints.gridy = 1;
260
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
261
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
262
gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
263
add(jLabel2, gridBagConstraints);
264
jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSN_TEXTAREA_Value"));
265
jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TEXTAREACustomizer.class, "ACSD_TEXTAREA_Value"));
267
jTextArea1.setColumns(30);
268
jTextArea1.setRows(5);
269
jScrollPane1.setViewportView(jTextArea1);
271
gridBagConstraints = new java.awt.GridBagConstraints();
272
gridBagConstraints.gridx = 1;
273
gridBagConstraints.gridy = 1;
274
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
275
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
276
gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 12);
277
add(jScrollPane1, gridBagConstraints);
279
}// </editor-fold>//GEN-END:initComponents
282
// Variables declaration - do not modify//GEN-BEGIN:variables
283
private javax.swing.JCheckBox jCheckBox1;
284
private javax.swing.JCheckBox jCheckBox2;
285
private javax.swing.JLabel jLabel1;
286
private javax.swing.JLabel jLabel2;
287
private javax.swing.JLabel jLabel3;
288
private javax.swing.JLabel jLabel4;
289
private javax.swing.JLabel jLabel5;
290
private javax.swing.JScrollPane jScrollPane1;
291
private javax.swing.JSpinner jSpinner1;
292
private javax.swing.JSpinner jSpinner2;
293
private javax.swing.JTextArea jTextArea1;
294
private javax.swing.JTextField jTextField1;
295
// End of variables declaration//GEN-END:variables