KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > struts > wizards > ActionPanel1Visual


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.wizards;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24 import org.netbeans.modules.j2ee.dd.api.common.InitParam;
25 import org.netbeans.modules.j2ee.dd.api.web.Servlet;
26 import org.netbeans.modules.web.struts.config.model.Action;
27 import org.netbeans.modules.web.struts.config.model.FormBean;
28 import org.netbeans.modules.web.struts.dialogs.BrowseFolders;
29 import org.openide.WizardDescriptor;
30 import org.openide.loaders.DataObject;
31 import org.openide.loaders.DataObjectNotFoundException;
32 import org.openide.util.HelpCtx;
33 import org.netbeans.api.project.Project;
34 import org.netbeans.modules.web.api.webmodule.WebModule;
35 import org.netbeans.modules.web.struts.StrutsConfigUtilities;
36 import org.netbeans.modules.web.struts.StrutsConfigDataObject;
37 import org.openide.util.NbBundle;
38
39 public class ActionPanel1Visual extends javax.swing.JPanel JavaDoc implements HelpCtx.Provider {
40     String JavaDoc configFile;
41     private ActionPanel1 panel;
42     
43     /** Creates new form ActionPanel1Visual */
44     public ActionPanel1Visual(ActionPanel1 panel) {
45         this.panel=panel;
46         initComponents();
47         setName(NbBundle.getMessage(ActionPanel1Visual.class,"TITLE_FormBean&Parameter"));
48         putClientProperty("NewFileWizard_Title", //NOI18N
49
NbBundle.getMessage(ActionPanel1Visual.class, "TITLE_StrutsAction"));
50     }
51     
52     /** This method is called from within the constructor to
53      * initialize the form.
54      * WARNING: Do NOT modify this code. The content of this method is
55      * always regenerated by the Form Editor.
56      */

57     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
58
private void initComponents() {
59         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
60
61         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
62         buttonGroup2 = new javax.swing.ButtonGroup JavaDoc();
63         jLabelFormName = new javax.swing.JLabel JavaDoc();
64         CBFormName = new javax.swing.JComboBox JavaDoc();
65         CBInputAction = new javax.swing.JComboBox JavaDoc();
66         TFInputResource = new javax.swing.JTextField JavaDoc();
67         CHBUseFormBean = new javax.swing.JCheckBox JavaDoc();
68         jButtonBrowse = new javax.swing.JButton JavaDoc();
69         jPanel1 = new javax.swing.JPanel JavaDoc();
70         RBSession = new javax.swing.JRadioButton JavaDoc();
71         RBRequest = new javax.swing.JRadioButton JavaDoc();
72         jLabelScope = new javax.swing.JLabel JavaDoc();
73         jLabelAttribute = new javax.swing.JLabel JavaDoc();
74         TFAttribute = new javax.swing.JTextField JavaDoc();
75         CHBValidate = new javax.swing.JCheckBox JavaDoc();
76         jLabelParameter = new javax.swing.JLabel JavaDoc();
77         TFParameter = new javax.swing.JTextField JavaDoc();
78         RBInputResource = new javax.swing.JRadioButton JavaDoc();
79         RBInputAction = new javax.swing.JRadioButton JavaDoc();
80         jParameterSpecificLabel = new javax.swing.JLabel JavaDoc();
81
82         setLayout(new java.awt.GridBagLayout JavaDoc());
83
84         getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_ActionPanel1"));
85         jLabelFormName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_FormName_mnem").charAt(0));
86         jLabelFormName.setLabelFor(CBFormName);
87         jLabelFormName.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_FormName"));
88         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
89         gridBagConstraints.gridx = 0;
90         gridBagConstraints.gridy = 1;
91         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
92         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
93         add(jLabelFormName, gridBagConstraints);
94
95         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
96         gridBagConstraints.gridx = 1;
97         gridBagConstraints.gridy = 1;
98         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
99         gridBagConstraints.weightx = 1.0;
100         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
101         add(CBFormName, gridBagConstraints);
102         CBFormName.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_CBFormName"));
103
104         CBInputAction.setEnabled(false);
105         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
106         gridBagConstraints.gridx = 1;
107         gridBagConstraints.gridy = 3;
108         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
109         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
110         add(CBInputAction, gridBagConstraints);
111         CBInputAction.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("RB_InputAction"));
112         CBInputAction.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_CBInputAction"));
113
114         TFInputResource.setText("/");
115         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
116         gridBagConstraints.gridx = 1;
117         gridBagConstraints.gridy = 2;
118         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
119         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
120         add(TFInputResource, gridBagConstraints);
121         TFInputResource.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("RB_InputResource"));
122         TFInputResource.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_TFInputResource"));
123
124         CHBUseFormBean.setMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_UseFormBean_mnem").charAt(0));
125         CHBUseFormBean.setSelected(true);
126         CHBUseFormBean.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "CB_UseFormBean"));
127         CHBUseFormBean.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
128         CHBUseFormBean.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
129         CHBUseFormBean.addItemListener(new java.awt.event.ItemListener JavaDoc() {
130             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
131                 CHBUseFormBeanItemStateChanged(evt);
132             }
133         });
134
135         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
136         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
137         add(CHBUseFormBean, gridBagConstraints);
138         CHBUseFormBean.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_CHBUseFormBean"));
139
140         jButtonBrowse.setMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_BrowseButton_mnem").charAt(0));
141         jButtonBrowse.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_BrowseButton"));
142         jButtonBrowse.addActionListener(new java.awt.event.ActionListener JavaDoc() {
143             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
144                 jButtonBrowseActionPerformed(evt);
145             }
146         });
147
148         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
149         gridBagConstraints.gridx = 2;
150         gridBagConstraints.gridy = 2;
151         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 0);
152         add(jButtonBrowse, gridBagConstraints);
153         jButtonBrowse.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_jButtonBrowse"));
154
155         buttonGroup1.add(RBSession);
156         RBSession.setMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "RB_Session_mnem").charAt(0));
157         RBSession.setSelected(true);
158         RBSession.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "RB_Sesson"));
159         RBSession.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
160         RBSession.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
161         jPanel1.add(RBSession);
162         RBSession.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_RBSession"));
163
164         buttonGroup1.add(RBRequest);
165         RBRequest.setMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "RB_Request_mnem").charAt(0));
166         RBRequest.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "RB_Request"));
167         RBRequest.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
168         RBRequest.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
169         jPanel1.add(RBRequest);
170         RBRequest.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_Request"));
171
172         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
173         gridBagConstraints.gridx = 1;
174         gridBagConstraints.gridy = 4;
175         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
176         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
177         add(jPanel1, gridBagConstraints);
178
179         jLabelScope.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_Scope"));
180         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
181         gridBagConstraints.gridx = 0;
182         gridBagConstraints.gridy = 4;
183         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
184         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
185         add(jLabelScope, gridBagConstraints);
186
187         jLabelAttribute.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_Attribute_mnem").charAt(0));
188         jLabelAttribute.setLabelFor(TFAttribute);
189         jLabelAttribute.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_Attribute"));
190         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
191         gridBagConstraints.gridx = 0;
192         gridBagConstraints.gridy = 5;
193         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
194         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
195         add(jLabelAttribute, gridBagConstraints);
196
197         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
198         gridBagConstraints.gridx = 1;
199         gridBagConstraints.gridy = 5;
200         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
201         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
202         add(TFAttribute, gridBagConstraints);
203         TFAttribute.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_TFAttribute"));
204
205         CHBValidate.setMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "CB_Validate_mnem").charAt(0));
206         CHBValidate.setSelected(true);
207         CHBValidate.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "CB_Validate"));
208         CHBValidate.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
209         CHBValidate.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
210         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
211         gridBagConstraints.gridx = 0;
212         gridBagConstraints.gridy = 6;
213         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
214         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
215         add(CHBValidate, gridBagConstraints);
216         CHBValidate.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_CHBValidate"));
217
218         jLabelParameter.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_Parameter_mnem").charAt(0));
219         jLabelParameter.setLabelFor(TFParameter);
220         jLabelParameter.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "LBL_Parameter"));
221         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
222         gridBagConstraints.gridx = 0;
223         gridBagConstraints.gridy = 7;
224         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
225         gridBagConstraints.insets = new java.awt.Insets JavaDoc(20, 0, 0, 0);
226         add(jLabelParameter, gridBagConstraints);
227
228         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
229         gridBagConstraints.gridx = 1;
230         gridBagConstraints.gridy = 7;
231         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
232         gridBagConstraints.insets = new java.awt.Insets JavaDoc(20, 12, 0, 0);
233         add(TFParameter, gridBagConstraints);
234         TFParameter.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_TFParameter"));
235
236         buttonGroup2.add(RBInputResource);
237         RBInputResource.setMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "RB_InputResource_mnem").charAt(0));
238         RBInputResource.setSelected(true);
239         RBInputResource.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "RB_InputResource"));
240         RBInputResource.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
241         RBInputResource.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
242         RBInputResource.addItemListener(new java.awt.event.ItemListener JavaDoc() {
243             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
244                 RBInputResourceItemStateChanged(evt);
245             }
246         });
247
248         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
249         gridBagConstraints.gridx = 0;
250         gridBagConstraints.gridy = 2;
251         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
252         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
253         add(RBInputResource, gridBagConstraints);
254         RBInputResource.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_RBInputResource"));
255
256         buttonGroup2.add(RBInputAction);
257         RBInputAction.setMnemonic(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "RB_InputAction_mnem").charAt(0));
258         RBInputAction.setText(org.openide.util.NbBundle.getMessage(ActionPanel1Visual.class, "RB_InputAction"));
259         RBInputAction.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
260         RBInputAction.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
261         RBInputAction.addItemListener(new java.awt.event.ItemListener JavaDoc() {
262             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
263                 RBInputActionItemStateChanged(evt);
264             }
265         });
266
267         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
268         gridBagConstraints.gridx = 0;
269         gridBagConstraints.gridy = 3;
270         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
271         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 0);
272         add(RBInputAction, gridBagConstraints);
273         RBInputAction.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("RBInputAction"));
274
275         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
276         gridBagConstraints.gridx = 1;
277         gridBagConstraints.gridy = 8;
278         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
279         gridBagConstraints.weighty = 1.0;
280         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 0);
281         add(jParameterSpecificLabel, gridBagConstraints);
282
283     }// </editor-fold>//GEN-END:initComponents
284

