KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbcore > ejb > wizard > dd > EjbJarXmlWizardPanel1


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

41 public class EjbJarXmlWizardPanel1 implements WizardDescriptor.Panel {
42
43     // generated by apisupport wizard
44

45     /**
46      * The visual component that displays this panel. If you need to access the
47      * component from this class, just use getComponent().
48      */

49     private final Set JavaDoc<ChangeListener JavaDoc> listeners = new HashSet JavaDoc<ChangeListener JavaDoc>(1);
50     private final EjbJarXmlVisualPanel1 component = new EjbJarXmlVisualPanel1();
51     private WizardDescriptor wizardDescriptor;
52     private Project project;
53     
54     public EjbJarXmlWizardPanel1() {
55         component.addPropertyChangeListener(new PropertyChangeListener JavaDoc() {
56             public void propertyChange(PropertyChangeEvent JavaDoc evt) {
57                 fireChangeEvent();
58             }
59         });
60     }
61     
62     FileObject getSelectedLocation() {
63         return component.getSelectedLocation();
64     }
65     
66     Project getProject() {
67         return project;
68     }
69     
70     public Component JavaDoc getComponent() {
71         return component;
72     }
73     
74     public HelpCtx getHelp() {
75         return HelpCtx.DEFAULT_HELP;
76     }
77     
78     public boolean isValid() {
79         if (component.getSelectedLocation() == null) {
80             wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(EjbJarXmlWizardPanel1.class,"ERR_FileExistsOrNoValidLocation")); //NOI18N
81
return false;
82         }
83         return true;
84     }
85     
86     public final void addChangeListener(ChangeListener JavaDoc listener) {
87         synchronized (listeners) {
88             listeners.add(listener);
89         }
90     }
91     
92     public final void removeChangeListener(ChangeListener JavaDoc listener) {
93         synchronized (listeners) {
94             listeners.remove(listener);
95         }
96     }
97
98     protected final void fireChangeEvent() {
99         Iterator JavaDoc<ChangeListener JavaDoc> listenersIterator;
100         synchronized (listeners) {
101             listenersIterator = new HashSet JavaDoc<ChangeListener JavaDoc>(listeners).iterator();
102         }
103         ChangeEvent JavaDoc changeEvent = new ChangeEvent JavaDoc(this);
104         while (listenersIterator.hasNext()) {
105             listenersIterator.next().stateChanged(changeEvent);
106         }
107     }
108     
109     public void readSettings(Object JavaDoc settings) {
110         wizardDescriptor = (WizardDescriptor) settings;
111         if (project == null) {
112             project = Templates.getProject(wizardDescriptor);
113             component.setProject(project);
114         }
115     }
116     
117     public void storeSettings(Object JavaDoc settings) {}
118     
119 }
120
121
Popular Tags