1 19 20 package org.netbeans.modules.websvc.core.dev.wizard; 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.JComponent ; 27 import javax.swing.event.ChangeEvent ; 28 import javax.swing.event.ChangeListener ; 29 import org.netbeans.api.project.Project; 30 31 import org.openide.WizardDescriptor; 32 import org.openide.WizardValidationException; 33 import org.openide.util.HelpCtx; 34 35 39 public class WebServiceFromWSDL implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel, WizardDescriptor.ValidatingPanel, ChangeListener { 40 41 private WebServiceFromWSDLPanel component; 42 private WizardDescriptor wizardDescriptor; 43 private Project project; 44 45 46 public WebServiceFromWSDL(WizardDescriptor wizardDescriptor, Project project) { 47 this.wizardDescriptor = wizardDescriptor; 48 this.project = project; 49 } 50 51 public Component getComponent() { 52 if (component == null) { 53 component = new WebServiceFromWSDLPanel(project); 54 component.addChangeListener(this); 55 } 56 57 return component; 58 } 59 60 public HelpCtx getHelp() { 61 HelpCtx helpCtx = null; 62 if (getComponent() != null && (helpCtx = component.getHelpCtx()) != null) 63 return helpCtx; 64 65 return new HelpCtx(WebServiceFromWSDL.class); 66 } 67 68 public void readSettings(Object settings) { 69 wizardDescriptor = (WizardDescriptor) settings; 70 component.read (wizardDescriptor); 71 72 Object substitute = ((JComponent ) component).getClientProperty("NewProjectWizard_Title"); if (substitute != null) 76 wizardDescriptor.putProperty("NewProjectWizard_Title", substitute); } 78 79 public void storeSettings(Object settings) { 80 WizardDescriptor d = (WizardDescriptor) settings; 81 component.store(d); 82 ((WizardDescriptor) d).putProperty("NewProjectWizard_Title", null); } 84 85 public boolean isValid() { 86 getComponent(); 87 return component.isValid(wizardDescriptor); 88 } 89 90 private final Set <ChangeListener > listeners = new HashSet <ChangeListener >(1); 91 92 public void addChangeListener(ChangeListener l) { 93 synchronized (listeners) { 94 listeners.add(l); 95 } 96 } 97 98 public void removeChangeListener(ChangeListener l) { 99 synchronized (listeners) { 100 listeners.remove(l); 101 } 102 } 103 104 public boolean isFinishPanel() { 105 return isValid(); 106 } 107 108 public void validate() throws WizardValidationException { 109 component.validate(wizardDescriptor); 110 } 111 112 public void stateChanged(ChangeEvent e) { 113 fireChange(); 114 } 115 116 private void fireChange() { 117 ChangeEvent e = new ChangeEvent (this); 118 Iterator <ChangeListener > it = listeners.iterator(); 119 while (it.hasNext()) { 120 it.next().stateChanged(e); 121 } 122 } 123 124 } 125 | Popular Tags |