KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > struts > dialogs > AddActionPanel


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.struts.dialogs;
21
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24 import javax.swing.DefaultComboBoxModel JavaDoc;
25 import javax.swing.SwingUtilities JavaDoc;
26 //import org.netbeans.modules.j2ee.common.FQNSearch;
27
import org.netbeans.modules.web.struts.StrutsConfigDataObject;
28 import org.netbeans.modules.web.struts.StrutsConfigUtilities;
29 import org.netbeans.modules.web.struts.config.model.Action;
30 import org.netbeans.modules.web.struts.config.model.FormBean;
31 import org.openide.util.NbBundle;
32
33 /**
34  *
35  * @author Milan Kuchtiak
36  */

37 public class AddActionPanel extends javax.swing.JPanel JavaDoc implements ValidatingPanel {
38     /** Creates new form AddFIActionPanel */
39     StrutsConfigDataObject config;
40     public AddActionPanel(StrutsConfigDataObject dObject) {
41         config=dObject;
42         initComponents();
43         List JavaDoc actions = StrutsConfigUtilities.getAllActionsInModule(dObject);
44         DefaultComboBoxModel JavaDoc model = (DefaultComboBoxModel JavaDoc)CBInputAction.getModel();
45         Iterator JavaDoc iter = actions.iterator();
46         while (iter.hasNext())
47             model.addElement(((Action)iter.next()).getAttributeValue("path")); //NOI18N
48

49         List JavaDoc formBeans = StrutsConfigUtilities.getAllFormBeansInModule(dObject);
50         model = (DefaultComboBoxModel JavaDoc)CBFormName.getModel();
51         iter = formBeans.iterator();
52         while (iter.hasNext())
53             model.addElement(((FormBean)iter.next()).getAttributeValue("name")); //NOI18N
54
}
55
56     public String JavaDoc validatePanel() {
57         if (TFActionClass.getText().trim().length()==0)
58             return NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyActionClass");
59         String JavaDoc actionPath = TFActionPath.getText().trim();
60         if (actionPath.length()==0 || actionPath.equals("/")) //NOI18N
61
return NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyActionPath");
62         if (!actionPath.startsWith("/") ) //NOI18N
63
return NbBundle.getMessage(AddActionPanel.class,"MSG_IncorrectActionPath", actionPath);
64         if (containsActionPath(actionPath)) //NOI18N
65
return NbBundle.getMessage(AddActionPanel.class,"MSG_DupliciteActionPath",actionPath);
66         if (CHBUseFormBean.isSelected()) {
67             if (CBFormName.getSelectedItem()==null)
68                 NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyFormName");
69             if (RBInputResource.isSelected()) {
70                 String JavaDoc inputResource = TFInputResource.getText().trim();
71                 if (inputResource.length()==0 || inputResource.equals("/")) //NOI18N
72
return NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyInputResource");
73             } else if (CBInputAction.getSelectedItem()==null) {
74                 return NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyAction");
75             }
76         }
77         return null;
78     }
79
80     public javax.swing.AbstractButton JavaDoc[] getStateChangeComponents() {
81         return new javax.swing.AbstractButton JavaDoc[]{ CHBUseFormBean, RBInputResource, RBInputAction };
82     }
83
84     public javax.swing.text.JTextComponent JavaDoc[] getDocumentChangeComponents() {
85         return new javax.swing.text.JTextComponent JavaDoc[]{TFActionClass, TFActionPath, TFInputResource};
86     }
87     
88     /** This method is called from within the constructor to
89      * initialize the form.
90      * WARNING: Do NOT modify this code. The content of this method is
91      * always regenerated by the Form Editor.
92      */

93     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
94
private void initComponents() {
95         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
96
97         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
98         buttonGroup2 = new javax.swing.ButtonGroup JavaDoc();
99         jLabelFormName = new javax.swing.JLabel JavaDoc();
100         CBFormName = new javax.swing.JComboBox JavaDoc();
101         CBInputAction = new javax.swing.JComboBox JavaDoc();
102         TFInputResource = new javax.swing.JTextField JavaDoc();
103         CHBUseFormBean = new javax.swing.JCheckBox JavaDoc();
104         jButtonBrowse = new javax.swing.JButton JavaDoc();
105         jLabelScope = new javax.swing.JLabel JavaDoc();
106         jLabelAttribute = new javax.swing.JLabel JavaDoc();
107         TFAttribute = new javax.swing.JTextField JavaDoc();
108         CHBValidate = new javax.swing.JCheckBox JavaDoc();
109         jLabelParameter = new javax.swing.JLabel JavaDoc();
110         TFParameter = new javax.swing.JTextField JavaDoc();
111         RBInputResource = new javax.swing.JRadioButton JavaDoc();
112         RBInputAction = new javax.swing.JRadioButton JavaDoc();
113         jPanel1 = new javax.swing.JPanel JavaDoc();
114         RBSession = new javax.swing.JRadioButton JavaDoc();
115         RBRequest = new javax.swing.JRadioButton JavaDoc();
116         jLabelActionClass = new javax.swing.JLabel JavaDoc();
117         TFActionClass = new javax.swing.JTextField JavaDoc();
118         jButtonBrowseClass = new javax.swing.JButton JavaDoc();
119         jLabelActionPath = new javax.swing.JLabel JavaDoc();
120         TFActionPath = new javax.swing.JTextField JavaDoc();
121
122         setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 11, 11));
123         setLayout(new java.awt.GridBagLayout JavaDoc());
124
125         jLabelFormName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_FormName_mnem").charAt(0));
126         jLabelFormName.setLabelFor(CBFormName);
127         jLabelFormName.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_FormName")); // NOI18N
128
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
129         gridBagConstraints.gridx = 0;
130         gridBagConstraints.gridy = 3;
131         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
132         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
133         add(jLabelFormName, gridBagConstraints);
134         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
135         gridBagConstraints.gridx = 1;
136         gridBagConstraints.gridy = 3;
137         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
138         gridBagConstraints.weightx = 1.0;
139         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
140         add(CBFormName, gridBagConstraints);
141         java.util.ResourceBundle JavaDoc bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/dialogs/Bundle"); // NOI18N
142
CBFormName.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CBFormName")); // NOI18N
143

