KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > ui > wizard > BasicInfoWizardPanel


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.apisupport.project.ui.wizard;
21
22 import java.awt.Component JavaDoc;
23 import java.io.File JavaDoc;
24 import org.openide.WizardDescriptor;
25 import org.openide.WizardValidationException;
26 import org.openide.util.HelpCtx;
27
28 /**
29  * First panel of <code>NewNbModuleWizardIterator</code>. Allows user to enter
30  * basic module information:
31  *
32  * <ul>
33  * <li>Project name</li>
34  * <li>Project Location</li>
35  * <li>Project Folder</li>
36  * <li>If should be set as a Main Project</li>
37  * <li>NetBeans Platform (for standalone modules)</li>
38  * <li>Module Suite (for suite modules)</li>
39  * </ul>
40  *
41  * @author Martin Krauskopf
42  */

43 final class BasicInfoWizardPanel extends BasicWizardPanel.NewTemplatePanel implements WizardDescriptor.ValidatingPanel {
44     
45     /** Representing visual component for this step. */
46     private BasicInfoVisualPanel visualPanel;
47     
48     /** Creates a new instance of BasicInfoWizardPanel */
49     public BasicInfoWizardPanel(final NewModuleProjectData data) {
50         super(data);
51     }
52     
53     public void reloadData() {
54         getVisualPanel().refreshData();
55     }
56     
57     public void storeData() {
58         getVisualPanel().storeData();
59     }
60     
61     private BasicInfoVisualPanel getVisualPanel() {
62         return (BasicInfoVisualPanel) getComponent();
63     }
64     
65     public Component JavaDoc getComponent() {
66         if (visualPanel == null) {
67             visualPanel = new BasicInfoVisualPanel(getData());
68             visualPanel.addPropertyChangeListener(this);
69             visualPanel.setName(getMessage("LBL_BasicInfoPanel_Title"));
70             visualPanel.updateAndCheck();
71         }
72         return visualPanel;
73     }
74     
75     public HelpCtx getHelp() {
76         return new HelpCtx(BasicInfoWizardPanel.class.getName() + "_" + getWizardTypeString());
77     }
78     
79     public void validate() throws WizardValidationException {
80         // XXX this is little strange. Since this method is called first time the panel appears.
81
// So we have to do this null check (data are uninitialized)
82
String JavaDoc prjFolder = getData().getProjectFolder();
83         if (prjFolder != null) {
84             File JavaDoc prjFolderF = new File JavaDoc(prjFolder);
85             if (prjFolderF.mkdir()) {
86                 prjFolderF.delete();
87             } else {
88                 String JavaDoc message = getMessage("MSG_UnableToCreateProjectFolder");
89                 throw new WizardValidationException(getVisualPanel().nameValue, message, message);
90             }
91         }
92     }
93     
94 }
95
Popular Tags