01: package org.netbeans.modules.mashup.db.wizard;
02:
03: import java.awt.Component;
04: import java.util.HashSet;
05: import java.util.Iterator;
06: import java.util.Set;
07:
08: import javax.swing.event.ChangeEvent;
09: import javax.swing.event.ChangeListener;
10:
11: import org.openide.WizardDescriptor;
12: import org.openide.util.HelpCtx;
13:
14: public class NewFlatfileDatabaseWizardPanel implements
15: WizardDescriptor.Panel {
16:
17: private Component component;
18:
19: public Component getComponent() {
20: if (component == null) {
21: component = new NewFlatfileDatabaseVisualPanel(this );
22: }
23: return component;
24: }
25:
26: public HelpCtx getHelp() {
27: return HelpCtx.DEFAULT_HELP;
28: }
29:
30: public boolean isValid() {
31: return canAdvance();
32: }
33:
34: private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(
35: 1);
36:
37: public final void addChangeListener(ChangeListener l) {
38: synchronized (listeners) {
39: listeners.add(l);
40: }
41: }
42:
43: public final void removeChangeListener(ChangeListener l) {
44: synchronized (listeners) {
45: listeners.remove(l);
46: }
47: }
48:
49: protected final void fireChangeEvent() {
50: Iterator<ChangeListener> it;
51: synchronized (listeners) {
52: it = new HashSet<ChangeListener>(listeners).iterator();
53: }
54: ChangeEvent ev = new ChangeEvent(this );
55: while (it.hasNext()) {
56: it.next().stateChanged(ev);
57: }
58: }
59:
60: public void readSettings(Object settings) {
61: NewFlatfileDatabaseVisualPanel panel = (NewFlatfileDatabaseVisualPanel) getComponent();
62: panel.clearText();
63: }
64:
65: public void storeSettings(Object settings) {
66: if (settings instanceof WizardDescriptor) {
67: WizardDescriptor wd = (WizardDescriptor) settings;
68: NewFlatfileDatabaseVisualPanel panel = (NewFlatfileDatabaseVisualPanel) getComponent();
69: wd.putProperty("dbName", panel.getDBName());
70: }
71: }
72:
73: private boolean canAdvance() {
74: NewFlatfileDatabaseVisualPanel panel = (NewFlatfileDatabaseVisualPanel) getComponent();
75: return panel.canProceed();
76: }
77: }
|