144         CBInputAction.setEnabled(false);
145         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
146         gridBagConstraints.gridx = 1;
147         gridBagConstraints.gridy = 5;
148         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
149         gridBagConstraints.weightx = 1.0;
150         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
151         add(CBInputAction, gridBagConstraints);
152         CBInputAction.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CBInputAction")); // NOI18N
153

154         TFInputResource.setText("/");
155         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
156         gridBagConstraints.gridx = 1;
157         gridBagConstraints.gridy = 4;
158         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
159         gridBagConstraints.weightx = 1.0;
160         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
161         add(TFInputResource, gridBagConstraints);
162         TFInputResource.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_TFInputResource")); // NOI18N
163
TFInputResource.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFinputResource")); // NOI18N
164

165         CHBUseFormBean.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_UseFormBean_mnem").charAt(0));
166         CHBUseFormBean.setSelected(true);
167         CHBUseFormBean.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "CB_UseFormBean")); // NOI18N
168
CHBUseFormBean.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
169         CHBUseFormBean.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
170         CHBUseFormBean.addItemListener(new java.awt.event.ItemListener JavaDoc() {
171             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
172                 CHBUseFormBeanItemStateChanged(evt);
173             }
174         });
175         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
176         gridBagConstraints.gridx = 0;
177         gridBagConstraints.gridy = 2;
178         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
179         gridBagConstraints.insets = new java.awt.Insets JavaDoc(20, 0, 0, 0);
180         add(CHBUseFormBean, gridBagConstraints);
181         CHBUseFormBean.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CHBUseFormBean")); // NOI18N
182

183         jButtonBrowse.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_BrowseButton_mnem").charAt(0));
184         jButtonBrowse.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_BrowseButton")); // NOI18N
185
jButtonBrowse.addActionListener(new java.awt.event.ActionListener JavaDoc() {
186             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
187                 jButtonBrowseActionPerformed(evt);
188             }
189         });
190         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
191         gridBagConstraints.gridx = 2;
192         gridBagConstraints.gridy = 4;
193         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 0);
194         add(jButtonBrowse, gridBagConstraints);
195         jButtonBrowse.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_jButtonBrowse")); // NOI18N
196

