1 19 20 package org.netbeans.modules.websvc.core.client.wizard; 21 22 import java.io.*; 23 import java.util.*; 24 import java.awt.Component ; 25 import javax.swing.JComponent ; 26 import javax.swing.event.ChangeListener ; 27 import org.netbeans.modules.websvc.core.ClientCreator; 28 import org.netbeans.modules.websvc.core.CreatorProvider; 29 import org.netbeans.modules.websvc.core.JaxWsUtils; 30 import org.openide.WizardDescriptor; 31 import org.openide.util.NbBundle; 32 33 import org.netbeans.api.project.Project; 34 import org.netbeans.spi.project.ui.templates.support.Templates; 35 import org.openide.filesystems.FileObject; 36 import org.openide.loaders.DataObject; 37 import org.openide.loaders.TemplateWizard; 38 39 41 public class WebServiceClientWizardIterator implements TemplateWizard.Iterator { 42 43 private int index = 0; 44 private WizardDescriptor.Panel [] panels; 45 46 private TemplateWizard wiz; 47 private Project project; 49 50 52 public static WebServiceClientWizardIterator create() { 53 return new WebServiceClientWizardIterator(); 54 } 55 56 private WizardDescriptor.Panel[] createPanels() { 57 return new WizardDescriptor.Panel[] { 58 new WebServiceClientWizardDescriptor() 59 }; 60 } 61 62 public void initialize(TemplateWizard wizard) { 63 wiz = wizard; 64 project = Templates.getProject(wiz); 65 66 index = 0; 67 panels = createPanels(); 68 69 Object prop = wiz.getProperty("WizardPanel_contentData"); String [] beforeSteps = null; 71 if (prop != null && prop instanceof String []) { 72 beforeSteps = (String [])prop; 73 } 74 String [] steps = JaxWsUtils.createSteps (beforeSteps, panels); 75 76 for (int i = 0; i < panels.length; i++) { 77 Component c = panels[i].getComponent(); 78 if (steps[i] == null) { 79 steps[i] = c.getName(); 83 } 84 85 assert c instanceof JComponent ; 86 JComponent jc = (JComponent )c; 87 jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (i)); jc.putClientProperty("WizardPanel_contentData", steps); } 92 } 93 94 public void uninitialize(TemplateWizard wizard) { 95 wiz = null; 96 panels = null; 97 } 98 99 public Set instantiate(TemplateWizard wiz) throws IOException { 100 FileObject template = Templates.getTemplate( wiz ); 101 DataObject dTemplate = DataObject.find( template ); 102 ClientCreator creator = CreatorProvider.getClientCreator(project, wiz); 105 if (creator!=null) creator.createClient(); 106 107 return Collections.singleton(dTemplate); 108 } 109 110 public String name() { 111 return NbBundle.getMessage(WebServiceClientWizardIterator.class, "LBL_WebServiceClient"); } 113 114 public WizardDescriptor.Panel current() { 115 return panels[index]; 116 } 117 118 public boolean hasNext() { 119 return index < panels.length - 1; 120 } 121 122 public void nextPanel() { 123 if(!hasNext()) { 124 throw new NoSuchElementException(); 125 } 126 127 index++; 128 } 129 130 public boolean hasPrevious() { 131 return index > 0; 132 } 133 134 public void previousPanel() { 135 if(!hasNext()) { 136 throw new NoSuchElementException(); 137 } 138 139 index--; 140 } 141 142 public void addChangeListener(ChangeListener l) { 143 } 145 146 public void removeChangeListener(ChangeListener l) { 147 } 149 } 150 | Popular Tags |