285     private void jButtonBrowseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonBrowseActionPerformed
286
// TODO add your handling code here:
287
Project proj = panel.getProject();
288         WebModule wm = WebModule.getWebModule(proj.getProjectDirectory());
289         org.openide.filesystems.FileObject configFO = wm.getDocumentBase().getFileObject(configFile);
290         if (configFO!=null) {
291             try {
292                 DataObject dObj = DataObject.find(configFO);
293                 if (dObj instanceof StrutsConfigDataObject) {
294                     StrutsConfigDataObject config = (StrutsConfigDataObject)dObj;
295                     org.netbeans.api.project.SourceGroup[] groups = StrutsConfigUtilities.getDocBaseGroups(configFO);
296                     org.openide.filesystems.FileObject fo = BrowseFolders.showDialog(groups);
297                     if (fo!=null) {
298                         String JavaDoc res = "/"+StrutsConfigUtilities.getResourcePath(groups,fo,'/',true);
299                         TFInputResource.setText(res);
300                     }
301                 }
302             } catch (DataObjectNotFoundException ex) {} catch (java.io.IOException JavaDoc ex) {}
303         }
304     }//GEN-LAST:event_jButtonBrowseActionPerformed
305

306     private void RBInputActionItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_RBInputActionItemStateChanged
307
// TODO add your handling code here:
308
boolean selected = RBInputAction.isSelected();
309         TFInputResource.setEditable(!selected);
310         jButtonBrowse.setEnabled(!selected);
311         CBInputAction.setEnabled(selected);
312     }//GEN-LAST:event_RBInputActionItemStateChanged
313

