1 19 20 package org.netbeans.modules.ant.freeform.samples; 21 22 import java.awt.Component ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.Set ; 26 import javax.swing.event.ChangeEvent ; 27 import javax.swing.event.ChangeListener ; 28 import org.openide.WizardDescriptor; 29 import org.openide.WizardValidationException; 30 import org.openide.util.HelpCtx; 31 import org.openide.util.NbBundle; 32 33 public class FreeformWizardPanel implements WizardDescriptor.Panel, 34 WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { 35 36 private WizardDescriptor wizardDescriptor; 37 private FreeformPanelVisual component; 38 39 40 public FreeformWizardPanel() { 41 } 42 43 public Component getComponent() { 44 if (component == null) { 45 component = new FreeformPanelVisual(this); 46 component.setName(NbBundle.getMessage(FreeformWizardPanel.class, "LBL_CreateProjectStep")); 47 } 48 return component; 49 } 50 51 public HelpCtx getHelp() { 52 String help = (String ) wizardDescriptor.getProperty("help"); 53 if (help != null) { 54 return new HelpCtx(help); 55 } else { 56 return null; 57 } 58 } 59 60 public boolean isValid() { 61 getComponent(); 62 return component.valid(wizardDescriptor); 63 } 64 65 private final Set listeners = new HashSet (1); 66 public final void addChangeListener(ChangeListener l) { 67 synchronized (listeners) { 68 listeners.add(l); 69 } 70 } 71 public final void removeChangeListener(ChangeListener l) { 72 synchronized (listeners) { 73 listeners.remove(l); 74 } 75 } 76 protected final void fireChangeEvent() { 77 Iterator it; 78 synchronized (listeners) { 79 it = new HashSet (listeners).iterator(); 80 } 81 ChangeEvent ev = new ChangeEvent (this); 82 while (it.hasNext()) { 83 ((ChangeListener ) it.next()).stateChanged(ev); 84 } 85 } 86 87 public void readSettings(Object settings) { 88 wizardDescriptor = (WizardDescriptor) settings; 89 component.read(wizardDescriptor); 90 } 91 92 public void storeSettings(Object settings) { 93 WizardDescriptor d = (WizardDescriptor) settings; 94 component.store(d); 95 } 96 97 public boolean isFinishPanel() { 98 return true; 99 } 100 101 public void validate() throws WizardValidationException { 102 getComponent(); 103 component.validate(wizardDescriptor); 104 } 105 106 } 107 | Popular Tags |