001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.html.palette.items;
043:
044: import java.awt.Dialog;
045: import java.awt.event.ActionEvent;
046: import java.awt.event.ActionListener;
047: import javax.swing.JSpinner;
048: import javax.swing.SpinnerNumberModel;
049: import org.openide.DialogDescriptor;
050: import org.openide.DialogDisplayer;
051: import org.openide.util.NbBundle;
052:
053: /**
054: *
055: * @author Libor Kotouc
056: */
057: public class ULCustomizer extends javax.swing.JPanel {
058:
059: private Dialog dialog = null;
060: private DialogDescriptor descriptor = null;
061: private boolean dialogOK = false;
062:
063: UL ul;
064:
065: /**
066: * Creates new form ULCustomizer
067: */
068: public ULCustomizer(UL ul) {
069: this .ul = ul;
070:
071: initComponents();
072:
073: if (ul.getType().equals(UL.DEFAULT))
074: jRadioButton1.setSelected(true);
075: else if (ul.getType().equals(UL.DISC))
076: jRadioButton2.setSelected(true);
077: else if (ul.getType().equals(UL.CIRCLE))
078: jRadioButton3.setSelected(true);
079: else if (ul.getType().equals(UL.SQUARE))
080: jRadioButton4.setSelected(true);
081: }
082:
083: public boolean showDialog() {
084:
085: dialogOK = false;
086:
087: String displayName = "";
088: try {
089: displayName = NbBundle
090: .getBundle(
091: "org.netbeans.modules.html.palette.items.resources.Bundle")
092: .getString("NAME_html-UL"); // NOI18N
093: } catch (Exception e) {
094: }
095:
096: descriptor = new DialogDescriptor(this , NbBundle.getMessage(
097: ULCustomizer.class, "LBL_Customizer_InsertPrefix")
098: + " " + displayName, true,
099: DialogDescriptor.OK_CANCEL_OPTION,
100: DialogDescriptor.OK_OPTION, new ActionListener() {
101: public void actionPerformed(ActionEvent e) {
102: if (descriptor.getValue().equals(
103: DialogDescriptor.OK_OPTION)) {
104: evaluateInput();
105: dialogOK = true;
106: }
107: dialog.dispose();
108: }
109: });
110:
111: dialog = DialogDisplayer.getDefault().createDialog(descriptor);
112: dialog.setVisible(true);
113:
114: return dialogOK;
115: }
116:
117: private void evaluateInput() {
118:
119: int count = ((Integer) jSpinner1.getValue()).intValue();
120: ul.setCount(count);
121:
122: String itemType = null;
123:
124: if (jRadioButton1.isSelected())
125: itemType = UL.DEFAULT;
126: if (jRadioButton2.isSelected())
127: itemType = UL.DISC;
128: else if (jRadioButton3.isSelected())
129: itemType = UL.CIRCLE;
130: else if (jRadioButton4.isSelected())
131: itemType = UL.SQUARE;
132:
133: ul.setType(itemType);
134: }
135:
136: /** This method is called from within the constructor to
137: * initialize the form.
138: * WARNING: Do NOT modify this code. The content of this method is
139: * always regenerated by the Form Editor.
140: */
141: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
142: private void initComponents() {
143: java.awt.GridBagConstraints gridBagConstraints;
144:
145: buttonGroup1 = new javax.swing.ButtonGroup();
146: jLabel1 = new javax.swing.JLabel();
147: jRadioButton1 = new javax.swing.JRadioButton();
148: jRadioButton2 = new javax.swing.JRadioButton();
149: jRadioButton3 = new javax.swing.JRadioButton();
150: jRadioButton4 = new javax.swing.JRadioButton();
151: jLabel2 = new javax.swing.JLabel();
152: jSpinner1 = new javax.swing.JSpinner();
153:
154: setLayout(new java.awt.GridBagLayout());
155:
156: org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
157: org.openide.util.NbBundle.getMessage(
158: ULCustomizer.class, "LBL_UL_Style"));
159: gridBagConstraints = new java.awt.GridBagConstraints();
160: gridBagConstraints.gridx = 0;
161: gridBagConstraints.gridy = 1;
162: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
163: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
164: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
165: add(jLabel1, gridBagConstraints);
166: jLabel1.getAccessibleContext().setAccessibleName(
167: org.openide.util.NbBundle.getMessage(
168: ULCustomizer.class, "ACSN_UL_Style"));
169: jLabel1.getAccessibleContext().setAccessibleDescription(
170: org.openide.util.NbBundle.getMessage(
171: ULCustomizer.class, "ACSD_UL_Style"));
172:
173: buttonGroup1.add(jRadioButton1);
174: jRadioButton1.setSelected(true);
175: org.openide.awt.Mnemonics.setLocalizedText(jRadioButton1,
176: org.openide.util.NbBundle.getMessage(
177: ULCustomizer.class, "LBL_UL_default"));
178: jRadioButton1.setBorder(javax.swing.BorderFactory
179: .createEmptyBorder(0, 0, 0, 0));
180: jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
181: gridBagConstraints = new java.awt.GridBagConstraints();
182: gridBagConstraints.gridx = 1;
183: gridBagConstraints.gridy = 1;
184: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
185: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
186: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 18);
187: add(jRadioButton1, gridBagConstraints);
188: jRadioButton1.getAccessibleContext().setAccessibleName(
189: org.openide.util.NbBundle.getMessage(
190: ULCustomizer.class, "ACSN_UL_default"));
191: jRadioButton1.getAccessibleContext().setAccessibleDescription(
192: org.openide.util.NbBundle.getMessage(
193: ULCustomizer.class, "ACSD_UL_default"));
194:
195: buttonGroup1.add(jRadioButton2);
196: org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2,
197: org.openide.util.NbBundle.getMessage(
198: ULCustomizer.class, "LBL_UL_disc"));
199: jRadioButton2.setBorder(javax.swing.BorderFactory
200: .createEmptyBorder(0, 0, 0, 0));
201: jRadioButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));
202: gridBagConstraints = new java.awt.GridBagConstraints();
203: gridBagConstraints.gridx = 1;
204: gridBagConstraints.gridy = 2;
205: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
206: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
207: gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 24);
208: add(jRadioButton2, gridBagConstraints);
209: jRadioButton2.getAccessibleContext().setAccessibleName(
210: org.openide.util.NbBundle.getMessage(
211: ULCustomizer.class, "ACSN_UL_disc"));
212: jRadioButton2.getAccessibleContext().setAccessibleDescription(
213: org.openide.util.NbBundle.getMessage(
214: ULCustomizer.class, "ACSD_UL_disc"));
215:
216: buttonGroup1.add(jRadioButton3);
217: org.openide.awt.Mnemonics.setLocalizedText(jRadioButton3,
218: org.openide.util.NbBundle.getMessage(
219: ULCustomizer.class, "LBL_UL_circle"));
220: jRadioButton3.setBorder(javax.swing.BorderFactory
221: .createEmptyBorder(0, 0, 0, 0));
222: jRadioButton3.setMargin(new java.awt.Insets(0, 0, 0, 0));
223: gridBagConstraints = new java.awt.GridBagConstraints();
224: gridBagConstraints.gridx = 1;
225: gridBagConstraints.gridy = 3;
226: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
227: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
228: gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 24);
229: add(jRadioButton3, gridBagConstraints);
230: jRadioButton3.getAccessibleContext().setAccessibleName(
231: org.openide.util.NbBundle.getMessage(
232: ULCustomizer.class, "ACSN_UL_circle"));
233: jRadioButton3.getAccessibleContext().setAccessibleDescription(
234: org.openide.util.NbBundle.getMessage(
235: ULCustomizer.class, "ACSD_UL_circle"));
236:
237: buttonGroup1.add(jRadioButton4);
238: org.openide.awt.Mnemonics.setLocalizedText(jRadioButton4,
239: org.openide.util.NbBundle.getMessage(
240: ULCustomizer.class, "LBL_UL_square"));
241: jRadioButton4.setBorder(javax.swing.BorderFactory
242: .createEmptyBorder(0, 0, 0, 0));
243: jRadioButton4.setMargin(new java.awt.Insets(0, 0, 0, 0));
244: gridBagConstraints = new java.awt.GridBagConstraints();
245: gridBagConstraints.gridx = 1;
246: gridBagConstraints.gridy = 4;
247: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
248: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
249: gridBagConstraints.weightx = 1.0;
250: gridBagConstraints.weighty = 1.0;
251: gridBagConstraints.insets = new java.awt.Insets(5, 12, 12, 24);
252: add(jRadioButton4, gridBagConstraints);
253: jRadioButton4.getAccessibleContext().setAccessibleName(
254: org.openide.util.NbBundle.getMessage(
255: ULCustomizer.class, "ACSN_UL_square"));
256: jRadioButton4.getAccessibleContext().setAccessibleDescription(
257: org.openide.util.NbBundle.getMessage(
258: ULCustomizer.class, "ACSD_UL_square"));
259:
260: jLabel2.setLabelFor(jSpinner1);
261: org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
262: org.openide.util.NbBundle.getMessage(
263: ULCustomizer.class, "LBL_UL_Items"));
264: gridBagConstraints = new java.awt.GridBagConstraints();
265: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
266: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
267: add(jLabel2, gridBagConstraints);
268: jLabel2.getAccessibleContext().setAccessibleName(
269: org.openide.util.NbBundle.getMessage(
270: ULCustomizer.class, "ACSN_UL_Items"));
271: jLabel2.getAccessibleContext().setAccessibleDescription(
272: org.openide.util.NbBundle.getMessage(
273: ULCustomizer.class, "ACSD_UL_Items"));
274:
275: jSpinner1.setModel(new SpinnerNumberModel(ul.getCount(), 0,
276: Integer.MAX_VALUE, 1));
277: jSpinner1.setEditor(new JSpinner.NumberEditor(jSpinner1, "#"));
278: jSpinner1.setValue(new Integer(ul.getCount()));
279: gridBagConstraints = new java.awt.GridBagConstraints();
280: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
281: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 18);
282: add(jSpinner1, gridBagConstraints);
283:
284: }// </editor-fold>//GEN-END:initComponents
285:
286: // Variables declaration - do not modify//GEN-BEGIN:variables
287: private javax.swing.ButtonGroup buttonGroup1;
288: private javax.swing.JLabel jLabel1;
289: private javax.swing.JLabel jLabel2;
290: private javax.swing.JRadioButton jRadioButton1;
291: private javax.swing.JRadioButton jRadioButton2;
292: private javax.swing.JRadioButton jRadioButton3;
293: private javax.swing.JRadioButton jRadioButton4;
294: private javax.swing.JSpinner jSpinner1;
295: // End of variables declaration//GEN-END:variables
296:
297: }
|