KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > feedreader > FeedReaderWizardPanel


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.apisupport.feedreader;
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
31 /**
32  * Panel just asking for basic info.
33  */

34 public class FeedReaderWizardPanel implements WizardDescriptor.Panel,
35         WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel {
36
37     private WizardDescriptor wizardDescriptor;
38     private FeedReaderPanelVisual component;
39     
40     public Component JavaDoc getComponent() {
41         if (component == null) {
42             component = new FeedReaderPanelVisual(this);
43         }
44         return component;
45     }
46     
47     public HelpCtx getHelp() {
48         return new HelpCtx( FeedReaderWizardPanel.class );
49     }
50     
51     public boolean isValid() {
52         getComponent();
53         return component.valid( wizardDescriptor );
54     }
55     
56     private final Set JavaDoc/*<ChangeListener>*/ listeners = new HashSet JavaDoc(1);
57     public final void addChangeListener(ChangeListener JavaDoc l) {
58         synchronized (listeners) {
59             listeners.add(l);
60         }
61     }
62     public final void removeChangeListener(ChangeListener JavaDoc l) {
63         synchronized (listeners) {
64             listeners.remove(l);
65         }
66     }
67     protected final void fireChangeEvent() {
68         Iterator JavaDoc it;
69         synchronized (listeners) {
70             it = new HashSet JavaDoc(listeners).iterator();
71         }
72         ChangeEvent JavaDoc ev = new ChangeEvent JavaDoc(this);
73         while (it.hasNext()) {
74             ((ChangeListener JavaDoc)it.next()).stateChanged(ev);
75         }
76     }
77     
78     public void readSettings(Object JavaDoc settings) {
79         wizardDescriptor = (WizardDescriptor)settings;
80         component.read(wizardDescriptor);
81         
82         // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
83
// this name is used in NewProjectWizard to modify the title
84
// Object substitute = ((JComponent)component).getClientProperty ("NewProjectWizard_Title"); // NOI18N
85
// if (substitute != null) {
86
// wizardDescriptor.putProperty ("NewProjectWizard_Title", substitute); // NOI18N
87
// }
88
}
89     
90     public void storeSettings(Object JavaDoc settings) {
91         WizardDescriptor d = (WizardDescriptor)settings;
92         component.store(d);
93 // ((WizardDescriptor)d).putProperty ("NewProjectWizard_Title", null); // NOI18N
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