KickJava   Java API By Example, From Geeks To Geeks.

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


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 import javax.swing.event.ListDataEvent JavaDoc;
22 import javax.swing.event.ListDataListener JavaDoc;
23 import org.netbeans.api.project.Project;
24 import org.netbeans.modules.web.api.webmodule.WebModule;
25 import org.netbeans.modules.web.struts.StrutsConfigUtilities;
26 import org.openide.WizardDescriptor;
27 import org.openide.util.HelpCtx;
28 import org.openide.util.NbBundle;
29
30
31 public class FormBeanNewPanelVisual extends javax.swing.JPanel JavaDoc implements HelpCtx.Provider, ListDataListener JavaDoc {
32
33     /**
34      * Creates new form PropertiesPanelVisual
35      */

36     public FormBeanNewPanelVisual(Project proj) {
37         initComponents();
38         
39         jComboBoxSuperclass.getModel().addListDataListener(this);
40         WebModule wm = WebModule.getWebModule(proj.getProjectDirectory());
41         if (wm!=null){
42             String JavaDoc[] configFiles = StrutsConfigUtilities.getConfigFiles(wm.getDeploymentDescriptor());
43             jComboBoxConfigFile.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(configFiles));
44         }
45         
46         
47 // this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FormBeanNewPanelVisual.class, "ACS_BeanFormProperties")); // NOI18N
48
}
49     
50     /** This method is called from within the constructor to
51      * initialize the form.
52      * WARNING: Do NOT modify this code. The content of this method is
53      * always regenerated by the Form Editor.
54      */

55     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
56
private void initComponents() {
57         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
58
59         jLabelSuperclass = new javax.swing.JLabel JavaDoc();
60         jComboBoxSuperclass = new javax.swing.JComboBox JavaDoc();
61         jLabelConfigFile = new javax.swing.JLabel JavaDoc();
62         jComboBoxConfigFile = new javax.swing.JComboBox JavaDoc();
63
64         setLayout(new java.awt.GridBagLayout JavaDoc());
65
66         jLabelSuperclass.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(FormBeanNewPanelVisual.class, "LBL_Superlass_mnem").charAt(0));
67         jLabelSuperclass.setLabelFor(jComboBoxSuperclass);
68         jLabelSuperclass.setText(org.openide.util.NbBundle.getMessage(FormBeanNewPanelVisual.class, "LBL_Superclass"));
69         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
70         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
71         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 5, 12);
72         add(jLabelSuperclass, gridBagConstraints);
73
74         jComboBoxSuperclass.setEditable(true);
75         jComboBoxSuperclass.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(new String JavaDoc[] { "org.apache.struts.action.ActionForm", "org.apache.struts.validator.ValidatorForm", "org.apache.struts.validator.ValidatorActionForm" }));
76         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
77         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
78         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
79         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 5, 0);
80         add(jComboBoxSuperclass, gridBagConstraints);
81
82         jLabelConfigFile.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(FormBeanNewPanelVisual.class, "LBL_ConfigFile_mnem").charAt(0));
83         jLabelConfigFile.setLabelFor(jComboBoxConfigFile);
84         jLabelConfigFile.setText(org.openide.util.NbBundle.getMessage(FormBeanNewPanelVisual.class, "LBL_ConfigFile"));
85         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
86         gridBagConstraints.gridx = 0;
87         gridBagConstraints.gridy = 1;
88         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
89         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
90         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 12);
91         add(jLabelConfigFile, gridBagConstraints);
92
93         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
94         gridBagConstraints.gridx = 1;
95         gridBagConstraints.gridy = 1;
96         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
97         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
98         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
99         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
100         gridBagConstraints.weightx = 1.0;
101         gridBagConstraints.weighty = 1.0;
102         add(jComboBoxConfigFile, gridBagConstraints);
103         jComboBoxConfigFile.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_ConfiguratioFile"));
104
105     }
106     // </editor-fold>//GEN-END:initComponents
107

108     // Variables declaration - do not modify//GEN-BEGIN:variables
109
private javax.swing.JComboBox JavaDoc jComboBoxConfigFile;
110     private javax.swing.JComboBox JavaDoc jComboBoxSuperclass;
111     private javax.swing.JLabel JavaDoc jLabelConfigFile;
112     private javax.swing.JLabel JavaDoc jLabelSuperclass;
113     // End of variables declaration//GEN-END:variables
114

115     boolean valid(WizardDescriptor wizardDescriptor) {
116         String JavaDoc superclass = (String JavaDoc) jComboBoxSuperclass.getEditor().getItem();
117         String JavaDoc configFile = (String JavaDoc) jComboBoxConfigFile.getSelectedItem();
118         
119         if (superclass == null || superclass.trim().equals("")){
120             wizardDescriptor.putProperty("WizardPanel_errorMessage",
121                     NbBundle.getMessage(FormBeanNewPanelVisual.class, "MSG_NoSuperClassSelected"));
122         }
123         if (configFile == null || configFile.trim().equals("")){
124             // Should dislpay only warning. We should allow to create bean outside module. #68034
125
wizardDescriptor.putProperty("WizardPanel_errorMessage",
126                     NbBundle.getMessage(FormBeanNewPanelVisual.class, "MSG_NoConfFileSelectedForBean"));
127         }
128         return true;
129     }
130     
131     void read(WizardDescriptor settings) {
132     }
133     
134     void store(WizardDescriptor settings) {
135         settings.putProperty(WizardProperties.FORMBEAN_SUPERCLASS, jComboBoxSuperclass.getSelectedItem());
136         settings.putProperty(WizardProperties.FORMBEAN_CONFIG_FILE, jComboBoxConfigFile.getSelectedItem());
137     }
138     
139     /** Help context where to find more about the paste type action.
140      * @return the help context for this action
141      */

142     public HelpCtx getHelpCtx() {
143         return new HelpCtx(FormBeanNewPanelVisual.class);
144     }
145     
146     public void intervalRemoved(ListDataEvent JavaDoc e) {
147     }
148     
149     public void intervalAdded(ListDataEvent JavaDoc e) {
150     }
151     
152     public void contentsChanged(ListDataEvent JavaDoc e) {
153         //System.out.println("xxx");
154
}
155     
156 }
157
Popular Tags