KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > railsprojects > 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.ruby.railsprojects.ui.wizards;
21
22 import java.io.File JavaDoc;
23 import javax.swing.JPanel JavaDoc;
24 import javax.swing.event.DocumentEvent JavaDoc;
25 import javax.swing.event.DocumentListener JavaDoc;
26 import javax.swing.text.Document JavaDoc;
27 import org.netbeans.modules.ruby.rubyproject.api.RubyInstallation;
28 import org.openide.WizardDescriptor;
29 import org.openide.WizardValidationException;
30 import org.openide.util.NbBundle;
31 import org.openide.util.Utilities;
32
33 /** First panel in the NewProject wizard. Used for filling in
34  * name, and directory of the project.
35  *
36  * @author Petr Hrebejk
37  */

38 public class PanelConfigureProjectVisual extends JPanel JavaDoc {
39
40     private PanelConfigureProject panel;
41         
42     private boolean ignoreProjectDirChanges;
43     
44     private boolean ignoreRakeProjectNameChanges;
45     
46     private boolean noDir = true;
47     
48     private SettingsPanel projectLocationPanel;
49     
50     private PanelOptionsVisual optionsPanel;
51     
52     private int type;
53     
54     /** Creates new form PanelInitProject */
55     public PanelConfigureProjectVisual( PanelConfigureProject panel, int type ) {
56         this.panel = panel;
57         initComponents();
58         this.type = type;
59         setName(NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NameAndLoc")); // NOI18N
60
if (type == NewRailsProjectWizardIterator.TYPE_APP) {
61             projectLocationPanel = new PanelProjectLocationVisual( panel, type );
62             putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaApp")); // NOI18N
63
jSeparator1.setVisible(true);
64             getAccessibleContext ().setAccessibleName (NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaApp")); // NOI18N
65
getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(PanelConfigureProjectVisual.class,"ACSD_NewJavaApp")); // NOI18N
66
}
67 // else if (type == NewRailsProjectWizardIterator.TYPE_LIB) {
68
// projectLocationPanel = new PanelProjectLocationVisual( panel, type );
69
// jSeparator1.setVisible (false);
70
// putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaLib")); // NOI18N
71
// getAccessibleContext ().setAccessibleName (NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaLib")); // NOI18N
72
// getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(PanelConfigureProjectVisual.class,"ACSD_NewJavaLib")); // NOI18N
73
// }
74
else {
75             projectLocationPanel = new PanelProjectLocationExtSrc ( panel );
76             jSeparator1.setVisible(true);
77             putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_JavaExtSourcesProjectLocation")); // NOI18N
78
getAccessibleContext ().setAccessibleName (NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_JavaExtSourcesProjectLocation")); // NOI18N
79
getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(PanelConfigureProjectVisual.class,"ACSD_JavaExtSourcesProjectLocation")); // NOI18N
80
}
81         locationContainer.add( projectLocationPanel, java.awt.BorderLayout.CENTER );
82         optionsPanel = new PanelOptionsVisual( panel, type );
83         projectLocationPanel.addPropertyChangeListener(optionsPanel);
84         optionsContainer.add( optionsPanel, java.awt.BorderLayout.CENTER );
85     }
86     
87     boolean valid( WizardDescriptor wizardDescriptor ) {
88         // Temporary workaround
89
// Spaces in paths won't work for now with Rails
90
if (Utilities.isWindows()) {
91             String JavaDoc rails = RubyInstallation.getInstance().getRails();
92             if (rails.indexOf(' ') != -1) {
93                  wizardDescriptor.putProperty("WizardPanel_errorMessage", "Rails path contains spaces; fails on Windows.\n " + rails);
94                  //return false;
95
}
96         }
97         
98         
99         wizardDescriptor.putProperty( "WizardPanel_errorMessage", "" ); //NOI18N
100
return projectLocationPanel.valid( wizardDescriptor ) && optionsPanel.valid(wizardDescriptor);
101     }
102     
103     void read (WizardDescriptor d) {
104         Integer JavaDoc lastType = (Integer JavaDoc) d.getProperty("rails-wizard-type"); //NOI18N
105
if (lastType == null || lastType.intValue() != this.type) {
106             //bugfix #46387 The type of project changed, reset values to defaults
107
d.putProperty ("name", null);
108             d.putProperty ("projdir",null);
109         }
110         projectLocationPanel.read (d);
111         optionsPanel.read (d);
112     }
113     
114     void store( WizardDescriptor d ) {
115         d.putProperty("rails-wizard-type", new Integer JavaDoc(this.type)); //NOI18N
116
projectLocationPanel.store( d );
117         optionsPanel.store( d );
118     }
119     
120     void validate (WizardDescriptor d) throws WizardValidationException {
121         projectLocationPanel.validate (d);
122     }
123     
124     
125     /** This method is called from within the constructor to
126      * initialize the form.
127      * WARNING: Do NOT modify this code. The content of this method is
128      * always regenerated by the Form Editor.
129      */

130     private void initComponents() {//GEN-BEGIN:initComponents
131
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
132
133         locationContainer = new javax.swing.JPanel JavaDoc();
134         jSeparator1 = new javax.swing.JSeparator JavaDoc();
135         optionsContainer = new javax.swing.JPanel JavaDoc();
136
137         setLayout(new java.awt.GridBagLayout JavaDoc());
138
139         locationContainer.setLayout(new java.awt.BorderLayout JavaDoc());
140
141         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
142         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
143         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
144         gridBagConstraints.weightx = 1.0;
145         add(locationContainer, gridBagConstraints);
146         locationContainer.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSN_locationContainer"));
147         locationContainer.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSD_locationContainer"));
148
149         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
150         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
151         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
152         gridBagConstraints.weightx = 1.0;
153         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 12, 0);
154         add(jSeparator1, gridBagConstraints);
155
156         optionsContainer.setLayout(new java.awt.BorderLayout JavaDoc());
157
158         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
159         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
160         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
161         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
162         gridBagConstraints.weightx = 1.0;
163         gridBagConstraints.weighty = 1.0;
164         add(optionsContainer, gridBagConstraints);
165         optionsContainer.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSN_optionsContainer"));
166         optionsContainer.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSD_optionsContainer"));
167
168     }//GEN-END:initComponents
169

170     /** Currently only handles the "Browse..." button
171      */

172            
173     // Variables declaration - do not modify//GEN-BEGIN:variables
174
private javax.swing.JSeparator JavaDoc jSeparator1;
175     private javax.swing.JPanel JavaDoc locationContainer;
176     private javax.swing.JPanel JavaDoc optionsContainer;
177     // End of variables declaration//GEN-END:variables
178

179     
180 }
181
Popular Tags