KickJava   Java API By Example, From Geeks To Geeks.

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


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  * @author Libor Kotouc
35  */

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

47     public OLCustomizer(OL ol) {
48         this.ol = ol;
49         
50         initComponents();
51         
52         if (ol.getType().equals(OL.DEFAULT))
53             jRadioButton1.setSelected(true);
54         else if (ol.getType().equals(OL.ARABIC_NUMBERS))
55             jRadioButton2.setSelected(true);
56         else if (ol.getType().equals(OL.LOWER_ALPHA))
57             jRadioButton3.setSelected(true);
58         else if (ol.getType().equals(OL.UPPER_ALPHA))
59             jRadioButton4.setSelected(true);
60         else if (ol.getType().equals(OL.LOWER_ROMAN))
61             jRadioButton5.setSelected(true);
62         else if (ol.getType().equals(OL.UPPER_ROMAN))
63             jRadioButton6.setSelected(true);
64     }
65     
66     public boolean showDialog() {
67         
68         dialogOK = false;
69         
70         String JavaDoc displayName = "";
71         try {
72             displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-OL"); // NOI18N
73
}
74         catch (Exception JavaDoc e) {}
75         
76         descriptor = new DialogDescriptor
77                 (this, NbBundle.getMessage(OLCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true,
78                  DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
79                  new ActionListener JavaDoc() {
80                      public void actionPerformed(ActionEvent JavaDoc e) {
81                         if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
82                             evaluateInput();
83                             dialogOK = true;
84                         }
85                         dialog.dispose();
86              }
87          }
88                 );
89         
90         dialog = DialogDisplayer.getDefault().createDialog(descriptor);
91         dialog.setVisible(true);
92         
93         return dialogOK;
94     }
95     
96     private void evaluateInput() {
97         
98         int count = ((Integer JavaDoc)jSpinner1.getValue()).intValue();
99         ol.setCount(count);
100
101         String JavaDoc itemType = null;
102
103         if (jRadioButton1.isSelected())
104             itemType = OL.DEFAULT;
105         if (jRadioButton2.isSelected())
106             itemType = OL.ARABIC_NUMBERS;
107         else if (jRadioButton3.isSelected())
108             itemType = OL.LOWER_ALPHA;
109         else if (jRadioButton4.isSelected())
110             itemType = OL.UPPER_ALPHA;
111         else if (jRadioButton5.isSelected())
112             itemType = OL.LOWER_ROMAN;
113         else if (jRadioButton6.isSelected())
114             itemType = OL.UPPER_ROMAN;
115
116         ol.setType(itemType);
117     }
118     
119     /** This method is called from within the constructor to
120      * initialize the form.
121      * WARNING: Do NOT modify this code. The content of this method is
122      * always regenerated by the Form Editor.
123      */

