KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > core > palette > items > IfCustomizer


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.web.core.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.DefaultComboBoxModel JavaDoc;
25 import javax.swing.text.JTextComponent JavaDoc;
26 import org.openide.DialogDescriptor;
27 import org.openide.DialogDisplayer;
28 import org.openide.util.NbBundle;
29
30
31
32
33
34 /**
35  *
36  * @author Libor Kotouc
37  */

38 public class IfCustomizer extends javax.swing.JPanel JavaDoc {
39
40     private Dialog JavaDoc dialog = null;
41     private DialogDescriptor descriptor = null;
42     private boolean dialogOK = false;
43
44     If iF;
45     JTextComponent JavaDoc target;
46             
47     public IfCustomizer(If iF, JTextComponent JavaDoc target) {
48         this.iF = iF;
49         this.target = target;
50         
51         initComponents();
52
53         jComboBox2.setModel(new DefaultComboBoxModel JavaDoc(If.scopes));
54         jComboBox2.setSelectedIndex(iF.getScopeIndex());
55         
56     }
57     
58     public boolean showDialog() {
59         
60         dialogOK = false;
61         
62         String JavaDoc displayName = "";
63         try {
64             displayName = NbBundle.getBundle("org.netbeans.modules.web.core.palette.items.resources.Bundle").getString("NAME_jsp-If"); // NOI18N
65
}
66         catch (Exception JavaDoc e) {}
67         
68         descriptor = new DialogDescriptor
69                 (this, NbBundle.getMessage(IfCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true,
70                  DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
71                  new ActionListener JavaDoc() {
72                      public void actionPerformed(ActionEvent JavaDoc e) {
73                         if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
74                             evaluateInput();
75                             dialogOK = true;
76                         }
77                         dialog.dispose();
78              }
79          }
80                 );
81         
82         dialog = DialogDisplayer.getDefault().createDialog(descriptor);
83         dialog.setVisible(true);
84         repaint();
85         
86         return dialogOK;
87     }
88     
89     private void evaluateInput() {
90         
91         
92         String JavaDoc condition = jTextField1.getText();
93         iF.setCondition(condition);
94         
95         String JavaDoc variable = jTextField2.getText();
96         iF.setVariable(variable);
97         
98         int scopeIndex = jComboBox2.getSelectedIndex();
99         iF.setScopeIndex(scopeIndex);
100         
101     }
102     
103     /** This method is called from within the constructor to
104      * initialize the form.
105      * WARNING: Do NOT modify this code. The content of this method is
106      * always regenerated by the Form Editor.
107      */

108     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
109
private void initComponents() {
110         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
111
112         jFileChooser1 = new javax.swing.JFileChooser JavaDoc();
113         jLabel4 = new javax.swing.JLabel JavaDoc();
114         jTextField1 = new javax.swing.JTextField JavaDoc();
115         jLabel1 = new javax.swing.JLabel JavaDoc();
116         jLabel2 = new javax.swing.JLabel JavaDoc();
117         jComboBox2 = new javax.swing.JComboBox JavaDoc();
118         jTextField2 = new javax.swing.JTextField JavaDoc();
119         jLabel3 = new javax.swing.JLabel JavaDoc();
120
121         jFileChooser1.setCurrentDirectory(null);
122
123         setLayout(new java.awt.GridBagLayout JavaDoc());
124
125         jLabel4.setLabelFor(jComboBox2);
126         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(IfCustomizer.class, "LBL_If_Scope"));
127         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
128         gridBagConstraints.gridx = 0;
129         gridBagConstraints.gridy = 3;
130         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
131         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
132         gridBagConstraints.weighty = 1.0;
133         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 0);
134         add(jLabel4, gridBagConstraints);
135         jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSN_If_Scope"));
136         jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSD_If_Scope"));
137
138         jTextField1.setColumns(35);
139         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
140         gridBagConstraints.gridx = 1;
141         gridBagConstraints.gridy = 0;
142         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
143         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
144         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 12);
145         add(jTextField1, gridBagConstraints);
146
147         jLabel1.setLabelFor(jTextField1);
148         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(IfCustomizer.class, "LBL_If_Condition"));
149         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
150         gridBagConstraints.gridx = 0;
151         gridBagConstraints.gridy = 0;
152         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
153         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
154         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
155         add(jLabel1, gridBagConstraints);
156         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSN_If_Condition"));
157         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSD_If_Condition"));
158
159         jLabel2.setLabelFor(jTextField2);
160         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(IfCustomizer.class, "LBL_If_Variable"));
161         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
162         gridBagConstraints.gridx = 0;
163         gridBagConstraints.gridy = 1;
164         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
165         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
166         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
167         add(jLabel2, gridBagConstraints);
168         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSN_If_Variable"));
169         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSD_If_Variable"));
170
171         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
172         gridBagConstraints.gridx = 1;
173         gridBagConstraints.gridy = 3;
174         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
175         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
176         gridBagConstraints.weightx = 1.0;
177         gridBagConstraints.weighty = 1.0;
178         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 12, 12);
179         add(jComboBox2, gridBagConstraints);
180
181         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(12, 12, 0, 12);
187         add(jTextField2, gridBagConstraints);
188
189         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(IfCustomizer.class, "LBL_If_VariableHelp"));
190         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
191         gridBagConstraints.gridx = 1;
192         gridBagConstraints.gridy = 2;
193         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
194         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 12);
195         add(jLabel3, gridBagConstraints);
196         jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSN_If_VariableHelp"));
197         jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSD_If_VariableHelp"));
198
199     }// </editor-fold>//GEN-END:initComponents
200

201     
202     // Variables declaration - do not modify//GEN-BEGIN:variables
203
private javax.swing.JComboBox JavaDoc jComboBox2;
204     private javax.swing.JFileChooser JavaDoc jFileChooser1;
205     private javax.swing.JLabel JavaDoc jLabel1;
206     private javax.swing.JLabel JavaDoc jLabel2;
207     private javax.swing.JLabel JavaDoc jLabel3;
208     private javax.swing.JLabel JavaDoc jLabel4;
209     private javax.swing.JTextField JavaDoc jTextField1;
210     private javax.swing.JTextField JavaDoc jTextField2;
211     // End of variables declaration//GEN-END:variables
212

213 }
214
Popular Tags