314     private void RBInputResourceItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_RBInputResourceItemStateChanged
315
// TODO add your handling code here:
316
boolean selected = RBInputResource.isSelected();
317         TFInputResource.setEditable(selected);
318         jButtonBrowse.setEnabled(selected);
319         CBInputAction.setEnabled(!selected);
320     }//GEN-LAST:event_RBInputResourceItemStateChanged
321

322     private void CHBUseFormBeanItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_CHBUseFormBeanItemStateChanged
323
// TODO add your handling code here:
324
boolean selected = CHBUseFormBean.isSelected();
325         CBFormName.setEnabled(selected);
326         RBInputResource.setEnabled(selected);
327         RBInputAction.setEnabled(selected);
328         if (selected) {
329             if (RBInputResource.isSelected()) {
330                 TFInputResource.setEditable(true);
331                 jButtonBrowse.setEnabled(true);
332             } else {
333                 CBInputAction.setEnabled(true);
334             }
335         } else {
336             TFInputResource.setEditable(false);
337             jButtonBrowse.setEnabled(false);
338             CBInputAction.setEnabled(false);
339         }
340         
341         RBSession.setEnabled(selected);
342         RBRequest.setEnabled(selected);
343         TFAttribute.setEditable(selected);
344         CHBValidate.setEnabled(selected);
345     }//GEN-LAST:event_CHBUseFormBeanItemStateChanged
346

