KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tomcat5 > wizard > InstallPanel


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.tomcat5.wizard;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.List JavaDoc;
25 import javax.swing.event.ChangeEvent JavaDoc;
26 import javax.swing.event.ChangeListener JavaDoc;
27 import org.netbeans.modules.tomcat5.TomcatManager.TomcatVersion;
28 import org.openide.WizardDescriptor;
29 import org.openide.util.HelpCtx;
30
31 /**
32  * Add Tomcat wizard descriptor panel implementation.
33  */

34 class InstallPanel implements WizardDescriptor.Panel, ChangeListener JavaDoc {
35
36     private final List JavaDoc listeners = new ArrayList JavaDoc();
37     private WizardDescriptor wizard;
38     private InstallPanelVisual component;
39     private final TomcatVersion tomcatVersion;
40
41     public InstallPanel(TomcatVersion tomcatVersion) {
42         this.tomcatVersion = tomcatVersion;
43     }
44
45     public void addChangeListener(javax.swing.event.ChangeListener JavaDoc l) {
46         synchronized (listeners) {
47             listeners.add(l);
48         }
49     }
50
51     public void removeChangeListener(javax.swing.event.ChangeListener JavaDoc l) {
52         synchronized (listeners) {
53             listeners.remove(l);
54         }
55     }
56
57     public void storeSettings(Object JavaDoc settings) {
58     }
59
60     public void readSettings(Object JavaDoc settings) {
61         wizard = (WizardDescriptor)settings;
62     }
63
64     public boolean isValid() {
65         boolean result = getVisual().isValid();
66         wizard.putProperty(AddInstanceIterator.PROP_ERROR_MESSAGE, getVisual().getErrorMessage());
67         return result;
68     }
69
70     public java.awt.Component JavaDoc getComponent() {
71         if (component == null) {
72             component = new InstallPanelVisual(tomcatVersion);
73             component.addChangeListener(this);
74         }
75
76         return component;
77     }
78
79     public org.openide.util.HelpCtx getHelp() {
80         return new HelpCtx("tomcat_addinstall"); // NOI18N
81
}
82
83     public void stateChanged(javax.swing.event.ChangeEvent JavaDoc event) {
84         fireChange(event);
85     }
86
87     public InstallPanelVisual getVisual() {
88         return (InstallPanelVisual)getComponent();
89     }
90
91     private void fireChange(ChangeEvent JavaDoc event) {
92         ArrayList JavaDoc tempList;
93
94         synchronized (listeners) {
95             tempList = new ArrayList JavaDoc(listeners);
96         }
97
98         Iterator JavaDoc iter = tempList.iterator();
99         while (iter.hasNext())
100             ((ChangeListener JavaDoc)iter.next()).stateChanged(event);
101     }
102 }
103
Popular Tags