KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > project > 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.web.project.ui.wizards;
21
22 import java.awt.Dimension JavaDoc;
23 import javax.swing.JPanel JavaDoc;
24 import javax.swing.event.DocumentEvent JavaDoc;
25 import javax.swing.event.DocumentListener JavaDoc;
26 import org.netbeans.modules.web.project.Utils;
27
28 import org.openide.WizardDescriptor;
29 import org.openide.WizardValidationException;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.NbBundle;
32
33 public class PanelConfigureProjectVisual extends JPanel JavaDoc implements HelpCtx.Provider {
34
35     private PanelConfigureProject panel;
36
37     private PanelProjectLocationVisual projectLocationPanel;
38     private PanelOptionsVisual optionsPanel;
39
40     /** Creates new form PanelInitProject */
41     public PanelConfigureProjectVisual(PanelConfigureProject panel) {
42         this.panel = panel;
43         initComponents();
44         this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PanelConfigureProjectVisual.class, "ACS_NWP1_NamePanel_A11YDesc")); // NOI18N
45

46         projectLocationPanel = new PanelProjectLocationVisual(panel);
47         locationContainer.add(projectLocationPanel, java.awt.BorderLayout.NORTH);
48
49         optionsPanel = new PanelOptionsVisual(panel);
50         java.awt.GridBagConstraints JavaDoc gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
51         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
52         gridBagConstraints.weightx = 1.0;
53         gridBagConstraints.weighty = 1.0;
54         optionsContainer.add(optionsPanel, gridBagConstraints);
55         
56         DocumentListener JavaDoc dl = new DocumentListener JavaDoc() {
57             public void changedUpdate(DocumentEvent JavaDoc e) {
58                 setContextPath(e);
59             }
60
61             public void insertUpdate(DocumentEvent JavaDoc e) {
62                 setContextPath(e);
63             }
64
65             public void removeUpdate(DocumentEvent JavaDoc e) {
66                 setContextPath(e);
67             }
68
69             private void setContextPath(DocumentEvent JavaDoc e) {
70                 if (!optionsPanel.isContextModified())
71                     optionsPanel.jTextFieldContextPath.setText(Utils.createDefaultContext(projectLocationPanel.projectNameTextField.getText()));
72             }
73         };
74         projectLocationPanel.projectNameTextField.getDocument().addDocumentListener(dl);
75
76
77         // Provide a name in the title bar.
78
setName(NbBundle.getMessage(PanelConfigureProjectVisual.class, "LBL_NWP1_ProjectTitleName")); //NOI18N
79
putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class, "TXT_NewWebApp")); //NOI18N
80

81         //resize panel to show all components
82
int height = projectLocationPanel.computeHeight() + optionsPanel.computeHeight() + 30;
83         if (height > 340) {
84             Dimension JavaDoc dim = new Dimension JavaDoc(getWidth(), height);
85             setMinimumSize(dim);
86             setPreferredSize(dim);
87         }
88     }
89
90     boolean valid(WizardDescriptor wizardDescriptor) {
91         return projectLocationPanel.valid(wizardDescriptor) && optionsPanel.valid(wizardDescriptor);
92     }
93
94     void validate (WizardDescriptor d) throws WizardValidationException {
95         projectLocationPanel.validate (d);
96     }
97     
98     void read (WizardDescriptor d) {
99         projectLocationPanel.read(d);
100         optionsPanel.read(d);
101     }
102
103     void store(WizardDescriptor d) {
104         projectLocationPanel.store(d);
105         optionsPanel.store(d);
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     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
114
private void initComponents() {
115         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
116
117         locationContainer = new javax.swing.JPanel JavaDoc();
118         jSeparator1 = new javax.swing.JSeparator JavaDoc();
119         optionsContainer = new javax.swing.JPanel JavaDoc();
120
121         setLayout(new java.awt.GridBagLayout JavaDoc());
122
123         setRequestFocusEnabled(false);
124         locationContainer.setLayout(new java.awt.BorderLayout JavaDoc());
125
126         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
127         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
128         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
129         gridBagConstraints.weightx = 1.0;
130         add(locationContainer, gridBagConstraints);
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.GridBagLayout 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
149     }// </editor-fold>//GEN-END:initComponents
150

151     // Variables declaration - do not modify//GEN-BEGIN:variables
152
private javax.swing.JSeparator JavaDoc jSeparator1;
153     private javax.swing.JPanel JavaDoc locationContainer;
154     private javax.swing.JPanel JavaDoc optionsContainer;
155     // End of variables declaration//GEN-END:variables
156

157     /** Help context where to find more about the paste type action.
158      * @return the help context for this action
159      */

160     public HelpCtx getHelpCtx() {
161         return new HelpCtx(PanelConfigureProjectVisual.class);
162     }
163 }
164
Popular Tags