197         jLabelScope.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Scope")); // NOI18N
198
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
199         gridBagConstraints.gridx = 0;
200         gridBagConstraints.gridy = 6;
201         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
202         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
203         add(jLabelScope, gridBagConstraints);
204
205         jLabelAttribute.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Attribute_mnem").charAt(0));
206         jLabelAttribute.setLabelFor(TFAttribute);
207         jLabelAttribute.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Attribute")); // NOI18N
208
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
209         gridBagConstraints.gridx = 0;
210         gridBagConstraints.gridy = 7;
211         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
212         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
213         add(jLabelAttribute, gridBagConstraints);
214         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
215         gridBagConstraints.gridx = 1;
216         gridBagConstraints.gridy = 7;
217         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
218         gridBagConstraints.weightx = 1.0;
219         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
220         add(TFAttribute, gridBagConstraints);
221         TFAttribute.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFAttribute")); // NOI18N
222

223         CHBValidate.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "CB_Validate_mnem").charAt(0));
224         CHBValidate.setSelected(true);
225         CHBValidate.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "CB_Validate")); // NOI18N
226
CHBValidate.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
227         CHBValidate.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
228         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
229         gridBagConstraints.gridx = 0;
230         gridBagConstraints.gridy = 8;
231         gridBagConstraints.gridwidth = 2;
232         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
233         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
234         add(CHBValidate, gridBagConstraints);
235         CHBValidate.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CHBValidate")); // NOI18N
236

237         jLabelParameter.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Parameter_mnem").charAt(0));
238         jLabelParameter.setLabelFor(TFParameter);
239         jLabelParameter.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Parameter")); // NOI18N
240
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
241         gridBagConstraints.gridx = 0;
242         gridBagConstraints.gridy = 9;
243         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
244         gridBagConstraints.insets = new java.awt.Insets JavaDoc(20, 0, 0, 0);
245         add(jLabelParameter, gridBagConstraints);
246         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
247         gridBagConstraints.gridx = 1;
248         gridBagConstraints.gridy = 9;
249         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
250         gridBagConstraints.weightx = 1.0;
251         gridBagConstraints.insets = new java.awt.Insets JavaDoc(20, 12, 0, 0);
252         add(TFParameter, gridBagConstraints);
253         TFParameter.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFParameter")); // NOI18N
254

255         buttonGroup1.add(RBInputResource);
256         RBInputResource.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_InputResource_mnem").charAt(0));
257         RBInputResource.setSelected(true);
258         RBInputResource.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_InputResource")); // NOI18N
259
RBInputResource.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
260         RBInputResource.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
261         RBInputResource.addItemListener(new java.awt.event.ItemListener JavaDoc() {
262             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
263                 RBInputResourceItemStateChanged(evt);
264             }
265         });
266         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
267         gridBagConstraints.gridx = 0;
268         gridBagConstraints.gridy = 4;
269         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
270         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
271         add(RBInputResource, gridBagConstraints);
272         RBInputResource.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RBInputResources")); // NOI18N
273

274         buttonGroup1.add(RBInputAction);
275         RBInputAction.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_InputAction_mnem").charAt(0));
276         RBInputAction.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_InputAction")); // NOI18N
277
RBInputAction.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
278         RBInputAction.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
279         RBInputAction.addItemListener(new java.awt.event.ItemListener JavaDoc() {
280             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
281                 RBInputActionItemStateChanged(evt);
282             }
283         });
284         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
285         gridBagConstraints.gridx = 0;
286         gridBagConstraints.gridy = 5;
287         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
288         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
289         add(RBInputAction, gridBagConstraints);
290         RBInputAction.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RBInputAction")); // NOI18N
291

292         buttonGroup2.add(RBSession);
293         RBSession.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_Session_mnem").charAt(0));
294         RBSession.setSelected(true);
295         RBSession.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_Sesson")); // NOI18N
296
RBSession.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
297         RBSession.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
298         jPanel1.add(RBSession);
299         RBSession.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RBSession")); // NOI18N
300

301         buttonGroup2.add(RBRequest);
302         RBRequest.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_Request_mnem").charAt(0));
303         RBRequest.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_Request")); // NOI18N
304
RBRequest.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
305         RBRequest.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
306         jPanel1.add(RBRequest);
307         RBRequest.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RBRequest")); // NOI18N
308

309         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
310         gridBagConstraints.gridx = 1;
311         gridBagConstraints.gridy = 6;
312         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
313         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
314         add(jPanel1, gridBagConstraints);
315         jPanel1.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Scope")); // NOI18N
316

