KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > wizards > WrapperSelection


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.web.wizards;
21
22 import java.awt.Component JavaDoc;
23 import java.util.HashSet JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.Set JavaDoc;
26 import javax.swing.event.ChangeEvent JavaDoc;
27 import javax.swing.event.ChangeListener JavaDoc;
28
29 import org.openide.WizardDescriptor;
30 import org.openide.util.HelpCtx;
31 import org.openide.loaders.TemplateWizard;
32
33 /** A single panel descriptor for a wizard.
34  * You probably want to make a wizard iterator to hold it.
35  *
36  * @author Milan Kuchtiak
37  */

38 public class WrapperSelection implements WizardDescriptor.Panel {
39
40     /** The visual component that displays this panel.
41      * If you need to access the component from this class,
42      * just use getComponent().
43      */

44     private WrapperPanel component;
45     private transient TemplateWizard wizard;
46     
47     /** Create the wizard panel descriptor. */
48     public WrapperSelection(TemplateWizard wizard) {
49         this.wizard=wizard;
50     }
51     
52     // Get the visual component for the panel. In this template, the component
53
// is kept separate. This can be more efficient: if the wizard is created
54
// but never displayed, or not all panels are displayed, it is better to
55
// create only those which really need to be visible.
56
public Component JavaDoc getComponent() {
57         if (component == null) {
58             component = new WrapperPanel(this);
59         }
60         return component;
61     }
62     
63     public HelpCtx getHelp() {
64         return null;
65     }
66     
67     public boolean isValid() {
68         // If it is always OK to press Next or Finish, then:
69
return true;
70         // If it depends on some condition (form filled out...), then:
71
// return someCondition ();
72
// and when this condition changes (last form field filled in...) then:
73
// fireChangeEvent ();
74
// and uncomment the complicated stuff below.
75
}
76     
77 /*
78     public boolean isValid() {
79     if(isListenerSelected()) {
80         wizard.putProperty("WizardPanel_errorMessage", ""); //NOI18N
81         return true;
82     }
83     wizard.putProperty("WizardPanel_errorMessage", //NOI18N
84             org.openide.util.NbBundle.getMessage(ListenerPanel.class,"MSG_noListenerSelected"));
85     return false;
86     }
87 */

88  
89     public final void addChangeListener(ChangeListener JavaDoc l) {}
90     public final void removeChangeListener(ChangeListener JavaDoc l) {}
91 /*
92     private final Set listeners = new HashSet (1); // Set<ChangeListener>
93     public final void addChangeListener (ChangeListener l) {
94         synchronized (listeners) {
95             listeners.add (l);
96         }
97     }
98     public final void removeChangeListener (ChangeListener l) {
99         synchronized (listeners) {
100             listeners.remove (l);
101         }
102     }
103     protected final void fireChangeEvent () {
104         Iterator it;
105         synchronized (listeners) {
106             it = new HashSet (listeners).iterator ();
107         }
108         ChangeEvent ev = new ChangeEvent (this);
109         while (it.hasNext ()) {
110             ((ChangeListener) it.next ()).stateChanged (ev);
111         }
112     }
113 */

114     
115     // You can use a settings object to keep track of state.
116
// Normally the settings object will be the WizardDescriptor,
117
// so you can use WizardDescriptor.getProperty & putProperty
118
// to store information entered by the user.
119
public void readSettings(Object JavaDoc settings) {
120     }
121     public void storeSettings(Object JavaDoc settings) {
122     }
123     
124     boolean isWrapper() {return component.isWrapper();}
125
126 }
127
Popular Tags