KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ejb > wizard > mdb > MessageEJBWizardPanel


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.mdb;
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.netbeans.api.project.Project;
29 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar;
30 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
31 import org.netbeans.spi.project.ui.templates.support.Templates;
32 import org.openide.WizardDescriptor;
33 import org.openide.util.HelpCtx;
34 import org.openide.util.NbBundle;
35
36 public class MessageEJBWizardPanel implements WizardDescriptor.FinishablePanel {
37     
38     private MessageEJBVisualPanel wizardPanel;
39     private final List JavaDoc<ChangeListener JavaDoc> changeListeners = new ArrayList JavaDoc<ChangeListener JavaDoc>();
40     private final WizardDescriptor wizardDescriptor;
41     //TODO: RETOUCHE
42
// private boolean isWaitingForScan = false;
43

44     public MessageEJBWizardPanel(WizardDescriptor wizardDescriptor) {
45         this.wizardDescriptor = wizardDescriptor;
46     }
47
48     public void addChangeListener(ChangeListener JavaDoc changeListener) {
49         changeListeners.add(changeListener);
50     }
51     
52     public boolean isValid() {
53         Project project = Templates.getProject(wizardDescriptor);
54         J2eeModuleProvider j2eeModuleProvider = (J2eeModuleProvider) project.getLookup ().lookup (J2eeModuleProvider.class);
55         String JavaDoc j2eeVersion = j2eeModuleProvider.getJ2eeModule().getModuleVersion();
56         if (!EjbJar.VERSION_3_0.equals(j2eeVersion) && !EjbJar.VERSION_2_1.equals(j2eeVersion)) {
57             wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(MessageEJBWizardPanel.class,"MSG_WrongJ2EESpecVersion")); //NOI18N
58
return false;
59         }
60
61         //TODO: RETOUCHE waitScanFinished
62
// if (JavaMetamodel.getManager().isScanInProgress()) {
63
// if (!isWaitingForScan) {
64
// isWaitingForScan = true;
65
// RequestProcessor.getDefault().post(new Runnable() {
66
// public void run() {
67
// JavaMetamodel.getManager().waitScanFinished();
68
// fireChangeEvent();
69
// }
70
// });
71
// }
72
// wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(MessageEJBWizardPanel.class,"scanning-in-progress")); //NOI18N
73
// return false;
74
// }
75

76         // XXX add the following checks
77
// p.getName = valid NmToken
78
// p.getName not already in module
79
// remote and or local is selected
80
return true;
81     }
82     
83     public void readSettings(Object JavaDoc settings) {
84     }
85     
86     public void removeChangeListener(ChangeListener JavaDoc changeListener) {
87         changeListeners.remove(changeListener);
88     }
89     
90     public void storeSettings(Object JavaDoc settings) {
91         
92     }
93     
94     public boolean isFinishPanel() {
95         return isValid();
96     }
97     
98     protected final void fireChangeEvent() {
99         Iterator JavaDoc<ChangeListener JavaDoc> iterator;
100         synchronized (changeListeners) {
101             iterator = new HashSet JavaDoc<ChangeListener JavaDoc>(changeListeners).iterator();
102         }
103         ChangeEvent JavaDoc changeEvent = new ChangeEvent JavaDoc(this);
104         while (iterator.hasNext()) {
105             iterator.next().stateChanged(changeEvent);
106         }
107     }
108
109     public org.openide.util.HelpCtx getHelp() {
110         return new HelpCtx(this.getClass());
111     }
112
113     public java.awt.Component JavaDoc getComponent() {
114         if (wizardPanel == null) {
115             wizardPanel = new MessageEJBVisualPanel();
116             // add listener to events which could cause valid status to change
117
}
118         return wizardPanel;
119     }
120
121     public boolean isQueue() {
122         return wizardPanel.isQueue();
123     }
124
125 }
126
127
Popular Tags