KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > metainfservices > ExportWizardPanel1


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.metainfservices;
20
21 import java.awt.Component JavaDoc;
22 import java.util.*;
23 import javax.swing.event.ChangeEvent JavaDoc;
24 import javax.swing.event.ChangeListener JavaDoc;
25 import org.openide.WizardDescriptor;
26 import org.openide.util.HelpCtx;
27 import org.openide.filesystems.FileObject;
28
29 public class ExportWizardPanel1 implements WizardDescriptor.Panel {
30
31     /**
32      * The visual component that displays this panel. If you need to access the
33      * component from this class, just use getComponent().
34      */

35     private ExportVisualPanel1 component;
36
37     private boolean valid;
38     private FileObject target;
39
40     // Get the visual component for the panel. In this template, the component
41
// is kept separate. This can be more efficient: if the wizard is created
42
// but never displayed, or not all panels are displayed, it is better to
43
// create only those which really need to be visible.
44
public Component JavaDoc getComponent() {
45         if (component == null) {
46             component = new ExportVisualPanel1(this);
47         }
48         return component;
49     }
50     
51     public HelpCtx getHelp() {
52         // Show no Help button for this panel:
53
return HelpCtx.DEFAULT_HELP;
54         // If you have context help:
55
// return new HelpCtx(SampleWizardPanel1.class);
56
}
57
58     final FileObject getTarget() {
59         return target;
60     }
61     
62     public boolean isValid() {
63         return valid;
64     }
65
66     final void setValid(boolean b) {
67         this.valid = b;
68         fireChangeEvent();
69     }
70     private final Set<ChangeListener JavaDoc> listeners = new HashSet<ChangeListener JavaDoc>(11);
71     public final void addChangeListener(ChangeListener JavaDoc l) {
72         synchronized (listeners) {
73             listeners.add(l);
74         }
75     }
76     public final void removeChangeListener(ChangeListener JavaDoc l) {
77         synchronized (listeners) {
78             listeners.remove(l);
79         }
80     }
81     protected final void fireChangeEvent() {
82         Iterator<ChangeListener JavaDoc> it;
83         synchronized (listeners) {
84             it = new HashSet<ChangeListener JavaDoc>(listeners).iterator();
85         }
86         ChangeEvent JavaDoc ev = new ChangeEvent JavaDoc(this);
87         while (it.hasNext()) {
88             it.next().stateChanged(ev);
89         }
90     }
91     
92     @SuppressWarnings JavaDoc("unchecked")
93     public void readSettings(Object JavaDoc settings) {
94         WizardDescriptor wd = (WizardDescriptor)settings;
95         String JavaDoc impl = (String JavaDoc)wd.getProperty("implName"); // NOI18N
96
Collection<String JavaDoc> interfaces = (Collection<String JavaDoc>)wd.getProperty("interfaceNames"); // NOI18N
97
target = (FileObject)wd.getProperty("target"); // NOI18N
98

99         if (component != null) {
100             component.fillTable(interfaces);
101         }
102     }
103     public void storeSettings(Object JavaDoc settings) {
104         WizardDescriptor wd = (WizardDescriptor)settings;
105         wd.putProperty("files", component.generatedFiles());
106     }
107     
108 }
109
110
Popular Tags