124     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
125
private void initComponents() {
126         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
127
128         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
129         jLabel1 = new javax.swing.JLabel JavaDoc();
130         jRadioButton1 = new javax.swing.JRadioButton JavaDoc();
131         jRadioButton2 = new javax.swing.JRadioButton JavaDoc();
132         jRadioButton3 = new javax.swing.JRadioButton JavaDoc();
133         jRadioButton4 = new javax.swing.JRadioButton JavaDoc();
134         jRadioButton5 = new javax.swing.JRadioButton JavaDoc();
135         jRadioButton6 = new javax.swing.JRadioButton JavaDoc();
136         jLabel2 = new javax.swing.JLabel JavaDoc();
137         jSpinner1 = new javax.swing.JSpinner JavaDoc();
138
139         setLayout(new java.awt.GridBagLayout JavaDoc());
140
141         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(OLCustomizer.class, "LBL_OL_Style"));
142         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
143         gridBagConstraints.gridx = 0;
144         gridBagConstraints.gridy = 1;
145         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
146         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
147         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
148         add(jLabel1, gridBagConstraints);
149         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_Style"));
150         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_Style"));
151
152         buttonGroup1.add(jRadioButton1);
153         jRadioButton1.setSelected(true);
154         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1, org.openide.util.NbBundle.getMessage(OLCustomizer.class, "LBL_OL_default"));
155         jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
156         jRadioButton1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
157         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
158         gridBagConstraints.gridx = 1;
159         gridBagConstraints.gridy = 1;
160         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
161         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
162         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 18);
163         add(jRadioButton1, gridBagConstraints);
164         jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_default"));
165         jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_default"));
166
167         buttonGroup1.add(jRadioButton2);
168         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, "1, 2, 3, ...");
169         jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
170         jRadioButton2.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
171         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
172         gridBagConstraints.gridx = 1;
173         gridBagConstraints.gridy = 2;
174         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
175         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
176         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 24);
177         add(jRadioButton2, gridBagConstraints);
178         jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_arabic"));
179         jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_arabicnumbers"));
180
181         buttonGroup1.add(jRadioButton3);
182         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton3, "a, b, c, ...");
183         jRadioButton3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
184         jRadioButton3.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
185         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
186         gridBagConstraints.gridx = 1;
187         gridBagConstraints.gridy = 3;
188         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
189         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
190         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 24);
191         add(jRadioButton3, gridBagConstraints);
192         jRadioButton3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_loweralpha"));
193         jRadioButton3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_loweralpha"));
194
195         buttonGroup1.add(jRadioButton4);
196         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton4, "A, B, C, ...");
197         jRadioButton4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
198         jRadioButton4.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
199         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
200         gridBagConstraints.gridx = 1;
201         gridBagConstraints.gridy = 4;
202         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
203         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
204         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 24);
205         add(jRadioButton4, gridBagConstraints);
206         jRadioButton4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_upperalpha"));
207         jRadioButton4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_upperalpha"));
208
209         buttonGroup1.add(jRadioButton5);
210         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton5, "i, ii, iii, ...");
211         jRadioButton5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
212         jRadioButton5.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
213         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
214         gridBagConstraints.gridx = 1;
215         gridBagConstraints.gridy = 5;
216         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
217         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
218         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 24);
219         add(jRadioButton5, gridBagConstraints);
220         jRadioButton5.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_lowerroman"));
221         jRadioButton5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_lowerroman"));
222
223         buttonGroup1.add(jRadioButton6);
224         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton6, "I, II, III, ...");
225         jRadioButton6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
226         jRadioButton6.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
227         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
228         gridBagConstraints.gridx = 1;
229         gridBagConstraints.gridy = 6;
230         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
231         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
232         gridBagConstraints.weightx = 1.0;
233         gridBagConstraints.weighty = 1.0;
234         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 12, 24);
235         add(jRadioButton6, gridBagConstraints);
236         jRadioButton6.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_upperroman"));
237         jRadioButton6.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_upperroman"));
238
239         jLabel2.setLabelFor(jSpinner1);
240         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(OLCustomizer.class, "LBL_OL_Items"));
241         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
242         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
243         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
244         add(jLabel2, gridBagConstraints);
245         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSN_OL_Items"));
246         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(OLCustomizer.class, "ACSD_OL_Items"));
247
248         jSpinner1.setModel(new SpinnerNumberModel JavaDoc(ol.getCount(), 0, Integer.MAX_VALUE, 1));
249         jSpinner1.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner1, "#"));
250         jSpinner1.setValue(new Integer JavaDoc(ol.getCount()));
251         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
252         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
253         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 18);
254         add(jSpinner1, gridBagConstraints);
255
256     }// </editor-fold>//GEN-END:initComponents
257

258     
259     // Variables declaration - do not modify//GEN-BEGIN:variables
260
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
261     private javax.swing.JLabel JavaDoc jLabel1;
262     private javax.swing.JLabel JavaDoc jLabel2;
263     private javax.swing.JRadioButton JavaDoc jRadioButton1;
264     private javax.swing.JRadioButton JavaDoc jRadioButton2;
265     private javax.swing.JRadioButton JavaDoc jRadioButton3;
266     private javax.swing.JRadioButton JavaDoc jRadioButton4;
267     private javax.swing.JRadioButton JavaDoc jRadioButton5;
268     private javax.swing.JRadioButton JavaDoc jRadioButton6;
269     private javax.swing.JSpinner JavaDoc jSpinner1;
270     // End of variables declaration//GEN-END:variables
271

272 }
273
Popular Tags