317         jLabelActionClass.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_ActionClass_mnem").charAt(0));
318         jLabelActionClass.setLabelFor(TFActionClass);
319         jLabelActionClass.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_ActionClass")); // NOI18N
320
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
321         gridBagConstraints.gridx = 0;
322         gridBagConstraints.gridy = 0;
323         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
324         add(jLabelActionClass, gridBagConstraints);
325
326         TFActionClass.setColumns(30);
327         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
328         gridBagConstraints.gridx = 1;
329         gridBagConstraints.gridy = 0;
330         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
331         gridBagConstraints.weightx = 1.0;
332         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 0);
333         add(TFActionClass, gridBagConstraints);
334         TFActionClass.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFActionClass")); // NOI18N
335

336         jButtonBrowseClass.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Browse_mnem").charAt(0));
337         jButtonBrowseClass.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_BrowseButton")); // NOI18N
338
jButtonBrowseClass.setEnabled(false);
339         jButtonBrowseClass.addActionListener(new java.awt.event.ActionListener JavaDoc() {
340             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
341                 jButtonBrowseClassActionPerformed(evt);
342             }
343         });
344         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
345         gridBagConstraints.gridx = 2;
346         gridBagConstraints.gridy = 0;
347         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 5, 0, 0);
348         add(jButtonBrowseClass, gridBagConstraints);
349         jButtonBrowseClass.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_jButtonBrowseClass")); // NOI18N
350

351         jLabelActionPath.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_ActionPath_mnem").charAt(0));
352         jLabelActionPath.setLabelFor(TFActionPath);
353         jLabelActionPath.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_ActionPath")); // NOI18N
354
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
355         gridBagConstraints.gridx = 0;
356         gridBagConstraints.gridy = 1;
357         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
358         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
359         add(jLabelActionPath, gridBagConstraints);
360
361         TFActionPath.setText("/");
362         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
363         gridBagConstraints.gridx = 1;
364         gridBagConstraints.gridy = 1;
365         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
366         gridBagConstraints.weightx = 1.0;
367         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
368         add(TFActionPath, gridBagConstraints);
369         TFActionPath.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFActionPath")); // NOI18N
370

371         getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_AddActionDialog")); // NOI18N
372
}// </editor-fold>//GEN-END:initComponents
373

374     private void jButtonBrowseClassActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonBrowseClassActionPerformed
375
SwingUtilities.invokeLater(new Runnable JavaDoc() {
376             public void run() {
377             //TODO: RETOUCHE
378
// FQNSearch.showFastOpen(TFActionClass);
379
}
380         });
381                 
382     }//GEN-LAST:event_jButtonBrowseClassActionPerformed
383

384     private void jButtonBrowseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonBrowseActionPerformed
385
// TODO add your handling code here:
386
try{
387         org.netbeans.api.project.SourceGroup[] groups = StrutsConfigUtilities.getDocBaseGroups(config.getPrimaryFile());
388             org.openide.filesystems.FileObject fo = BrowseFolders.showDialog(groups);
389             if (fo!=null) {
390                 String JavaDoc res = "/"+StrutsConfigUtilities.getResourcePath(groups,fo,'/',true);
391                 TFInputResource.setText(res);
392             }
393         } catch (java.io.IOException JavaDoc ex) {}
394     }//GEN-LAST:event_jButtonBrowseActionPerformed
395

396     private void RBInputActionItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_RBInputActionItemStateChanged
397
// TODO add your handling code here:
398
boolean selected = RBInputAction.isSelected();
399         TFInputResource.setEditable(!selected);
400         jButtonBrowse.setEnabled(!selected);
401         CBInputAction.setEnabled(selected);
402     }//GEN-LAST:event_RBInputActionItemStateChanged
403

404     private void RBInputResourceItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_RBInputResourceItemStateChanged
405
// TODO add your handling code here:
406
boolean selected = RBInputResource.isSelected();
407         TFInputResource.setEditable(selected);
408         jButtonBrowse.setEnabled(selected);
409         CBInputAction.setEnabled(!selected);
410     }//GEN-LAST:event_RBInputResourceItemStateChanged
411

