KickJava   Java API By Example, From Geeks To Geeks.

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


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 CHECKBOXCustomizer extends javax.swing.JPanel JavaDoc {
36
37     private Dialog JavaDoc 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 JavaDoc displayName = "";
54         try {
55             displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-CHECKBOX"); // NOI18N
56
}
57         catch (Exception JavaDoc 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 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         checkbox.setName(name);
84
85         String JavaDoc value = jTextField2.getText();
86         checkbox.setValue(value);
87         
88         checkbox.setSelected(jCheckBox1.isSelected());
89
90         checkbox.setDisabled(jCheckBox2.isSelected());
91         
92     }
93     
94     /** This method is called from within the constructor to
95      * initialize the form.
96      * WARNING: Do NOT modify this code. The content of this method is
97      * always regenerated by the Form Editor.
98      */

99     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
100
private void initComponents() {
101         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
102
103         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
104         jTextField1 = new javax.swing.JTextField JavaDoc();
105         jLabel1 = new javax.swing.JLabel JavaDoc();
106         jLabel3 = new javax.swing.JLabel JavaDoc();
107         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
108         jCheckBox2 = new javax.swing.JCheckBox JavaDoc();
109         jLabel5 = new javax.swing.JLabel JavaDoc();
110         jTextField2 = new javax.swing.JTextField JavaDoc();
111         jLabel2 = new javax.swing.JLabel JavaDoc();
112
113         setLayout(new java.awt.GridBagLayout JavaDoc());
114
115         jTextField1.setColumns(30);
116         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
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 JavaDoc(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 JavaDoc();
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 JavaDoc(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 JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
150         jCheckBox1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
151         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
163         jCheckBox2.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
164         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
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 JavaDoc(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 JavaDoc();
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 JavaDoc(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 JavaDoc();
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 JavaDoc(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     // </editor-fold>//GEN-END:initComponents
210

211     
212     // Variables declaration - do not modify//GEN-BEGIN:variables
213
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
214     private javax.swing.JCheckBox JavaDoc jCheckBox1;
215     private javax.swing.JCheckBox JavaDoc jCheckBox2;
216     private javax.swing.JLabel JavaDoc jLabel1;
217     private javax.swing.JLabel JavaDoc jLabel2;
218     private javax.swing.JLabel JavaDoc jLabel3;
219     private javax.swing.JLabel JavaDoc jLabel5;
220     private javax.swing.JTextField JavaDoc jTextField1;
221     private javax.swing.JTextField JavaDoc jTextField2;
222     // End of variables declaration//GEN-END:variables
223

224 }
225
Popular Tags