1 19 20 package org.netbeans.modules.websvc.wsitconf.wizard; 21 22 import org.netbeans.api.project.Project; 23 import org.netbeans.api.project.SourceGroup; 24 import org.netbeans.spi.java.project.support.ui.templates.JavaTemplates; 25 import org.netbeans.spi.project.ui.templates.support.Templates; 26 import org.openide.WizardDescriptor; 27 import org.openide.filesystems.FileObject; 28 import org.openide.loaders.DataFolder; 29 import org.openide.loaders.DataObject; 30 import org.openide.loaders.TemplateWizard; 31 import org.openide.util.HelpCtx; 32 import org.openide.util.NbBundle; 33 34 import javax.swing.*; 35 import javax.swing.event.ChangeListener ; 36 import java.io.IOException ; 37 import java.util.Collections ; 38 import java.util.NoSuchElementException ; 39 import java.util.Set ; 40 import org.netbeans.modules.websvc.wsitconf.util.Util; 41 42 public class UsernameCallbackHandlerWizard implements TemplateWizard.Iterator { 43 public int currentPanel = 0; 44 private WizardDescriptor.Panel [] wizardPanels; 45 private WizardDescriptor.Panel firstPanel; private TemplateWizard wiz; 47 private Project project; 48 private String handlerName; 49 public static final String JAVAC_CLASSPATH = "javac.classpath"; 51 public static UsernameCallbackHandlerWizard create() { 52 return new UsernameCallbackHandlerWizard(); 53 } 54 55 private static final String [] HANDLER_STEPS = 56 new String [] { 57 NbBundle.getMessage(UsernameCallbackHandlerWizard.class, 58 "LBL_SpecifyHandlerInfo") }; 60 61 public void initialize(TemplateWizard wizard) { 62 63 wiz = wizard; 64 project = Templates.getProject(wiz); 65 SourceGroup[] sourceGroups = Util.getJavaSourceGroups(project); 66 67 firstPanel = JavaTemplates.createPackageChooser(project,sourceGroups, new BottomPanel()); 69 JComponent c = (JComponent)firstPanel.getComponent(); 70 Util.changeLabelInComponent(c, NbBundle.getMessage(Util.class, "LBL_JavaTargetChooserPanelGUI_ClassName_Label"), NbBundle.getMessage(UsernameCallbackHandlerWizard.class, "LBL_Handler_Name") ); c.putClientProperty("WizardPanel_contentData", HANDLER_STEPS); 74 c.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (0)); 76 c.getAccessibleContext().setAccessibleDescription 77 (HANDLER_STEPS[0]); 78 wizardPanels = new WizardDescriptor.Panel[] {firstPanel}; 79 } 80 81 public void uninitialize(TemplateWizard wizard) 82 {} 83 84 public Set instantiate(TemplateWizard wiz) throws IOException { 85 FileObject pkg = Templates.getTargetFolder(wiz); 86 handlerName = Templates.getTargetName(wiz); 87 88 DataFolder df = DataFolder.findFolder(pkg); 89 FileObject template = Templates.getTemplate(wiz); 90 91 DataObject dTemplate = DataObject.find(template); 92 DataObject dobj = dTemplate.createFromTemplate(df, handlerName); 93 94 return Collections.singleton(dobj); 95 } 96 97 public WizardDescriptor.Panel current() { 98 return wizardPanels[currentPanel]; 99 } 100 101 public boolean hasNext() { 102 return currentPanel < wizardPanels.length -1; 103 } 104 105 public boolean hasPrevious() { 106 return currentPanel > 0; 107 } 108 109 public String name() { 110 return NbBundle.getMessage(UsernameCallbackHandlerWizard.class, "LBL_Create_MessageHandler_Title"); } 112 113 public void nextPanel() { 114 if(!hasNext()){ 115 throw new NoSuchElementException (); 116 } 117 currentPanel++; 118 } 119 120 public void previousPanel() { 121 if(!hasPrevious()){ 122 throw new NoSuchElementException (); 123 } 124 currentPanel--; 125 } 126 127 public void addChangeListener(javax.swing.event.ChangeListener l) { 128 } 129 130 public void removeChangeListener(ChangeListener l) { 131 } 132 133 134 protected int getCurrentPanelIndex() { 135 return currentPanel; 136 } 137 138 140 private class BottomPanel implements WizardDescriptor.Panel { 141 142 public void storeSettings(Object settings) { 143 } 144 145 public void readSettings(Object settings) { 146 147 } 148 149 public java.awt.Component getComponent() { 150 return new javax.swing.JPanel (); 151 } 152 153 public void addChangeListener(ChangeListener l) { 154 } 155 156 public void removeChangeListener(ChangeListener l) { 157 } 158 159 public boolean isValid() { 160 return true; 161 } 162 163 public HelpCtx getHelp() { 164 return new HelpCtx(UsernameCallbackHandlerWizard.class); 165 } 166 167 } 168 169 } 170 | Popular Tags |