412     private void CHBUseFormBeanItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_CHBUseFormBeanItemStateChanged
413
// TODO add your handling code here:
414
boolean selected = CHBUseFormBean.isSelected();
415         CBFormName.setEnabled(selected);
416         RBInputResource.setEnabled(selected);
417         RBInputAction.setEnabled(selected);
418         if (selected) {
419             if (RBInputResource.isSelected()) {
420                 TFInputResource.setEditable(true);
421                 jButtonBrowse.setEnabled(true);
422             } else {
423                 CBInputAction.setEnabled(true);
424             }
425         } else {
426             TFInputResource.setEditable(false);
427             jButtonBrowse.setEnabled(false);
428             CBInputAction.setEnabled(false);
429         }
430         
431         RBSession.setEnabled(selected);
432         RBRequest.setEnabled(selected);
433         TFAttribute.setEditable(selected);
434         CHBValidate.setEnabled(selected);
435     }//GEN-LAST:event_CHBUseFormBeanItemStateChanged
436

437     
438     // Variables declaration - do not modify//GEN-BEGIN:variables
439
private javax.swing.JComboBox JavaDoc CBFormName;
440     private javax.swing.JComboBox JavaDoc CBInputAction;
441     private javax.swing.JCheckBox JavaDoc CHBUseFormBean;
442     private javax.swing.JCheckBox JavaDoc CHBValidate;
443     private javax.swing.JRadioButton JavaDoc RBInputAction;
444     private javax.swing.JRadioButton JavaDoc RBInputResource;
445     private javax.swing.JRadioButton JavaDoc RBRequest;
446     private javax.swing.JRadioButton JavaDoc RBSession;
447     private javax.swing.JTextField JavaDoc TFActionClass;
448     private javax.swing.JTextField JavaDoc TFActionPath;
449     private javax.swing.JTextField JavaDoc TFAttribute;
450     private javax.swing.JTextField JavaDoc TFInputResource;
451     private javax.swing.JTextField JavaDoc TFParameter;
452     private javax.swing.ButtonGroup JavaDoc buttonGroup1;
453     private javax.swing.ButtonGroup JavaDoc buttonGroup2;
454     private javax.swing.JButton JavaDoc jButtonBrowse;
455     private javax.swing.JButton JavaDoc jButtonBrowseClass;
456     private javax.swing.JLabel JavaDoc jLabelActionClass;
457     private javax.swing.JLabel JavaDoc jLabelActionPath;
458     private javax.swing.JLabel JavaDoc jLabelAttribute;
459     private javax.swing.JLabel JavaDoc jLabelFormName;
460     private javax.swing.JLabel JavaDoc jLabelParameter;
461     private javax.swing.JLabel JavaDoc jLabelScope;
462     private javax.swing.JPanel JavaDoc jPanel1;
463     // End of variables declaration//GEN-END:variables
464

465     public String JavaDoc getActionClass() {
466         return TFActionClass.getText().trim();
467     }
468     
469     public String JavaDoc getActionPath() {
470         return TFActionPath.getText().trim();
471     }
472     
473     public String JavaDoc getFormName() {
474         return (String JavaDoc)CBFormName.getSelectedItem();
475     }
476     
477     public String JavaDoc getInput() {
478         if (!CHBUseFormBean.isSelected()) return null;
479         if (RBInputResource.isSelected()) {
480             String JavaDoc input=TFInputResource.getText().trim();
481             return input.length()==0?null:input;
482         } else {
483             return (String JavaDoc)CBInputAction.getSelectedItem();
484         }
485     }
486     
487     public String JavaDoc getScope() {
488         if (!CHBUseFormBean.isSelected()) return null;
489         if (RBSession.isSelected()) {
490             return "session"; //NOI18N
491
} else {
492             return "request"; //NOI18N
493
}
494     }
495     
496     public String JavaDoc getValidate() {
497         if (!CHBUseFormBean.isSelected()) return null;
498         if (CHBValidate.isSelected()) return null;
499         return "false"; //NOI18N
500
}
501     
502     public String JavaDoc getAttribute() {
503         if (!CHBUseFormBean.isSelected()) return null;
504         String JavaDoc attr=TFAttribute.getText().trim();
505         return attr.length()==0?null:attr;
506     }
507     
508     public String JavaDoc getParameter() {
509         String JavaDoc param=TFParameter.getText().trim();
510         return param.length()==0?null:param;
511     }
512     
513     public boolean isActionFormUsed(){
514         return CHBUseFormBean.isSelected();
515     }
516     
517     private boolean containsActionPath(String JavaDoc path) {
518         DefaultComboBoxModel JavaDoc model = (DefaultComboBoxModel JavaDoc)CBInputAction.getModel();
519         for (int i=0; i<model.getSize(); i++) {
520             if (path.equals(model.getElementAt(i))) return true;
521         }
522         return false;
523     }
524 }
525
Popular Tags