KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > deployment > impl > ui > wizard > ServerChooserPanel


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.deployment.impl.ui.wizard;
21
22 import java.awt.Component JavaDoc;
23 import java.util.ArrayList 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
31 /**
32  *
33  * @author Andrei Badea
34  */

35 class ServerChooserPanel implements WizardDescriptor.Panel, ChangeListener JavaDoc {
36     private final List JavaDoc listeners = new ArrayList JavaDoc();
37     private ServerChooserVisual component;
38
39     public ServerChooserPanel() {
40     }
41
42     public Component JavaDoc getComponent() {
43         if (component == null) {
44             component = new ServerChooserVisual();
45             component.addChangeListener(this);
46         }
47         return component;
48     }
49
50     public HelpCtx getHelp() {
51         return HelpCtx.DEFAULT_HELP;
52     }
53
54     public void readSettings(Object JavaDoc settings) {
55         getVisual().read((AddServerInstanceWizard)settings);
56     }
57
58     public void storeSettings(Object JavaDoc settings) {
59         getVisual().store((AddServerInstanceWizard)settings);
60     }
61
62     public boolean isValid() {
63         return getVisual().isValid();
64     }
65
66     public void addChangeListener(ChangeListener JavaDoc l) {
67         synchronized (listeners) {
68             listeners.add(l);
69         }
70     }
71
72     public void removeChangeListener(ChangeListener JavaDoc l) {
73         synchronized (listeners) {
74             listeners.remove(l);
75         }
76     }
77
78     public void stateChanged(ChangeEvent JavaDoc event) {
79         fireChange(event);
80     }
81
82     private void fireChange(ChangeEvent JavaDoc event) {
83         ArrayList JavaDoc tempList;
84
85         synchronized (listeners) {
86             tempList = new ArrayList JavaDoc(listeners);
87         }
88
89         Iterator JavaDoc iter = tempList.iterator();
90         while (iter.hasNext())
91             ((ChangeListener JavaDoc)iter.next()).stateChanged(event);
92     }
93
94     private ServerChooserVisual getVisual() {
95         return (ServerChooserVisual)getComponent();
96     }
97 }
98
Popular Tags