KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > archive > wizard > DeployableWizardPanel


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 package org.netbeans.modules.j2ee.archive.wizard;
20
21 import java.awt.Component JavaDoc;
22 import java.util.HashSet JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.Set JavaDoc;
25 import javax.swing.event.ChangeEvent JavaDoc;
26 import javax.swing.event.ChangeListener JavaDoc;
27 import org.openide.WizardDescriptor;
28 import org.openide.WizardValidationException;
29 import org.openide.util.HelpCtx;
30 import org.openide.util.NbBundle;
31
32 /**
33  * Panel just asking for basic info.
34  */

35 public class DeployableWizardPanel implements WizardDescriptor.Panel,
36         WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel {
37     
38     private WizardDescriptor wizardDescriptor;
39     private DeployablePanelVisual component;
40     
41     /** Creates a new instance of templateWizardPanel */
42     public DeployableWizardPanel() {
43         component = null;
44         wizardDescriptor = null;;
45     }
46     
47     public Component JavaDoc getComponent() {
48         if (component == null) {
49             component = new DeployablePanelVisual(this);
50             component.setName(NbBundle.getMessage(DeployableWizardPanel.class,"LBL_CreateProjectStep"));
51         }
52         return component;
53     }
54     
55     public HelpCtx getHelp() {
56         return new HelpCtx(DeployableWizardPanel.class);
57     }
58     
59     public boolean isValid() {
60         getComponent();
61         return component.valid(wizardDescriptor);
62     }
63     
64     private final Set JavaDoc/*<ChangeListener>*/ listeners = new HashSet JavaDoc(1);
65     public final void addChangeListener(ChangeListener JavaDoc l) {
66         synchronized (listeners) {
67             listeners.add(l);
68         }
69     }
70     public final void removeChangeListener(ChangeListener JavaDoc l) {
71         synchronized (listeners) {
72             listeners.remove(l);
73         }
74     }
75     protected final void fireChangeEvent() {
76         Iterator JavaDoc it;
77         synchronized (listeners) {
78             it = new HashSet JavaDoc(listeners).iterator();
79         }
80         ChangeEvent JavaDoc ev = new ChangeEvent JavaDoc(this);
81         while (it.hasNext()) {
82             ((ChangeListener JavaDoc) it.next()).stateChanged(ev);
83         }
84     }
85     
86     public void readSettings(Object JavaDoc settings) {
87         wizardDescriptor = (WizardDescriptor) settings;
88         component.read(wizardDescriptor);
89     }
90     
91     public void storeSettings(Object JavaDoc settings) {
92         WizardDescriptor d = (WizardDescriptor) settings;
93         component.store(d);
94     }
95     
96     public boolean isFinishPanel() {
97         return true;
98     }
99     
100     public void validate() throws WizardValidationException {
101         getComponent();
102         component.validate(wizardDescriptor);
103     }
104     
105 }
106
Popular Tags