KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > blueprints > ui > projects > J2eeSampleProjectIterator


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.j2ee.blueprints.ui.projects;
21
22 import java.io.File JavaDoc;
23 import java.util.HashSet JavaDoc;
24 import java.util.NoSuchElementException JavaDoc;
25 import java.util.Set JavaDoc;
26 import java.util.Collections JavaDoc;
27 import java.util.NoSuchElementException JavaDoc;
28 import javax.swing.JComponent JavaDoc;
29 import org.openide.WizardDescriptor;
30 import org.openide.filesystems.FileObject;
31 import org.openide.loaders.DataObject;
32 import org.openide.loaders.TemplateWizard;
33 import org.openide.util.NbBundle;
34
35 /**
36  *
37  * @author Martin Grebac
38  */

39 public class J2eeSampleProjectIterator implements TemplateWizard.Iterator {
40     
41     private static final long serialVersionUID = 4L;
42     
43     int currentIndex;
44     PanelConfigureProject basicPanel;
45     private transient WizardDescriptor wiz;
46
47     static Object JavaDoc create() {
48         return new J2eeSampleProjectIterator();
49     }
50     
51     public J2eeSampleProjectIterator () {
52     }
53     
54     public void addChangeListener (javax.swing.event.ChangeListener JavaDoc changeListener) {
55     }
56     
57     public void removeChangeListener (javax.swing.event.ChangeListener JavaDoc changeListener) {
58     }
59     
60     public org.openide.WizardDescriptor.Panel current () {
61         return basicPanel;
62     }
63     
64     public boolean hasNext () {
65         return false;
66     }
67     
68     public boolean hasPrevious () {
69         return false;
70     }
71     
72     public void initialize (org.openide.loaders.TemplateWizard templateWizard) {
73         this.wiz = templateWizard;
74         String JavaDoc name = templateWizard.getTemplate().getNodeDelegate().getName();
75         if (name != null) {
76             name = name.replaceAll(" ", ""); //NOI18N
77
}
78         templateWizard.putProperty (WizardProperties.NAME, name);
79         basicPanel = new PanelConfigureProject();
80         currentIndex = 0;
81         updateStepsList ();
82     }
83     
84     public void uninitialize (org.openide.loaders.TemplateWizard templateWizard) {
85         basicPanel = null;
86         currentIndex = -1;
87         this.wiz.putProperty(WizardProperties.PROJECT_DIR,null);
88         this.wiz.putProperty(WizardProperties.NAME,null);
89     }
90     
91     public java.util.Set JavaDoc instantiate (org.openide.loaders.TemplateWizard templateWizard) throws java.io.IOException JavaDoc {
92         File JavaDoc projectLocation = (File JavaDoc) wiz.getProperty(WizardProperties.PROJECT_DIR);
93         String JavaDoc name = (String JavaDoc) wiz.getProperty(WizardProperties.NAME);
94                         
95         FileObject prjLoc = null;
96
97         prjLoc = J2eeSampleProjectGenerator.createProjectFromTemplate(templateWizard.getTemplate().getPrimaryFile(), projectLocation, name);
98         
99         //Get the overview page for current project
100
J2eeSampleProjectGenerator.getOverviewPage(templateWizard);
101         
102         //return Collections.singleton(DataObject.find(prjLoc));
103

104         Set JavaDoc hset = new HashSet JavaDoc();
105         hset.add(DataObject.find(prjLoc));
106         return hset;
107     }
108     
109     public String JavaDoc name() {
110         return current().getComponent().getName();
111     }
112     
113     public void nextPanel() {
114         throw new NoSuchElementException JavaDoc ();
115     }
116     
117     public void previousPanel() {
118         throw new NoSuchElementException JavaDoc ();
119     }
120     
121     void updateStepsList() {
122         JComponent JavaDoc component = (JComponent JavaDoc) current ().getComponent ();
123         if (component == null) {
124             return;
125         }
126         String JavaDoc[] list;
127         list = new String JavaDoc[] {
128             NbBundle.getMessage(PanelConfigureProject.class, "LBL_NWP1_ProjectTitleName"), // NOI18N
129
};
130         component.putClientProperty ("WizardPanel_contentData", list); // NOI18N
131
component.putClientProperty ("WizardPanel_contentSelectedIndex", new Integer JavaDoc (currentIndex)); // NOI18N
132
}
133     
134 }
135
Popular Tags