KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.HashSet JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.Set JavaDoc;
25
26 import java.awt.Component JavaDoc;
27 import javax.swing.event.ChangeEvent JavaDoc;
28 import javax.swing.event.ChangeListener JavaDoc;
29
30 import org.openide.WizardDescriptor;
31 import org.openide.util.HelpCtx;
32 import org.openide.util.NbBundle;
33
34 import org.netbeans.api.project.Project;
35 import org.netbeans.spi.project.ui.templates.support.Templates;
36
37
38 /**
39  *
40  * @author Peter Williams
41  */

42 public class WebServiceClientWizardDescriptor implements WizardDescriptor.FinishablePanel, WizardDescriptor.ValidatingPanel {
43
44     private WizardDescriptor wizardDescriptor;
45     private ClientInfo component = null;
46     private String JavaDoc projectPath;
47     private Project project;
48
49     public WebServiceClientWizardDescriptor() {
50     }
51
52     public boolean isFinishPanel(){
53         return true;
54     }
55
56     private final Set JavaDoc<ChangeListener JavaDoc> listeners = new HashSet JavaDoc<ChangeListener JavaDoc>(1);
57         public final void addChangeListener(ChangeListener JavaDoc l) {
58         synchronized (listeners) {
59             listeners.add(l);
60         }
61     }
62
63     public final void removeChangeListener(ChangeListener JavaDoc l) {
64         synchronized (listeners) {
65             listeners.remove(l);
66         }
67     }
68
69     protected final void fireChangeEvent() {
70         Iterator JavaDoc<ChangeListener JavaDoc> it;
71         synchronized (listeners) {
72             it = new HashSet JavaDoc<ChangeListener JavaDoc>(listeners).iterator();
73         }
74         ChangeEvent JavaDoc ev = new ChangeEvent JavaDoc(this);
75         while (it.hasNext()) {
76             it.next().stateChanged(ev);
77         }
78     }
79
80     public Component JavaDoc getComponent() {
81         if(component == null) {
82             component = new ClientInfo(this);
83         }
84
85         return component;
86     }
87
88     public HelpCtx getHelp() {
89         return new HelpCtx(WebServiceClientWizardDescriptor.class);
90     }
91
92     public boolean isValid() {
93         boolean projectDirValid=true;
94         String JavaDoc illegalChar = null;
95         
96         if (projectPath.indexOf("%")>=0) {
97             projectDirValid=false;
98             illegalChar="%";
99         } else if (projectPath.indexOf("&")>=0) {
100             projectDirValid=false;
101             illegalChar="&";
102         } else if (projectPath.indexOf("?")>=0) {
103             projectDirValid=false;
104             illegalChar="?";
105         }
106         if (!projectDirValid) {
107             wizardDescriptor.putProperty("WizardPanel_errorMessage",
108                     NbBundle.getMessage(WebServiceClientWizardDescriptor.class,"MSG_InvalidProjectPath",projectPath,illegalChar));
109             return false;
110         }
111         
112         return component.valid(wizardDescriptor);
113     }
114
115     public void readSettings(Object JavaDoc settings) {
116         wizardDescriptor = (WizardDescriptor) settings;
117         component.read(wizardDescriptor);
118         project = Templates.getProject(wizardDescriptor);
119         projectPath = project.getProjectDirectory().getPath();
120
121         // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
122
// this name is used in NewFileWizard to modify the title
123
wizardDescriptor.putProperty("NewFileWizard_Title",
124         NbBundle.getMessage(WebServiceClientWizardDescriptor.class, "LBL_WebServiceClient"));// NOI18N
125
}
126
127     public void storeSettings(Object JavaDoc settings) {
128         WizardDescriptor d = (WizardDescriptor) settings;
129         component.store(d);
130         ((WizardDescriptor) d).putProperty("NewFileWizard_Title", null); // NOI18N
131
}
132
133     public void validate() throws org.openide.WizardValidationException {
134         component.validatePanel();
135     }
136     
137 }
138
Popular Tags