KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > ui > basic > wizard > SchemaAdditionalInfoPanel


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.schema.ui.basic.wizard;
21
22 //java imports
23
import java.awt.Component JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27 import javax.swing.event.ChangeEvent JavaDoc;
28 import javax.swing.event.ChangeListener JavaDoc;
29
30 //netbeans imports
31
import org.openide.util.HelpCtx;
32 import org.openide.WizardDescriptor;
33 import org.openide.loaders.TemplateWizard;
34
35
36 /**
37  * This class represents the data for the schema panel wizard.
38  * Read http://performance.netbeans.org/howto/dialogs/wizard-panels.html.
39  *
40  * @author Samaresh (Samaresh.Panda@Sun.Com)
41  */

42 public class SchemaAdditionalInfoPanel implements WizardDescriptor.Panel, ChangeListener JavaDoc {
43
44     private final List JavaDoc<ChangeListener JavaDoc> listeners = new ArrayList JavaDoc<ChangeListener JavaDoc>();
45     private SchemaAdditionalInfoGUI gui;
46     private TemplateWizard templateWizard;
47
48     /**
49      * Empty constructor.
50      */

51     SchemaAdditionalInfoPanel() {
52         super();
53     }
54     
55     /**
56      * Returns the template wizard.
57      */

58     TemplateWizard getTemplateWizard() {
59         return templateWizard;
60     }
61
62     /**
63      * Returns the GUI associated with this WizardDescriptor.
64      * This is where, the gui panel gets created.
65      */

66     public Component JavaDoc getComponent() {
67         if (gui == null) {
68             gui = new SchemaAdditionalInfoGUI();
69         }
70         return gui;
71     }
72
73     /**
74      * Returns the help context.
75      */

76     public HelpCtx getHelp() {
77         return HelpCtx.DEFAULT_HELP;
78     }
79
80     /**
81      * If true, enables the FINISH button, else not.
82      */

83     public boolean isValid() {
84         return true;
85     }
86
87     /**
88      * Allows addition of listeners.
89      */

90     public void addChangeListener(ChangeListener JavaDoc l) {
91         listeners.add(l);
92     }
93
94     /**
95      * Allows deletion of listeners.
96      */

97     public void removeChangeListener(ChangeListener JavaDoc l) {
98         listeners.remove(l);
99     }
100
101     /**
102      *
103      */

104     private void fireChange() {
105         ChangeEvent JavaDoc e = new ChangeEvent JavaDoc(this);
106         Iterator JavaDoc it = listeners.iterator();
107         while (it.hasNext()) {
108             ((ChangeListener JavaDoc)it.next()).stateChanged(e);
109         }
110     }
111
112     /**
113      *
114      */

115     public void readSettings( Object JavaDoc settings ) {
116         templateWizard = (TemplateWizard)settings;
117     gui.attachListenerToFileName(templateWizard);
118     }
119     
120     /**
121      *
122      */

123     public void storeSettings(Object JavaDoc settings) {
124         if ( WizardDescriptor.PREVIOUS_OPTION.equals( ((WizardDescriptor)settings).getValue() ) ) {
125             return;
126         }
127         if ( WizardDescriptor.CANCEL_OPTION.equals( ((WizardDescriptor)settings).getValue() ) ) {
128             return;
129         }
130         ((WizardDescriptor)settings).putProperty ("NewFileWizard_Title", null); // NOI18N
131
}
132     
133     /**
134      *
135      */

136     public void stateChanged(ChangeEvent JavaDoc e) {
137         fireChange();
138     }
139     
140 }
141
Popular Tags