347     
348     // Variables declaration - do not modify//GEN-BEGIN:variables
349
private javax.swing.JComboBox JavaDoc CBFormName;
350     private javax.swing.JComboBox JavaDoc CBInputAction;
351     private javax.swing.JCheckBox JavaDoc CHBUseFormBean;
352     private javax.swing.JCheckBox JavaDoc CHBValidate;
353     private javax.swing.JRadioButton JavaDoc RBInputAction;
354     private javax.swing.JRadioButton JavaDoc RBInputResource;
355     private javax.swing.JRadioButton JavaDoc RBRequest;
356     private javax.swing.JRadioButton JavaDoc RBSession;
357     private javax.swing.JTextField JavaDoc TFAttribute;
358     private javax.swing.JTextField JavaDoc TFInputResource;
359     private javax.swing.JTextField JavaDoc TFParameter;
360     private javax.swing.ButtonGroup JavaDoc buttonGroup1;
361     private javax.swing.ButtonGroup JavaDoc buttonGroup2;
362     private javax.swing.JButton JavaDoc jButtonBrowse;
363     private javax.swing.JLabel JavaDoc jLabelAttribute;
364     private javax.swing.JLabel JavaDoc jLabelFormName;
365     private javax.swing.JLabel JavaDoc jLabelParameter;
366     private javax.swing.JLabel JavaDoc jLabelScope;
367     private javax.swing.JPanel JavaDoc jPanel1;
368     private javax.swing.JLabel JavaDoc jParameterSpecificLabel;
369     // End of variables declaration//GEN-END:variables
370

