KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > serverresources > wizards > MailResourceWizard


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 /*
21  * MailResourceWizard.java
22  */

23
24 package org.netbeans.modules.j2ee.sun.ws7.serverresources.wizards;
25
26 import java.awt.Component JavaDoc;
27 import java.util.Set JavaDoc;
28 import javax.swing.JComponent JavaDoc;
29 import java.io.InputStream JavaDoc;
30 import javax.swing.event.ChangeEvent JavaDoc;
31 import javax.swing.event.ChangeListener JavaDoc;
32
33 import org.openide.util.NbBundle;
34 import org.openide.WizardDescriptor;
35 import org.netbeans.api.project.Project;
36 import org.openide.filesystems.FileObject;
37 import org.netbeans.spi.project.ui.templates.support.Templates;
38 import org.openide.WizardDescriptor;
39
40 import org.netbeans.modules.j2ee.sun.sunresources.beans.Wizard;
41 import org.netbeans.modules.j2ee.sun.ws7.serverresources.beans.WS70ResourceUtils;
42
43 /**
44  *
45  * @author Mukesh Garg
46  */

47 public class MailResourceWizard extends AbstractResourceWizard{
48     private static final String JavaDoc DATAFILE = "org/netbeans/modules/j2ee/sun/ws7/serverresources/wizards/MailWizard.xml"; //NOI18N
49

50     private Wizard wizardInfo;
51     private ResourceConfigHelper helper;
52     private transient WizardDescriptor wizard;
53     private transient String JavaDoc[] steps;
54     private static Project project;
55     
56     public static MailResourceWizard create(){
57         return new MailResourceWizard();
58     }
59     
60     public void initialize(WizardDescriptor wizard){
61         wizardInfo = getWizardInfo(DATAFILE);
62         this.helper = new ResourceConfigHelperHolder().getMailHelper();
63         
64         this.wizard = wizard;
65         wizard.putProperty("NewFileWizard_Title",
66                            NbBundle.getMessage(MailResourceWizard.class, "Templates/SunWS70Resources/JavaMail_Resource")); //NOI18N
67
index = 0;
68                 
69         project = Templates.getProject(wizard);
70         
71         panels = createPanels();
72         // Make sure list of steps is accurate.
73
steps = createSteps();
74         
75         try{
76             FileObject pkgLocation = project.getProjectDirectory();
77             if (pkgLocation != null) {
78                 this.helper.getData().setTargetFileObject(pkgLocation);
79             }
80         }catch (Exception JavaDoc ex){
81            //Unable to get project location
82
}
83         
84         for (int i = 0; i < panels.length; i++) {
85             Component JavaDoc c = panels[i].getComponent();
86             if (c instanceof JComponent JavaDoc) { // assume Swing components
87
JComponent JavaDoc jc = (JComponent JavaDoc)c;
88                 // Step #.
89
jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer JavaDoc(i)); // NOI18N
90
// Step name (actually the whole list for reference).
91
jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
92
}
93         }
94     }
95     public Set JavaDoc instantiate(){
96         try{
97             WS70ResourceUtils.saveMailResourceDatatoXml(this.helper.getData());
98         }catch (Exception JavaDoc ex){
99             //System.out.println("Error in instantiate ");
100
}
101         return java.util.Collections.EMPTY_SET;
102         
103     }
104     public void uninitialize(WizardDescriptor wizard){
105         
106     }
107
108         
109  
110     public String JavaDoc name(){
111         return NbBundle.getMessage(MailResourceWizard.class, "Templates/SunWS70Resources/JavaMail_Resource"); //NOI18N
112
}
113     
114     private WizardDescriptor.Panel[] createPanels() {
115         return new WizardDescriptor.Panel[] {
116             new CommonGeneralFinishPanel(helper, wizardInfo, new String JavaDoc[] {"general", "advanced"}) //NOI18N
117

118         };
119     }
120     
121     private String JavaDoc[] createSteps() {
122         return new String JavaDoc[] {
123             WS70WizardConstants.__FirstStepChoose,
124             NbBundle.getMessage(MailResourceWizard.class, "TITLE_GeneralAttributes_MAIL"), //NOI18N
125
};
126     }
127     
128 }
129
Popular Tags