KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > loaders > TemplateWizardPanel1


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.openide.loaders;
21
22 import javax.swing.event.ChangeListener JavaDoc;
23 import org.openide.WizardDescriptor;
24 import org.openide.nodes.Node;
25 import org.openide.util.HelpCtx;
26
27 /** Implementaion of WizardDescriptor.Panel that can be used in create from template.
28  *
29  * @author Jiri Rechtacek
30  */

31 final class TemplateWizardPanel1 implements WizardDescriptor.Panel<WizardDescriptor> {
32     private TemplateWizard1 templateWizard1UI;
33     /** listener to changes in the wizard */
34     private ChangeListener JavaDoc listener;
35
36     private TemplateWizard1 getPanelUI () {
37         if (templateWizard1UI == null) {
38             templateWizard1UI = new TemplateWizard1 ();
39             templateWizard1UI.addChangeListener (listener);
40         }
41         return templateWizard1UI;
42     }
43     
44     /** Add a listener to changes of the panel's validity.
45     * @param l the listener to add
46     * @see #isValid
47     */

48     public void addChangeListener (ChangeListener JavaDoc l) {
49         if (listener != null) throw new IllegalStateException JavaDoc ();
50         if (templateWizard1UI != null)
51             templateWizard1UI.addChangeListener (l);
52         listener = l;
53     }
54
55     /** Remove a listener to changes of the panel's validity.
56     * @param l the listener to remove
57     */

58     public void removeChangeListener (ChangeListener JavaDoc l) {
59         listener = null;
60         if (templateWizard1UI != null)
61             templateWizard1UI.removeChangeListener (l);
62     }
63
64     /** Get the component displayed in this panel.
65      *
66      * Note; method can be called from any thread, but not concurrently
67      * with other methods of this interface.
68      *
69      * @return the UI component of this wizard panel
70      *
71      */

72     public java.awt.Component JavaDoc getComponent() {
73         return getPanelUI ();
74     }
75     
76     /** Help for this panel.
77     * @return the help or <code>null</code> if no help is supplied
78     */

79     public HelpCtx getHelp () {
80         if (templateWizard1UI != null) {
81             if (templateWizard1UI.getExplorerManager().getRootContext() != Node.EMPTY) {
82                 return new HelpCtx(TemplateWizard1.class.getName()+"."+ // NOI18N
83
templateWizard1UI.getExplorerManager().getRootContext().getName());
84             }
85         }
86         return new HelpCtx (TemplateWizard1.class);
87     }
88
89     /** Test whether the panel is finished and it is safe to proceed to the next one.
90     * If the panel is valid, the "Next" (or "Finish") button will be enabled.
91     * @return <code>true</code> if the user has entered satisfactory information
92     */

93     public boolean isValid() {
94         if (templateWizard1UI == null)
95             return false;
96         return getPanelUI ().implIsValid ();
97     }
98     
99     /** Provides the wizard panel with the current data--either
100     * the default data or already-modified settings, if the user used the previous and/or next buttons.
101     * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
102     * @param settings the object representing wizard panel state, as originally supplied to {@link WizardDescriptor#WizardDescriptor(WizardDescriptor.Iterator,Object)}
103     */

104     public void readSettings(WizardDescriptor settings) {
105         getPanelUI ().implReadSettings (settings);
106     }
107     
108     /** Provides the wizard panel with the opportunity to update the
109     * settings with its current customized state.
110     * Rather than updating its settings with every change in the GUI, it should collect them,
111     * and then only save them when requested to by this method.
112     * Also, the original settings passed to {@link #readSettings} should not be modified (mutated);
113     * rather, the (copy) passed in here should be mutated according to the collected changes.
114     * This method can be called multiple times on one instance of <code>WizardDescriptor.Panel</code>.
115     * @param settings the object representing a settings of the wizard
116     */

117     public void storeSettings(WizardDescriptor settings) {
118         getPanelUI ().implStoreSettings (settings);
119     }
120     
121 }
122
Popular Tags