1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.webphotos.netbeans.project.empty;
17
18 import java.awt.Component;
19 import java.util.HashSet;
20 import java.util.Set;
21 import javax.swing.event.ChangeEvent;
22 import javax.swing.event.ChangeListener;
23 import net.sf.webphotos.netbeans.project.Constants.ProjectFactory;
24 import org.openide.WizardDescriptor;
25 import org.openide.WizardValidationException;
26 import org.openide.util.HelpCtx;
27 import org.openide.util.NbBundle;
28
29
30
31
32 public class EmptyWebPhotosProjectWizardPanel implements WizardDescriptor.Panel,
33 WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel {
34
35 private WizardDescriptor wizardDescriptor;
36 private EmptyWebPhotosProjectPanelVisual component;
37
38 public EmptyWebPhotosProjectWizardPanel() {
39 }
40
41 @Override
42 public Component getComponent() {
43 if (component == null) {
44 component = new EmptyWebPhotosProjectPanelVisual(this);
45 component.setName(NbBundle.getMessage(EmptyWebPhotosProjectWizardPanel.class, "LBL_CreateProjectStep"));
46 }
47 return component;
48 }
49
50 @Override
51 public HelpCtx getHelp() {
52 return new HelpCtx(ProjectFactory.EMPTY_WEBPHOTOS_PROJECT_WIZARD_PANEL);
53 }
54
55 @Override
56 public boolean isValid() {
57 getComponent();
58 return component.valid(wizardDescriptor);
59 }
60 private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1);
61
62 @Override
63 public final void addChangeListener(ChangeListener l) {
64 synchronized (listeners) {
65 listeners.add(l);
66 }
67 }
68
69 @Override
70 public final void removeChangeListener(ChangeListener l) {
71 synchronized (listeners) {
72 listeners.remove(l);
73 }
74 }
75
76 protected final void fireChangeEvent() {
77 Set<ChangeListener> ls;
78 synchronized (listeners) {
79 ls = new HashSet<ChangeListener>(listeners);
80 }
81 ChangeEvent ev = new ChangeEvent(this);
82 for (ChangeListener l : ls) {
83 l.stateChanged(ev);
84 }
85 }
86
87 @Override
88 public void readSettings(Object settings) {
89 wizardDescriptor = (WizardDescriptor) settings;
90 component.read(wizardDescriptor);
91 }
92
93 @Override
94 public void storeSettings(Object settings) {
95 WizardDescriptor d = (WizardDescriptor) settings;
96 component.store(d);
97 }
98
99 @Override
100 public boolean isFinishPanel() {
101 return true;
102 }
103
104 @Override
105 public void validate() throws WizardValidationException {
106 getComponent();
107 component.validate(wizardDescriptor);
108 }
109 }