KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.JSpinner JavaDoc;
25 import javax.swing.SpinnerNumberModel JavaDoc;
26 import org.openide.DialogDescriptor;
27 import org.openide.DialogDisplayer;
28 import org.openide.util.NbBundle;
29
30
31
32
33 /**
34  *
35  * @author Libor Kotouc
36  */

37 public class SELECTCustomizer extends javax.swing.JPanel JavaDoc {
38     
39     private Dialog JavaDoc dialog = null;
40     private DialogDescriptor descriptor = null;
41     private boolean dialogOK = false;
42
43     SELECT select;
44             
45     /**
46      * Creates new form SELECTCustomizer
47      */

48     public SELECTCustomizer(SELECT select) {
49         this.select = select;
50         
51         initComponents();
52     }
53     
54     public boolean showDialog() {
55         
56         dialogOK = false;
57         
58         String JavaDoc displayName = "";
59         try {
60             displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-SELECT"); // NOI18N
61
}
62         catch (Exception JavaDoc e) {}
63         
64         descriptor = new DialogDescriptor
65                 (this, NbBundle.getMessage(SELECTCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true,
66                  DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
67                  new ActionListener JavaDoc() {
68                      public void actionPerformed(ActionEvent JavaDoc 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 JavaDoc name = jTextField1.getText();
88         select.setName(name);
89
90         int options = ((Integer JavaDoc)jSpinner1.getValue()).intValue();
91         select.setOptions(options);
92         
93         int optionsVisible = ((Integer JavaDoc)jSpinner2.getValue()).intValue();
94         select.setOptionsVisible(optionsVisible);
95         
96         select.setMultiple(jCheckBox1.isSelected());
97         
98         select.setDisabled(jCheckBox2.isSelected());
99         
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         jTextField1 = new javax.swing.JTextField JavaDoc();
112         jLabel1 = new javax.swing.JLabel JavaDoc();
113         jLabel3 = new javax.swing.JLabel JavaDoc();
114         jLabel2 = new javax.swing.JLabel JavaDoc();
115         jLabel4 = new javax.swing.JLabel JavaDoc();
116         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
117         jCheckBox2 = new javax.swing.JCheckBox JavaDoc();
118         jSpinner1 = new javax.swing.JSpinner JavaDoc();
119         jLabel5 = new javax.swing.JLabel JavaDoc();
120         jSpinner2 = new javax.swing.JSpinner JavaDoc();
121
122         setLayout(new java.awt.GridBagLayout JavaDoc());
123
124         jTextField1.setColumns(30);
125         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
126         gridBagConstraints.gridx = 1;
127         gridBagConstraints.gridy = 0;
128         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
129         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
130         gridBagConstraints.weightx = 1.0;
131         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
132         add(jTextField1, gridBagConstraints);
133
134         jLabel1.setLabelFor(jTextField1);
135         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_Name"));
136         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
137         gridBagConstraints.gridx = 0;
138         gridBagConstraints.gridy = 0;
139         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
140         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
141         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
142         add(jLabel1, gridBagConstraints);
143         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_Name"));
144         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_Name"));
145
146         jLabel3.setLabelFor(jSpinner2);
147         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_VisOptions"));
148         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
149         gridBagConstraints.gridx = 0;
150         gridBagConstraints.gridy = 2;
151         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
152         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
153         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
154         add(jLabel3, gridBagConstraints);
155         jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_VisOptions"));
156         jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_VisOptions"));
157
158         jLabel2.setLabelFor(jSpinner1);
159         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_Options"));
160         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
161         gridBagConstraints.gridx = 0;
162         gridBagConstraints.gridy = 1;
163         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
164         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
165         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
166         add(jLabel2, gridBagConstraints);
167         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_Options"));
168         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_Options"));
169
170         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_Multi"));
171         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
172         gridBagConstraints.gridx = 0;
173         gridBagConstraints.gridy = 3;
174         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
175         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
176         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
177         add(jLabel4, gridBagConstraints);
178         jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_Multi"));
179         jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_Multi"));
180
181         org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_allowed"));
182         jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
183         jCheckBox1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
184         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
185         gridBagConstraints.gridx = 1;
186         gridBagConstraints.gridy = 3;
187         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
188         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
189         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
190         add(jCheckBox1, gridBagConstraints);
191         jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_allowed"));
192         jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_allowed"));
193
194         org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_disabled"));
195         jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
196         jCheckBox2.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
197         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
198         gridBagConstraints.gridx = 1;
199         gridBagConstraints.gridy = 4;
200         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
201         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
202         gridBagConstraints.weighty = 1.0;
203         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 12);
204         add(jCheckBox2, gridBagConstraints);
205         jCheckBox2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_disabled"));
206         jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_disabled"));
207
208         jSpinner1.setModel(new SpinnerNumberModel JavaDoc(select.getOptions(), 0, Integer.MAX_VALUE, 1));
209         jSpinner1.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner1, "#"));
210         jSpinner1.setValue(new Integer JavaDoc(select.getOptions()));
211         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
212         gridBagConstraints.gridx = 1;
213         gridBagConstraints.gridy = 1;
214         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
215         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
216         add(jSpinner1, gridBagConstraints);
217
218         org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "LBL_SELECT_State"));
219         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
220         gridBagConstraints.gridx = 0;
221         gridBagConstraints.gridy = 4;
222         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
223         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
224         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 0);
225         add(jLabel5, gridBagConstraints);
226         jLabel5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSN_SELECT_State"));
227         jLabel5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SELECTCustomizer.class, "ACSD_SELECT_State"));
228
229         jSpinner2.setModel(new SpinnerNumberModel JavaDoc(select.getOptionsVisible(), 1, Integer.MAX_VALUE, 1));
230         jSpinner2.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner2, "#"));
231         jSpinner2.setValue(new Integer JavaDoc(select.getOptionsVisible()));
232         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
233         gridBagConstraints.gridx = 1;
234         gridBagConstraints.gridy = 2;
235         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
236         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 12);
237         add(jSpinner2, gridBagConstraints);
238
239     }// </editor-fold>//GEN-END:initComponents
240

241     
242     // Variables declaration - do not modify//GEN-BEGIN:variables
243
private javax.swing.JCheckBox JavaDoc jCheckBox1;
244     private javax.swing.JCheckBox JavaDoc jCheckBox2;
245     private javax.swing.JLabel JavaDoc jLabel1;
246     private javax.swing.JLabel JavaDoc jLabel2;
247     private javax.swing.JLabel JavaDoc jLabel3;
248     private javax.swing.JLabel JavaDoc jLabel4;
249     private javax.swing.JLabel JavaDoc jLabel5;
250     private javax.swing.JSpinner JavaDoc jSpinner1;
251     private javax.swing.JSpinner JavaDoc jSpinner2;
252     private javax.swing.JTextField JavaDoc jTextField1;
253     // End of variables declaration//GEN-END:variables
254

255 }
256
Popular Tags