KickJava   Java API By Example, From Geeks To Geeks.

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


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 ULCustomizer extends javax.swing.JPanel JavaDoc {
37     
38     private Dialog JavaDoc dialog = null;
39     private DialogDescriptor descriptor = null;
40     private boolean dialogOK = false;
41
42     UL ul;
43             
44     /**
45      * Creates new form ULCustomizer
46      */

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

116     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
117
private void initComponents() {
118         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
119
120         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
121         jLabel1 = new javax.swing.JLabel JavaDoc();
122         jRadioButton1 = new javax.swing.JRadioButton JavaDoc();
123         jRadioButton2 = new javax.swing.JRadioButton JavaDoc();
124         jRadioButton3 = new javax.swing.JRadioButton JavaDoc();
125         jRadioButton4 = new javax.swing.JRadioButton JavaDoc();
126         jLabel2 = new javax.swing.JLabel JavaDoc();
127         jSpinner1 = new javax.swing.JSpinner JavaDoc();
128
129         setLayout(new java.awt.GridBagLayout JavaDoc());
130
131         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_Style"));
132         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
133         gridBagConstraints.gridx = 0;
134         gridBagConstraints.gridy = 1;
135         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
136         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
137         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
138         add(jLabel1, gridBagConstraints);
139         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_Style"));
140         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_Style"));
141
142         buttonGroup1.add(jRadioButton1);
143         jRadioButton1.setSelected(true);
144         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_default"));
145         jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
146         jRadioButton1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
147         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
148         gridBagConstraints.gridx = 1;
149         gridBagConstraints.gridy = 1;
150         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
151         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
152         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 18);
153         add(jRadioButton1, gridBagConstraints);
154         jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_default"));
155         jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_default"));
156
157         buttonGroup1.add(jRadioButton2);
158         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_disc"));
159         jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
160         jRadioButton2.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
161         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
162         gridBagConstraints.gridx = 1;
163         gridBagConstraints.gridy = 2;
164         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
165         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
166         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 24);
167         add(jRadioButton2, gridBagConstraints);
168         jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_disc"));
169         jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_disc"));
170
171         buttonGroup1.add(jRadioButton3);
172         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton3, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_circle"));
173         jRadioButton3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
174         jRadioButton3.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
175         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
176         gridBagConstraints.gridx = 1;
177         gridBagConstraints.gridy = 3;
178         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
179         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
180         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 24);
181         add(jRadioButton3, gridBagConstraints);
182         jRadioButton3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_circle"));
183         jRadioButton3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_circle"));
184
185         buttonGroup1.add(jRadioButton4);
186         org.openide.awt.Mnemonics.setLocalizedText(jRadioButton4, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_square"));
187         jRadioButton4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
188         jRadioButton4.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
189         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
190         gridBagConstraints.gridx = 1;
191         gridBagConstraints.gridy = 4;
192         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
193         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
194         gridBagConstraints.weightx = 1.0;
195         gridBagConstraints.weighty = 1.0;
196         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 12, 24);
197         add(jRadioButton4, gridBagConstraints);
198         jRadioButton4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_square"));
199         jRadioButton4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_square"));
200
201         jLabel2.setLabelFor(jSpinner1);
202         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ULCustomizer.class, "LBL_UL_Items"));
203         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
204         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
205         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
206         add(jLabel2, gridBagConstraints);
207         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSN_UL_Items"));
208         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ULCustomizer.class, "ACSD_UL_Items"));
209
210         jSpinner1.setModel(new SpinnerNumberModel JavaDoc(ul.getCount(), 0, Integer.MAX_VALUE, 1));
211         jSpinner1.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner1, "#"));
212         jSpinner1.setValue(new Integer JavaDoc(ul.getCount()));
213         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
214         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
215         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 18);
216         add(jSpinner1, gridBagConstraints);
217
218     }// </editor-fold>//GEN-END:initComponents
219

220     
221     // Variables declaration - do not modify//GEN-BEGIN:variables
222
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
223     private javax.swing.JLabel JavaDoc jLabel1;
224     private javax.swing.JLabel JavaDoc jLabel2;
225     private javax.swing.JRadioButton JavaDoc jRadioButton1;
226     private javax.swing.JRadioButton JavaDoc jRadioButton2;
227     private javax.swing.JRadioButton JavaDoc jRadioButton3;
228     private javax.swing.JRadioButton JavaDoc jRadioButton4;
229     private javax.swing.JSpinner JavaDoc jSpinner1;
230     // End of variables declaration//GEN-END:variables
231

232 }
233
Popular Tags