KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ejb > wizard > session > SessionEJBWizardDescriptor


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.ejbcore.ejb.wizard.session;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.HashSet JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26 import javax.swing.event.ChangeEvent JavaDoc;
27 import javax.swing.event.ChangeListener JavaDoc;
28 import org.openide.WizardDescriptor;
29 import org.openide.util.HelpCtx;
30 import org.openide.util.NbBundle;
31
32 public class SessionEJBWizardDescriptor implements WizardDescriptor.FinishablePanel, ChangeListener JavaDoc {
33     
34     private SessionEJBWizardPanel wizardPanel;
35     //TODO: RETOUCHE
36
// private boolean isWaitingForScan = false;
37

38     private final List JavaDoc<ChangeListener JavaDoc> changeListeners = new ArrayList JavaDoc<ChangeListener JavaDoc>();
39
40     private WizardDescriptor wizardDescriptor;
41
42     public void addChangeListener(ChangeListener JavaDoc changeListener) {
43         changeListeners.add(changeListener);
44     }
45     
46     public java.awt.Component JavaDoc getComponent() {
47         if (wizardPanel == null) {
48             wizardPanel = new SessionEJBWizardPanel(this);
49             // add listener to events which could cause valid status to change
50
}
51         return wizardPanel;
52     }
53     
54     public org.openide.util.HelpCtx getHelp() {
55         return new HelpCtx(SessionEJBWizardDescriptor.class);
56     }
57     
58     public boolean isValid() {
59         // XXX add the following checks
60
// p.getName = valid NmToken
61
// p.getName not already in module
62
if (wizardDescriptor == null) {
63             return true;
64         }
65         boolean isLocalOrRemote = (wizardPanel.isLocal() || wizardPanel.isRemote());
66         if (!isLocalOrRemote) {
67             wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(SessionEJBWizardDescriptor.class,"ERR_RemoteOrLocal_MustBeSelected")); //NOI18N
68
return false;
69         }
70         
71         //TODO: RETOUCHE waitScanFinished
72
// if (JavaMetamodel.getManager().isScanInProgress()) {
73
// if (!isWaitingForScan) {
74
// isWaitingForScan = true;
75
// RequestProcessor.getDefault().post(new Runnable() {
76
// public void run() {
77
// JavaMetamodel.getManager().waitScanFinished();
78
// isWaitingForScan = false;
79
// fireChangeEvent();
80
// }
81
// });
82
// }
83
// wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(SessionEJBWizardPanel.class,"scanning-in-progress")); //NOI18N
84
// return false;
85
// }
86
wizardDescriptor.putProperty("WizardPanel_errorMessage", " "); //NOI18N
87
return true;
88     }
89     
90     public void readSettings(Object JavaDoc settings) {
91         wizardDescriptor = (WizardDescriptor) settings;
92     }
93     
94     public void removeChangeListener(ChangeListener JavaDoc changeListener) {
95         changeListeners.remove(changeListener);
96     }
97     
98     public void storeSettings(Object JavaDoc settings) {
99         
100     }
101     
102     public boolean hasRemote() {
103         return wizardPanel.isRemote();
104     }
105     
106     public boolean hasLocal() {
107         return wizardPanel.isLocal();
108     }
109     
110     public boolean isStateful() {
111         return !wizardPanel.isStateless();
112     }
113     
114     public boolean isFinishPanel() {
115         return isValid();
116     }
117     
118     protected final void fireChangeEvent() {
119         Iterator JavaDoc<ChangeListener JavaDoc> iterator;
120         synchronized (changeListeners) {
121             iterator = new HashSet JavaDoc<ChangeListener JavaDoc>(changeListeners).iterator();
122         }
123         ChangeEvent JavaDoc changeEvent = new ChangeEvent JavaDoc(this);
124         while (iterator.hasNext()) {
125             iterator.next().stateChanged(changeEvent);
126         }
127     }
128
129     public void stateChanged(ChangeEvent JavaDoc changeEvent) {
130         fireChangeEvent();
131     }
132
133 }
134
135
Popular Tags