KickJava   Java API By Example, From Geeks To Geeks.

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


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

35 public class FILESELCustomizer extends javax.swing.JPanel JavaDoc {
36
37     private Dialog JavaDoc dialog = null;
38     private DialogDescriptor descriptor = null;
39     private boolean dialogOK = false;
40
41     FILESEL filesel;
42
43     public FILESELCustomizer(FILESEL filesel) {
44         this.filesel = filesel;
45         
46         initComponents();
47     }
48     
49     public boolean showDialog() {
50         
51         dialogOK = false;
52         
53         String JavaDoc displayName = "";
54         try {
55             displayName = NbBundle.getBundle("org.netbeans.modules.html.palette.items.resources.Bundle").getString("NAME_html-FILESEL"); // NOI18N
56
}
57         catch (Exception JavaDoc e) {}
58         
59         descriptor = new DialogDescriptor
60                 (this, NbBundle.getMessage(FILESELCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true,
61                  DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
62                  new ActionListener JavaDoc() {
63                      public void actionPerformed(ActionEvent JavaDoc e) {
64                         if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
65                             evaluateInput();
66                             dialogOK = true;
67                         }
68                         dialog.dispose();
69              }
70          }
71                 );
72         
73         dialog = DialogDisplayer.getDefault().createDialog(descriptor);
74         dialog.setVisible(true);
75         repaint();
76         
77         return dialogOK;
78     }
79     
80     private void evaluateInput() {
81         
82         String JavaDoc name = jTextField1.getText();
83         filesel.setName(name);
84
85         String JavaDoc width = jTextField2.getText();
86         filesel.setWidth(width);
87         
88         filesel.setDisabled(jCheckBox1.isSelected());
89         
90     }
91     
92     /** This method is called from within the constructor to
93      * initialize the form.
94      * WARNING: Do NOT modify this code. The content of this method is
95      * always regenerated by the Form Editor.
96      */

97     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
98
private void initComponents() {
99         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
100
101         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
102         jTextField1 = new javax.swing.JTextField JavaDoc();
103         jLabel1 = new javax.swing.JLabel JavaDoc();
104         jLabel2 = new javax.swing.JLabel JavaDoc();
105         jLabel3 = new javax.swing.JLabel JavaDoc();
106         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
107         jTextField2 = new javax.swing.JTextField JavaDoc();
108
109         setLayout(new java.awt.GridBagLayout JavaDoc());
110
111         jTextField1.setColumns(30);
112         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
113         gridBagConstraints.gridx = 1;
114         gridBagConstraints.gridy = 0;
115         gridBagConstraints.gridwidth = 2;
116         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
117         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
118         gridBagConstraints.weightx = 1.0;
119         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
120         add(jTextField1, gridBagConstraints);
121
122         jLabel1.setLabelFor(jTextField1);
123         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "LBL_FILESEL_Name"));
124         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
125         gridBagConstraints.gridx = 0;
126         gridBagConstraints.gridy = 0;
127         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
128         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
129         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
130         add(jLabel1, gridBagConstraints);
131         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "ACSN_FILESEL_Name"));
132         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "ACSD_FILESEL_Name"));
133
134         jLabel2.setLabelFor(jTextField2);
135         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "LBL_FILESEL_Width"));
136         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
137         gridBagConstraints.gridx = 0;
138         gridBagConstraints.gridy = 1;
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(jLabel2, gridBagConstraints);
143         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "ACSN_FILESEL_Width"));
144         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "ACSD_FILESEL_Width"));
145
146         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "LBL_FILESEL_InitState"));
147         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
148         gridBagConstraints.gridx = 0;
149         gridBagConstraints.gridy = 2;
150         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
151         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
152         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 0);
153         add(jLabel3, gridBagConstraints);
154         jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "ACSN_FILESEL_InitState"));
155         jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "ACSD_FILESEL_InitState"));
156
157         org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "LBL_FILESEL_disabled"));
158         jCheckBox1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(0, 0, 0, 0)));
159         jCheckBox1.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
160         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
161         gridBagConstraints.gridx = 1;
162         gridBagConstraints.gridy = 2;
163         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
164         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
165         gridBagConstraints.weighty = 1.0;
166         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 12);
167         add(jCheckBox1, gridBagConstraints);
168         jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "ACSN_FILESEL_disabled"));
169         jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(FILESELCustomizer.class, "ACSD_FILESEL_disabled"));
170
171         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
172         gridBagConstraints.gridx = 1;
173         gridBagConstraints.gridy = 1;
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, 12);
177         add(jTextField2, gridBagConstraints);
178
179     }
180     // </editor-fold>//GEN-END:initComponents
181

182     
183     // Variables declaration - do not modify//GEN-BEGIN:variables
184
private javax.swing.ButtonGroup JavaDoc buttonGroup1;
185     private javax.swing.JCheckBox JavaDoc jCheckBox1;
186     private javax.swing.JLabel JavaDoc jLabel1;
187     private javax.swing.JLabel JavaDoc jLabel2;
188     private javax.swing.JLabel JavaDoc jLabel3;
189     private javax.swing.JTextField JavaDoc jTextField1;
190     private javax.swing.JTextField JavaDoc jTextField2;
191     // End of variables declaration//GEN-END:variables
192

193 }
194
Popular Tags