KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > html > palette > items > INPUTCustomizer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.html.palette.items;
21 import java.awt.Dialog JavaDoc;
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.awt.event.ActionListener JavaDoc;
24 import org.openide.DialogDescriptor;
25 import org.openide.DialogDisplayer;
26 import org.openide.util.NbBundle;
27
28
29
30
31 /**
32  *
33  * @author Libor Kotouc
34  */

35 public class INPUTCustomizer extends javax.swing.JPanel JavaDoc {
36
37     private Dialog JavaDoc dialog = null;
38     private DialogDescriptor descriptor = null;
39     private boolean dialogOK = false;
40
41     INPUT input;
42
43     public INPUTCustomizer(INPUT input) {
44         this.input = input;
45         
46         initComponents();
47     }
48     
49     public boolean showDialog() {
50         
51         dialogOK = false;
52         
53         String JavaDoc displayName = "";
54         try {
55             displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-INPUT"); // NOI18N
56
}
57         catch (Exception JavaDoc e) {}
58         
59         descriptor = new DialogDescriptor
60                 (this, NbBundle.getMessage(INPUTCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true,
61                  DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
62                  new ActionListener JavaDoc() {
63                      public void actionPerformed(ActionEvent JavaDoc 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 JavaDoc name = jTextField1.getText();
83         input.setName(name);
84
85         String JavaDoc value = jTextField2.getText();
86         input.setValue(value);
87         
88         if (jRadioButton1.isSelected())
89             input.setType(INPUT.TYPE_TEXT);
90         if (jRadioButton2.isSelected())
91             input.setType(INPUT.TYPE_PASS);
92         else if (jRadioButton3.isSelected())
93             input.setType(INPUT.TYPE_HIDDEN);
94
95         input.setDisabled(jCheckBox1.isSelected());
96         input.setReadonly(jCheckBox2.isSelected());
97         
98         String JavaDoc width = jTextField4.getText();
99         input.setWidth(width);
100     }
101     
102     /** This method is called from within the constructor to
103      * initialize the form.
104      * WARNING: Do NOT modify this code. The content of this method is
105      * always regenerated by the Form Editor.
106      */

107     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
108
private void initComponents() {
109         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
110
111         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
112         jLabel4 = new javax.swing.JLabel JavaDoc();
113         jTextField1 = new javax.swing.JTextField JavaDoc();
114         jLabel1 = new javax.swing.JLabel JavaDoc();
115         jLabel2 = new javax.swing.JLabel JavaDoc();
116         jLabel3 = new javax.swing.JLabel JavaDoc();
117         jTextField4 = new javax.swing.JTextField JavaDoc();
118         jRadioButton1 = new javax.swing.JRadioButton JavaDoc();
119         jRadioButton2 = new javax.swing.JRadioButton JavaDoc();
120         jRadioButton3 = new javax.swing.JRadioButton JavaDoc();
121         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
122         jCheckBox2 = new javax.swing.JCheckBox JavaDoc();
123         jLabel5 = new javax.swing.JLabel JavaDoc();
124         jTextField2 = new javax.swing.JTextField JavaDoc();
125
126         setLayout(new java.awt.GridBagLayout JavaDoc());
127
128         jLabel4.setLabelFor(jTextField4);
129         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_Width"));
130         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
131         gridBagConstraints.gridx = 0;
132         gridBagConstraints.gridy = 7;
133         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
134         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
135         gridBagConstraints.weighty = 1.0;
136         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 0);
137         add(jLabel4, gridBagConstraints);
138         jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_Width"));
139         jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_Width"));
140
141         jTextField1.setColumns(30);
142         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
143         gridBagConstraints.gridx = 1;
144         gridBagConstraints.gridy = 0;
145         gridBagConstraints.gridwidth = 2;
146         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
147         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
148         gridBagConstraints.weightx = 1.0;
149         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
150         add(jTextField1, gridBagConstraints);
151
152         jLabel1.setLabelFor(jTextField1);
153         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_Name"));
154         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
155         gridBagConstraints.gridx = 0;
156         gridBagConstraints.gridy = 0;
157         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
158         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
159         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
160         add(jLabel1, gridBagConstraints);
161         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_Name"));
162         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_Name"));
163
164         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_Type"));
165         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
166         gridBagConstraints.gridx = 0;
167         gridBagConstraints.gridy = 2;
168         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
169         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
170         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
171         add(jLabel2, gridBagConstraints);
172         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_Type"));
173         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_Type"));
174
175         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_State"));
176         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
177         gridBagConstraints.gridx = 0;
178         gridBagConstraints.gridy = 5;
179         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
180         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
181         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
182         add(jLabel3, gridBagConstraints);
183         jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_State"));
184         jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_state"));
185
186         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
187         gridBagConstraints.gridx = 1;
188         gridBagConstraints.gridy = 7;
189         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
190         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
191         gridBagConstraints.weighty = 1.0;
192         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 12);
193         add(jTextField4, gridBagConstraints);
194
195         buttonGroup1.add(jRadioButton1);
196         jRadioButton1.setSelected(true);
197         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_text"));
198         jRadioButton1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
199         jRadioButton1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
200         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
201         gridBagConstraints.gridx = 1;
202         gridBagConstraints.gridy = 2;
203         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
204         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
205         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
206         add(jRadioButton1, gridBagConstraints);
207         jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_text"));
208         jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_text"));
209
210         buttonGroup1.add(jRadioButton2);
211         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_password"));
212         jRadioButton2.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
213         jRadioButton2.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
214         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
215         gridBagConstraints.gridx = 1;
216         gridBagConstraints.gridy = 3;
217         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
218         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
219         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 12);
220         add(jRadioButton2, gridBagConstraints);
221         jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_password"));
222         jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_password"));
223
224         buttonGroup1.add(jRadioButton3);
225         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton3, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_hidden"));
226         jRadioButton3.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
227         jRadioButton3.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
228         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
229         gridBagConstraints.gridx = 1;
230         gridBagConstraints.gridy = 4;
231         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
232         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
233         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 12);
234         add(jRadioButton3, gridBagConstraints);
235         jRadioButton3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_hidden"));
236         jRadioButton3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_hidden"));
237
238         org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_disabled"));
239         jCheckBox1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
240         jCheckBox1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
241         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
242         gridBagConstraints.gridx = 1;
243         gridBagConstraints.gridy = 5;
244         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
245         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
246         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
247         add(jCheckBox1, gridBagConstraints);
248         jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_disabled"));
249         jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_disabled"));
250
251         org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_readonly"));
252         jCheckBox2.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
253         jCheckBox2.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
254         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
255         gridBagConstraints.gridx = 1;
256         gridBagConstraints.gridy = 6;
257         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
258         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
259         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 12);
260         add(jCheckBox2, gridBagConstraints);
261         jCheckBox2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_readonly"));
262         jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_readonly"));
263
264         jLabel5.setLabelFor(jTextField2);
265         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "LBL_INPUT_Value"));
266         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
267         gridBagConstraints.gridx = 0;
268         gridBagConstraints.gridy = 1;
269         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
270         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
271         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
272         add(jLabel5, gridBagConstraints);
273         jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSN_INPUT_Value"));
274         jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(INPUTCustomizer.class, "ACSD_INPUT_Value"));
275
276         jTextField2.setColumns(30);
277         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
278         gridBagConstraints.gridx = 1;
279         gridBagConstraints.gridy = 1;
280         gridBagConstraints.gridwidth = 2;
281         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
282         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
283         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 12);
284         add(jTextField2, gridBagConstraints);
285
286     }
287     // </editor-fold>//GEN-END:initComponents
288

289     
290     // Variables declaration - do not modify//GEN-BEGIN:variables
291
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
292     private javax.swing.JCheckBox JavaDoc jCheckBox1;
293     private javax.swing.JCheckBox JavaDoc jCheckBox2;
294     private javax.swing.JLabel JavaDoc jLabel1;
295     private javax.swing.JLabel JavaDoc jLabel2;
296     private javax.swing.JLabel JavaDoc jLabel3;
297     private javax.swing.JLabel JavaDoc jLabel4;
298     private javax.swing.JLabel JavaDoc jLabel5;
299     private javax.swing.JRadioButton JavaDoc jRadioButton1;
300     private javax.swing.JRadioButton JavaDoc jRadioButton2;
301     private javax.swing.JRadioButton JavaDoc jRadioButton3;
302     private javax.swing.JTextField JavaDoc jTextField1;
303     private javax.swing.JTextField JavaDoc jTextField2;
304     private javax.swing.JTextField JavaDoc jTextField4;
305     // End of variables declaration//GEN-END:variables
306

307 }
308
Popular Tags