KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > j2seproject > ui > wizards > PanelConfigureProjectVisual


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.java.j2seproject.ui.wizards;
21
22 import javax.swing.JPanel JavaDoc;
23 import org.openide.WizardDescriptor;
24 import org.openide.WizardValidationException;
25 import org.openide.util.NbBundle;
26
27 /** First panel in the NewProject wizard. Used for filling in
28  * name, and directory of the project.
29  *
30  * @author Petr Hrebejk
31  */

32 public class PanelConfigureProjectVisual extends JPanel JavaDoc {
33
34     private PanelConfigureProject panel;
35         
36     private boolean ignoreProjectDirChanges;
37     
38     private boolean ignoreAntProjectNameChanges;
39     
40     private boolean noDir = true;
41     
42     private SettingsPanel projectLocationPanel;
43     
44     private PanelOptionsVisual optionsPanel;
45     
46     private NewJ2SEProjectWizardIterator.WizardType type;
47     
48     public PanelConfigureProjectVisual(PanelConfigureProject panel, NewJ2SEProjectWizardIterator.WizardType type) {
49         this.panel = panel;
50         initComponents();
51         this.type = type;
52         setName(NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NameAndLoc")); // NOI18N
53
switch (type) {
54         case APP:
55             projectLocationPanel = new PanelProjectLocationVisual( panel, type );
56             putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaApp")); // NOI18N
57
jSeparator1.setVisible(true);
58             getAccessibleContext ().setAccessibleName (NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaApp")); // NOI18N
59
getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(PanelConfigureProjectVisual.class,"ACSD_NewJavaApp")); // NOI18N
60
break;
61         case LIB:
62             projectLocationPanel = new PanelProjectLocationVisual( panel, type );
63             jSeparator1.setVisible (false);
64             putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaLib")); // NOI18N
65
getAccessibleContext ().setAccessibleName (NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaLib")); // NOI18N
66
getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(PanelConfigureProjectVisual.class,"ACSD_NewJavaLib")); // NOI18N
67
break;
68         case EXT:
69             projectLocationPanel = new PanelProjectLocationExtSrc ( panel );
70             jSeparator1.setVisible(true);
71             putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_JavaExtSourcesProjectLocation")); // NOI18N
72
getAccessibleContext ().setAccessibleName (NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_JavaExtSourcesProjectLocation")); // NOI18N
73
getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(PanelConfigureProjectVisual.class,"ACSD_JavaExtSourcesProjectLocation")); // NOI18N
74
}
75         locationContainer.add( projectLocationPanel, java.awt.BorderLayout.CENTER );
76         optionsPanel = new PanelOptionsVisual( panel, type );
77         projectLocationPanel.addPropertyChangeListener(optionsPanel);
78         optionsContainer.add( optionsPanel, java.awt.BorderLayout.CENTER );
79     }
80     
81     boolean valid( WizardDescriptor wizardDescriptor ) {
82         wizardDescriptor.putProperty( "WizardPanel_errorMessage", "" ); //NOI18N
83
return projectLocationPanel.valid( wizardDescriptor ) && optionsPanel.valid(wizardDescriptor);
84     }
85     
86     void read (WizardDescriptor d) {
87         NewJ2SEProjectWizardIterator.WizardType lastType = (NewJ2SEProjectWizardIterator.WizardType) d.getProperty("wizard-type"); //NOI18N
88
if (lastType == null || lastType != type) {
89             //bugfix #46387 The type of project changed, reset values to defaults
90
d.putProperty ("name", null);
91             d.putProperty ("projdir",null);
92         }
93         projectLocationPanel.read (d);
94         optionsPanel.read (d);
95     }
96     
97     void store( WizardDescriptor d ) {
98         d.putProperty("wizard-type", type); //NOI18N
99
projectLocationPanel.store( d );
100         optionsPanel.store( d );
101     }
102     
103     void validate (WizardDescriptor d) throws WizardValidationException {
104         projectLocationPanel.validate (d);
105     }
106     
107     
108     /** This method is called from within the constructor to
109      * initialize the form.
110      * WARNING: Do NOT modify this code. The content of this method is
111      * always regenerated by the Form Editor.
112      */

113     private void initComponents() {//GEN-BEGIN:initComponents
114
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
115
116         locationContainer = new javax.swing.JPanel JavaDoc();
117         jSeparator1 = new javax.swing.JSeparator JavaDoc();
118         optionsContainer = new javax.swing.JPanel JavaDoc();
119
120         setLayout(new java.awt.GridBagLayout JavaDoc());
121
122         locationContainer.setLayout(new java.awt.BorderLayout JavaDoc());
123
124         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
125         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
126         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
127         gridBagConstraints.weightx = 1.0;
128         add(locationContainer, gridBagConstraints);
129         locationContainer.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSN_locationContainer"));
130         locationContainer.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSD_locationContainer"));
131
132         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
133         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
134         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
135         gridBagConstraints.weightx = 1.0;
136         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 12, 0);
137         add(jSeparator1, gridBagConstraints);
138
139         optionsContainer.setLayout(new java.awt.BorderLayout JavaDoc());
140
141         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
142         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
143         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
144         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
145         gridBagConstraints.weightx = 1.0;
146         gridBagConstraints.weighty = 1.0;
147         add(optionsContainer, gridBagConstraints);
148         optionsContainer.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSN_optionsContainer"));
149         optionsContainer.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSD_optionsContainer"));
150
151     }//GEN-END:initComponents
152

153     /** Currently only handles the "Browse..." button
154      */

155            
156     // Variables declaration - do not modify//GEN-BEGIN:variables
157
private javax.swing.JSeparator JavaDoc jSeparator1;
158     private javax.swing.JPanel JavaDoc locationContainer;
159     private javax.swing.JPanel JavaDoc optionsContainer;
160     // End of variables declaration//GEN-END:variables
161

162     
163 }
164
Popular Tags