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 org.openide.DialogDescriptor;
048: import org.openide.DialogDisplayer;
049: import org.openide.util.NbBundle;
050:
051: /**
052: *
053: * @author Libor Kotouc
054: */
055: public class FILESELCustomizer extends javax.swing.JPanel {
056:
057: private Dialog dialog = null;
058: private DialogDescriptor descriptor = null;
059: private boolean dialogOK = false;
060:
061: FILESEL filesel;
062:
063: public FILESELCustomizer(FILESEL filesel) {
064: this .filesel = filesel;
065:
066: initComponents();
067: }
068:
069: public boolean showDialog() {
070:
071: dialogOK = false;
072:
073: String displayName = "";
074: try {
075: displayName = NbBundle
076: .getBundle(
077: "org.netbeans.modules.html.palette.items.resources.Bundle")
078: .getString("NAME_html-FILESEL"); // NOI18N
079: } catch (Exception e) {
080: }
081:
082: descriptor = new DialogDescriptor(this , NbBundle.getMessage(
083: FILESELCustomizer.class, "LBL_Customizer_InsertPrefix")
084: + " " + displayName, true,
085: DialogDescriptor.OK_CANCEL_OPTION,
086: DialogDescriptor.OK_OPTION, new ActionListener() {
087: public void actionPerformed(ActionEvent e) {
088: if (descriptor.getValue().equals(
089: DialogDescriptor.OK_OPTION)) {
090: evaluateInput();
091: dialogOK = true;
092: }
093: dialog.dispose();
094: }
095: });
096:
097: dialog = DialogDisplayer.getDefault().createDialog(descriptor);
098: dialog.setVisible(true);
099: repaint();
100:
101: return dialogOK;
102: }
103:
104: private void evaluateInput() {
105:
106: String name = jTextField1.getText();
107: filesel.setName(name);
108:
109: String width = jTextField2.getText();
110: filesel.setWidth(width);
111:
112: filesel.setDisabled(jCheckBox1.isSelected());
113:
114: }
115:
116: /** This method is called from within the constructor to
117: * initialize the form.
118: * WARNING: Do NOT modify this code. The content of this method is
119: * always regenerated by the Form Editor.
120: */
121: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
122: private void initComponents() {
123: java.awt.GridBagConstraints gridBagConstraints;
124:
125: buttonGroup1 = new javax.swing.ButtonGroup();
126: jTextField1 = new javax.swing.JTextField();
127: jLabel1 = new javax.swing.JLabel();
128: jLabel2 = new javax.swing.JLabel();
129: jLabel3 = new javax.swing.JLabel();
130: jCheckBox1 = new javax.swing.JCheckBox();
131: jTextField2 = new javax.swing.JTextField();
132:
133: setLayout(new java.awt.GridBagLayout());
134:
135: jTextField1.setColumns(30);
136: gridBagConstraints = new java.awt.GridBagConstraints();
137: gridBagConstraints.gridx = 1;
138: gridBagConstraints.gridy = 0;
139: gridBagConstraints.gridwidth = 2;
140: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
141: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
142: gridBagConstraints.weightx = 1.0;
143: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
144: add(jTextField1, gridBagConstraints);
145:
146: jLabel1.setLabelFor(jTextField1);
147: org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
148: org.openide.util.NbBundle.getMessage(
149: FILESELCustomizer.class, "LBL_FILESEL_Name"));
150: gridBagConstraints = new java.awt.GridBagConstraints();
151: gridBagConstraints.gridx = 0;
152: gridBagConstraints.gridy = 0;
153: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
154: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
155: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
156: add(jLabel1, gridBagConstraints);
157: jLabel1.getAccessibleContext().setAccessibleName(
158: org.openide.util.NbBundle.getMessage(
159: FILESELCustomizer.class, "ACSN_FILESEL_Name"));
160: jLabel1.getAccessibleContext().setAccessibleDescription(
161: org.openide.util.NbBundle.getMessage(
162: FILESELCustomizer.class, "ACSD_FILESEL_Name"));
163:
164: jLabel2.setLabelFor(jTextField2);
165: org.openide.awt.Mnemonics.setLocalizedText(jLabel2,
166: org.openide.util.NbBundle.getMessage(
167: FILESELCustomizer.class, "LBL_FILESEL_Width"));
168: gridBagConstraints = new java.awt.GridBagConstraints();
169: gridBagConstraints.gridx = 0;
170: gridBagConstraints.gridy = 1;
171: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
172: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
173: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
174: add(jLabel2, gridBagConstraints);
175: jLabel2.getAccessibleContext().setAccessibleName(
176: org.openide.util.NbBundle.getMessage(
177: FILESELCustomizer.class, "ACSN_FILESEL_Width"));
178: jLabel2.getAccessibleContext().setAccessibleDescription(
179: org.openide.util.NbBundle.getMessage(
180: FILESELCustomizer.class, "ACSD_FILESEL_Width"));
181:
182: org.openide.awt.Mnemonics.setLocalizedText(jLabel3,
183: org.openide.util.NbBundle.getMessage(
184: FILESELCustomizer.class,
185: "LBL_FILESEL_InitState"));
186: gridBagConstraints = new java.awt.GridBagConstraints();
187: gridBagConstraints.gridx = 0;
188: gridBagConstraints.gridy = 2;
189: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
190: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
191: gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 0);
192: add(jLabel3, gridBagConstraints);
193: jLabel3.getAccessibleContext().setAccessibleName(
194: org.openide.util.NbBundle.getMessage(
195: FILESELCustomizer.class,
196: "ACSN_FILESEL_InitState"));
197: jLabel3.getAccessibleContext().setAccessibleDescription(
198: org.openide.util.NbBundle.getMessage(
199: FILESELCustomizer.class,
200: "ACSD_FILESEL_InitState"));
201:
202: org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1,
203: org.openide.util.NbBundle
204: .getMessage(FILESELCustomizer.class,
205: "LBL_FILESEL_disabled"));
206: jCheckBox1.setBorder(new javax.swing.border.EmptyBorder(
207: new java.awt.Insets(0, 0, 0, 0)));
208: jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
209: gridBagConstraints = new java.awt.GridBagConstraints();
210: gridBagConstraints.gridx = 1;
211: gridBagConstraints.gridy = 2;
212: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
213: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
214: gridBagConstraints.weighty = 1.0;
215: gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
216: add(jCheckBox1, gridBagConstraints);
217: jCheckBox1.getAccessibleContext().setAccessibleName(
218: org.openide.util.NbBundle.getMessage(
219: FILESELCustomizer.class,
220: "ACSN_FILESEL_disabled"));
221: jCheckBox1.getAccessibleContext().setAccessibleDescription(
222: org.openide.util.NbBundle.getMessage(
223: FILESELCustomizer.class,
224: "ACSD_FILESEL_disabled"));
225:
226: gridBagConstraints = new java.awt.GridBagConstraints();
227: gridBagConstraints.gridx = 1;
228: gridBagConstraints.gridy = 1;
229: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
230: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
231: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
232: add(jTextField2, gridBagConstraints);
233:
234: }
235:
236: // </editor-fold>//GEN-END:initComponents
237:
238: // Variables declaration - do not modify//GEN-BEGIN:variables
239: private javax.swing.ButtonGroup buttonGroup1;
240: private javax.swing.JCheckBox jCheckBox1;
241: private javax.swing.JLabel jLabel1;
242: private javax.swing.JLabel jLabel2;
243: private javax.swing.JLabel jLabel3;
244: private javax.swing.JTextField jTextField1;
245: private javax.swing.JTextField jTextField2;
246: // End of variables declaration//GEN-END:variables
247:
248: }
|