KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > core > client > wizard > WebServiceClientWizardIterator


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.websvc.core.client.wizard;
21
22 import java.io.*;
23 import java.util.*;
24 import java.awt.Component JavaDoc;
25 import javax.swing.JComponent JavaDoc;
26 import javax.swing.event.ChangeListener JavaDoc;
27 import org.netbeans.modules.websvc.core.ClientCreator;
28 import org.netbeans.modules.websvc.core.CreatorProvider;
29 import org.netbeans.modules.websvc.core.JaxWsUtils;
30 import org.openide.WizardDescriptor;
31 import org.openide.util.NbBundle;
32
33 import org.netbeans.api.project.Project;
34 import org.netbeans.spi.project.ui.templates.support.Templates;
35 import org.openide.filesystems.FileObject;
36 import org.openide.loaders.DataObject;
37 import org.openide.loaders.TemplateWizard;
38
39 /** Wizard for adding web service clients to an application
40  */

41 public class WebServiceClientWizardIterator implements TemplateWizard.Iterator {
42
43     private int index = 0;
44     private WizardDescriptor.Panel [] panels;
45
46     private TemplateWizard wiz;
47     // !PW FIXME How to handle freeform???
48
private Project project;
49
50     /** Entry point specified in layer
51      */

52     public static WebServiceClientWizardIterator create() {
53         return new WebServiceClientWizardIterator();
54     }
55
56     private WizardDescriptor.Panel[] createPanels() {
57         return new WizardDescriptor.Panel[] {
58             new WebServiceClientWizardDescriptor()
59         };
60     }
61
62     public void initialize(TemplateWizard wizard) {
63         wiz = wizard;
64         project = Templates.getProject(wiz);
65
66         index = 0;
67         panels = createPanels();
68
69         Object JavaDoc prop = wiz.getProperty("WizardPanel_contentData"); // NOI18N
70
String JavaDoc[] beforeSteps = null;
71         if (prop != null && prop instanceof String JavaDoc[]) {
72             beforeSteps = (String JavaDoc[])prop;
73         }
74         String JavaDoc[] steps = JaxWsUtils.createSteps (beforeSteps, panels);
75
76         for (int i = 0; i < panels.length; i++) {
77             Component JavaDoc c = panels[i].getComponent();
78             if (steps[i] == null) {
79                 // Default step name to component name of panel.
80
// Mainly useful for getting the name of the target
81
// chooser to appear in the list of steps.
82
steps[i] = c.getName();
83             }
84
85             assert c instanceof JComponent JavaDoc;
86             JComponent JavaDoc jc = (JComponent JavaDoc)c;
87             // Step #.
88
jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer JavaDoc(i)); // NOI18N
89
// Step name (actually the whole list for reference).
90
jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
91
}
92     }
93
94     public void uninitialize(TemplateWizard wizard) {
95         wiz = null;
96         panels = null;
97     }
98     
99     public Set/*FileObject*/ instantiate(TemplateWizard wiz) throws IOException {
100         FileObject template = Templates.getTemplate( wiz );
101         DataObject dTemplate = DataObject.find( template );
102         // jax-rpc split
103
//new WebServiceClientCreator(project,wiz).create();
104
ClientCreator creator = CreatorProvider.getClientCreator(project, wiz);
105         if (creator!=null) creator.createClient();
106                 
107         return Collections.singleton(dTemplate);
108     }
109
110     public String JavaDoc name() {
111         return NbBundle.getMessage(WebServiceClientWizardIterator.class, "LBL_WebServiceClient"); // NOI18N
112
}
113
114     public WizardDescriptor.Panel current() {
115        return panels[index];
116     }
117
118     public boolean hasNext() {
119         return index < panels.length - 1;
120     }
121
122     public void nextPanel() {
123         if(!hasNext()) {
124             throw new NoSuchElementException();
125         }
126
127         index++;
128     }
129
130     public boolean hasPrevious() {
131         return index > 0;
132     }
133
134     public void previousPanel() {
135         if(!hasNext()) {
136             throw new NoSuchElementException();
137         }
138
139         index--;
140     }
141
142     public void addChangeListener(ChangeListener JavaDoc l) {
143         // nothing to do yet
144
}
145
146     public void removeChangeListener(ChangeListener JavaDoc l) {
147         // nothing to do yet
148
}
149 }
150
Popular Tags