author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:52:45 +0200 | |
changeset 52 | 4257f4cf226b |
permissions | -rw-r--r-- |
jtulach@52 | 1 |
package org.netbeans.apifest.testingtemplate; |
jtulach@52 | 2 |
|
jtulach@52 | 3 |
import java.awt.Component; |
jtulach@52 | 4 |
import java.util.HashSet; |
jtulach@52 | 5 |
import java.util.Iterator; |
jtulach@52 | 6 |
import java.util.Set; |
jtulach@52 | 7 |
import javax.swing.event.ChangeEvent; |
jtulach@52 | 8 |
import javax.swing.event.ChangeListener; |
jtulach@52 | 9 |
import org.openide.WizardDescriptor; |
jtulach@52 | 10 |
import org.openide.WizardValidationException; |
jtulach@52 | 11 |
import org.openide.util.HelpCtx; |
jtulach@52 | 12 |
import org.openide.util.NbBundle; |
jtulach@52 | 13 |
|
jtulach@52 | 14 |
/** |
jtulach@52 | 15 |
* Panel just asking for basic info. |
jtulach@52 | 16 |
*/ |
jtulach@52 | 17 |
public class TestingTemplateWizardPanel implements WizardDescriptor.Panel, |
jtulach@52 | 18 |
WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { |
jtulach@52 | 19 |
|
jtulach@52 | 20 |
private WizardDescriptor wizardDescriptor; |
jtulach@52 | 21 |
private TestingTemplatePanelVisual component; |
jtulach@52 | 22 |
|
jtulach@52 | 23 |
/** Creates a new instance of templateWizardPanel */ |
jtulach@52 | 24 |
public TestingTemplateWizardPanel() { |
jtulach@52 | 25 |
} |
jtulach@52 | 26 |
|
jtulach@52 | 27 |
public Component getComponent() { |
jtulach@52 | 28 |
if (component == null) { |
jtulach@52 | 29 |
component = new TestingTemplatePanelVisual(this); |
jtulach@52 | 30 |
component.setName(NbBundle.getMessage(TestingTemplateWizardPanel.class, "LBL_CreateProjectStep")); |
jtulach@52 | 31 |
} |
jtulach@52 | 32 |
return component; |
jtulach@52 | 33 |
} |
jtulach@52 | 34 |
|
jtulach@52 | 35 |
public HelpCtx getHelp() { |
jtulach@52 | 36 |
return new HelpCtx(TestingTemplateWizardPanel.class); |
jtulach@52 | 37 |
} |
jtulach@52 | 38 |
|
jtulach@52 | 39 |
public boolean isValid() { |
jtulach@52 | 40 |
getComponent(); |
jtulach@52 | 41 |
return component.valid(wizardDescriptor); |
jtulach@52 | 42 |
} |
jtulach@52 | 43 |
|
jtulach@52 | 44 |
private final Set/*<ChangeListener>*/ listeners = new HashSet(1); |
jtulach@52 | 45 |
public final void addChangeListener(ChangeListener l) { |
jtulach@52 | 46 |
synchronized (listeners) { |
jtulach@52 | 47 |
listeners.add(l); |
jtulach@52 | 48 |
} |
jtulach@52 | 49 |
} |
jtulach@52 | 50 |
public final void removeChangeListener(ChangeListener l) { |
jtulach@52 | 51 |
synchronized (listeners) { |
jtulach@52 | 52 |
listeners.remove(l); |
jtulach@52 | 53 |
} |
jtulach@52 | 54 |
} |
jtulach@52 | 55 |
protected final void fireChangeEvent() { |
jtulach@52 | 56 |
Iterator it; |
jtulach@52 | 57 |
synchronized (listeners) { |
jtulach@52 | 58 |
it = new HashSet(listeners).iterator(); |
jtulach@52 | 59 |
} |
jtulach@52 | 60 |
ChangeEvent ev = new ChangeEvent(this); |
jtulach@52 | 61 |
while (it.hasNext()) { |
jtulach@52 | 62 |
((ChangeListener) it.next()).stateChanged(ev); |
jtulach@52 | 63 |
} |
jtulach@52 | 64 |
} |
jtulach@52 | 65 |
|
jtulach@52 | 66 |
public void readSettings(Object settings) { |
jtulach@52 | 67 |
wizardDescriptor = (WizardDescriptor) settings; |
jtulach@52 | 68 |
component.read(wizardDescriptor); |
jtulach@52 | 69 |
} |
jtulach@52 | 70 |
|
jtulach@52 | 71 |
public void storeSettings(Object settings) { |
jtulach@52 | 72 |
WizardDescriptor d = (WizardDescriptor) settings; |
jtulach@52 | 73 |
component.store(d); |
jtulach@52 | 74 |
} |
jtulach@52 | 75 |
|
jtulach@52 | 76 |
public boolean isFinishPanel() { |
jtulach@52 | 77 |
return true; |
jtulach@52 | 78 |
} |
jtulach@52 | 79 |
|
jtulach@52 | 80 |
public void validate() throws WizardValidationException { |
jtulach@52 | 81 |
getComponent(); |
jtulach@52 | 82 |
component.validate(wizardDescriptor); |
jtulach@52 | 83 |
} |
jtulach@52 | 84 |
|
jtulach@52 | 85 |
} |