1 19 20 package org.netbeans.modules.websvc.core.client.wizard; 21 22 import java.util.HashSet ; 23 import java.util.Iterator ; 24 import java.util.Set ; 25 26 import java.awt.Component ; 27 import javax.swing.event.ChangeEvent ; 28 import javax.swing.event.ChangeListener ; 29 30 import org.openide.WizardDescriptor; 31 import org.openide.util.HelpCtx; 32 import org.openide.util.NbBundle; 33 34 import org.netbeans.api.project.Project; 35 import org.netbeans.spi.project.ui.templates.support.Templates; 36 37 38 42 public class WebServiceClientWizardDescriptor implements WizardDescriptor.FinishablePanel, WizardDescriptor.ValidatingPanel { 43 44 private WizardDescriptor wizardDescriptor; 45 private ClientInfo component = null; 46 private String projectPath; 47 private Project project; 48 49 public WebServiceClientWizardDescriptor() { 50 } 51 52 public boolean isFinishPanel(){ 53 return true; 54 } 55 56 private final Set <ChangeListener > listeners = new HashSet <ChangeListener >(1); 57 public final void addChangeListener(ChangeListener l) { 58 synchronized (listeners) { 59 listeners.add(l); 60 } 61 } 62 63 public final void removeChangeListener(ChangeListener l) { 64 synchronized (listeners) { 65 listeners.remove(l); 66 } 67 } 68 69 protected final void fireChangeEvent() { 70 Iterator <ChangeListener > it; 71 synchronized (listeners) { 72 it = new HashSet <ChangeListener >(listeners).iterator(); 73 } 74 ChangeEvent ev = new ChangeEvent (this); 75 while (it.hasNext()) { 76 it.next().stateChanged(ev); 77 } 78 } 79 80 public Component getComponent() { 81 if(component == null) { 82 component = new ClientInfo(this); 83 } 84 85 return component; 86 } 87 88 public HelpCtx getHelp() { 89 return new HelpCtx(WebServiceClientWizardDescriptor.class); 90 } 91 92 public boolean isValid() { 93 boolean projectDirValid=true; 94 String illegalChar = null; 95 96 if (projectPath.indexOf("%")>=0) { 97 projectDirValid=false; 98 illegalChar="%"; 99 } else if (projectPath.indexOf("&")>=0) { 100 projectDirValid=false; 101 illegalChar="&"; 102 } else if (projectPath.indexOf("?")>=0) { 103 projectDirValid=false; 104 illegalChar="?"; 105 } 106 if (!projectDirValid) { 107 wizardDescriptor.putProperty("WizardPanel_errorMessage", 108 NbBundle.getMessage(WebServiceClientWizardDescriptor.class,"MSG_InvalidProjectPath",projectPath,illegalChar)); 109 return false; 110 } 111 112 return component.valid(wizardDescriptor); 113 } 114 115 public void readSettings(Object settings) { 116 wizardDescriptor = (WizardDescriptor) settings; 117 component.read(wizardDescriptor); 118 project = Templates.getProject(wizardDescriptor); 119 projectPath = project.getProjectDirectory().getPath(); 120 121 wizardDescriptor.putProperty("NewFileWizard_Title", 124 NbBundle.getMessage(WebServiceClientWizardDescriptor.class, "LBL_WebServiceClient")); } 126 127 public void storeSettings(Object settings) { 128 WizardDescriptor d = (WizardDescriptor) settings; 129 component.store(d); 130 ((WizardDescriptor) d).putProperty("NewFileWizard_Title", null); } 132 133 public void validate() throws org.openide.WizardValidationException { 134 component.validatePanel(); 135 } 136 137 } 138 | Popular Tags |