371     boolean valid(WizardDescriptor wizardDescriptor) {
372         return true;
373     }
374     
375     void read(WizardDescriptor settings) {
376         
377         // initialize the parameter value
378
if (settings.getProperty(WizardProperties.ACTION_PARAMETER)==null) {
379             String JavaDoc actionClass = (String JavaDoc)settings.getProperty(WizardProperties.ACTION_SUPERCLASS);
380             if (ActionPanelVisual.DISPATCH_ACTION.equals(actionClass)){
381                 TFParameter.setText("method"); //NOI18N
382
jParameterSpecificLabel.setText(NbBundle.getMessage(ActionPanel1Visual.class, "LBL_Dispatch_Action"));//NOI18
383
} else if (ActionPanelVisual.MAPPING_DISPATCH_ACTION.equals(actionClass)){
384                 TFParameter.setText("customMethod"); //NOI18
385
jParameterSpecificLabel.setText(NbBundle.getMessage(ActionPanel1Visual.class, "LBL_Mapping_Dispatch_Action"));//NOI18
386
} else if (ActionPanelVisual.LOOKUP_DISPATCH_ACTION.equals(actionClass)){
387                 TFParameter.setText(""); //NOI18
388
jParameterSpecificLabel.setText(NbBundle.getMessage(ActionPanel1Visual.class, "LBL_Lookup_Dispatch_Action"));//NOI18
389
} else{
390                 TFParameter.setText(""); //NOI18
391
jParameterSpecificLabel.setText(""); //NOI18
392
}
393         }
394         configFile = (String JavaDoc)settings.getProperty(WizardProperties.ACTION_CONFIG_FILE);
395         Project proj = panel.getProject();
396         WebModule wm = WebModule.getWebModule(proj.getProjectDirectory());
397         if (wm != null && configFile != null && !"".equals(configFile.trim())){ //NOI18N
398
org.openide.filesystems.FileObject fo = wm.getDocumentBase().getFileObject(configFile);
399             if (fo!=null) {
400                 try {
401                     DataObject dObj = DataObject.find(fo);
402                     if (dObj instanceof StrutsConfigDataObject) {
403                         StrutsConfigDataObject strutsDO = (StrutsConfigDataObject)dObj;
404                         
405                         // initialize Input Actions Combo Box
406
List JavaDoc actions = StrutsConfigUtilities.getAllActionsInModule(strutsDO);
407                         String JavaDoc[] actionPaths = new String JavaDoc[actions.size()];
408                         for (int i=0;i<actionPaths.length;i++) {
409                             actionPaths[i]=((Action)actions.get(i)).getAttributeValue("path"); //NOI18N
410
if (actionPaths[i]==null) actionPaths[i]="???"; //NOI18N
411
}
412                         CBInputAction.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(actionPaths));
413                         
414                         // initialize Form Name Combo Box
415
List JavaDoc formBeans = StrutsConfigUtilities.getAllFormBeansInModule(strutsDO);
416                         String JavaDoc[] beans = new String JavaDoc[formBeans.size()];
417                         for (int i=0;i<beans.length;i++) {
418                             beans[i]=((FormBean)formBeans.get(i)).getAttributeValue("name"); //NOI18N
419
if (beans[i]==null) beans[i]="???"; //NOI18N
420
}
421                         CBFormName.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(beans));
422                         jButtonBrowse.setEnabled(true);
423                         return;
424                     }
425                 } catch (DataObjectNotFoundException ex) {}
426             }
427         } else{
428             jButtonBrowse.setEnabled(false);
429         }
430         
431         CBInputAction.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(new String JavaDoc[]{}));
432         CBFormName.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(new String JavaDoc[]{}));
433     }
434     
435     void store(WizardDescriptor settings) {
436         settings.putProperty(WizardProperties.ACTION_FORM_NAME,
437                 CHBUseFormBean.isSelected()?CBFormName.getSelectedItem():null);
438         settings.putProperty(WizardProperties.ACTION_INPUT,
439                 CHBUseFormBean.isSelected()?getInput():null);
440         settings.putProperty(WizardProperties.ACTION_SCOPE,
441                 CHBUseFormBean.isSelected()?getScope():null);
442         settings.putProperty(WizardProperties.ACTION_ATTRIBUTE,
443                 CHBUseFormBean.isSelected()?getAttribute():null);
444         settings.putProperty(WizardProperties.ACTION_VALIDATE,
445                 CHBUseFormBean.isSelected()?isValidate():null);
446         // set the parameter property only when other than default
447
String JavaDoc param = getParameter();
448         if (param!=null) {
449             String JavaDoc actionClass = (String JavaDoc)settings.getProperty(WizardProperties.ACTION_SUPERCLASS);
450             if (ActionPanelVisual.DISPATCH_ACTION.equals(actionClass) && param.equals("method")) return; //NOI18N
451
if (ActionPanelVisual.MAPPING_DISPATCH_ACTION.equals(actionClass) && param.equals("customMethod")) return; //NOI18N
452
settings.putProperty(WizardProperties.ACTION_PARAMETER, param);
453         }
454     }
455     
456     private String JavaDoc getInput() {
457         if (RBInputResource.isSelected()) {
458             String JavaDoc input=TFInputResource.getText().trim();
459             return input.length()==0?null:input;
460         } else {
461             return (String JavaDoc)CBInputAction.getSelectedItem();
462         }
463     }
464     
465     private String JavaDoc getScope() {
466         if (RBSession.isSelected()) {
467             return "session"; //NOI18N
468
} else {
469             return "request"; //NOI18N
470
}
471     }
472     
473     private Boolean JavaDoc isValidate() {
474         return Boolean.valueOf(CHBValidate.isSelected());
475     }
476     
477     private String JavaDoc getAttribute() {
478         String JavaDoc attr=TFAttribute.getText().trim();
479         return attr.length()==0?null:attr;
480     }
481     
482     private String JavaDoc getParameter() {
483         String JavaDoc param=TFParameter.getText().trim();
484         return param.length()==0?null:param;
485     }
486     
487     public HelpCtx getHelpCtx() {
488         return new HelpCtx(ActionPanel1Visual.class);
489     }
490     
491 }
492
Popular Tags