KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ExternalJNDIResourceWizard.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
42 import org.netbeans.modules.j2ee.sun.ws7.serverresources.beans.WS70ResourceUtils;
43
44 /**
45  *
46  * @author Mukesh Garg
47  */

48 public class ExternalJNDIResourceWizard extends AbstractResourceWizard{
49     
50     private static final String JavaDoc DATAFILE = "org/netbeans/modules/j2ee/sun/ws7/serverresources/wizards/ExternalJNDIWizard.xml"; //NOI18N
51
private Wizard wizardInfo;
52     private ResourceConfigHelper helper;
53     
54     private transient WizardDescriptor wizard;
55     private transient String JavaDoc[] steps;
56     
57     private static Project project;
58      
59     public static ExternalJNDIResourceWizard create(){
60         return new ExternalJNDIResourceWizard();
61     }
62     public void initialize(WizardDescriptor wizard){
63         wizardInfo = getWizardInfo(DATAFILE);
64         this.helper = new ResourceConfigHelperHolder().getExternalJndiResourceHelper();
65         
66         this.wizard = wizard;
67         wizard.putProperty("NewFileWizard_Title",
68                            NbBundle.getMessage(ExternalJNDIResourceWizard.class, "Templates/SunWS70Resources/ExternalJNDI_Resource")); //NOI18N
69
index = 0;
70                 
71         project = Templates.getProject(wizard);
72         
73         panels = createPanels();
74         // Make sure list of steps is accurate.
75
steps = createSteps();
76         
77         try{
78             FileObject pkgLocation = project.getProjectDirectory();
79             if (pkgLocation != null) {
80                 this.helper.getData().setTargetFileObject(pkgLocation);
81             }
82         }catch (Exception JavaDoc ex){
83            ex.printStackTrace();
84         }
85         
86         for (int i = 0; i < panels.length; i++) {
87             Component JavaDoc c = panels[i].getComponent();
88             if (c instanceof JComponent JavaDoc) { // assume Swing components
89
JComponent JavaDoc jc = (JComponent JavaDoc)c;
90                 // Step #.
91
jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer JavaDoc(i)); // NOI18N
92
// Step name (actually the whole list for reference).
93
jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
94
}
95         }
96     }
97     public Set JavaDoc instantiate(){
98         try{
99             WS70ResourceUtils.saveExternalJndiResourceDatatoXml(this.helper.getData());
100         }catch (Exception JavaDoc ex){
101             System.out.println("Error in instantiate of ExternalResourceWizard ");
102         }
103         return java.util.Collections.EMPTY_SET; }
104     public void uninitialize(WizardDescriptor wizard){
105         
106     }
107     private Wizard getWizardInfo(){
108         try{
109             InputStream JavaDoc in = this.getClass().getClassLoader().getResourceAsStream(DATAFILE);
110             this.wizardInfo = Wizard.createGraph(in);
111         }catch(Exception JavaDoc ex){
112             ex.printStackTrace();
113         }
114         return this.wizardInfo;
115     }
116         
117  
118     public String JavaDoc name(){
119         return NbBundle.getMessage(ExternalJNDIResourceWizard.class, "Templates/SunWS70Resources/ExternalJNDI_Resource"); //NOI18N
120
}
121    private WizardDescriptor.Panel[] createPanels() {
122         return new WizardDescriptor.Panel[] {
123             new CommonGeneralFinishPanel(helper, wizardInfo, new String JavaDoc[] {"general"}), //NOI18N
124
new CommonPropertyPanel(helper, wizardInfo)
125         };
126     }
127     
128     private String JavaDoc[] createSteps() {
129         return new String JavaDoc[] {
130             WS70WizardConstants.__FirstStepChoose,
131             NbBundle.getMessage(CustomResourceWizard.class, "TITLE_GeneralAttributes_EXTERNAL"), //NOI18N
132
NbBundle.getMessage(CustomResourceWizard.class, "TITLE_UserProps_EXTERNAL") //NOI18N
133
};
134     }
135 }
136
Popular Tags