1 19 20 package org.netbeans.modules.websvc.dev.wizard; 21 22 import java.io.IOException ; 23 import java.util.Collections ; 24 import java.util.NoSuchElementException ; 25 import java.util.Set ; 26 import javax.swing.JComponent ; 27 import org.netbeans.api.project.Project; 28 import org.netbeans.api.project.SourceGroup; 29 import org.netbeans.spi.java.project.support.ui.templates.JavaTemplates; 30 import org.netbeans.spi.project.ui.templates.support.Templates; 31 import org.openide.WizardDescriptor; 32 import javax.swing.event.ChangeListener ; 33 import org.openide.util.HelpCtx; 34 import org.openide.util.NbBundle; 35 import org.netbeans.modules.j2ee.common.Util; 36 37 public class LogicalHandlerWizard implements WizardDescriptor.InstantiatingIterator { 38 public int currentPanel = 0; 39 private WizardDescriptor.Panel [] wizardPanels; 40 private WizardDescriptor.Panel firstPanel; private WizardDescriptor wiz; 42 private Project project; 43 private String handlerName; 44 public static final String JAVAC_CLASSPATH = "javac.classpath"; 46 public static LogicalHandlerWizard create() { 47 return new LogicalHandlerWizard(); 48 } 49 50 private static final String [] HANDLER_STEPS = 51 new String [] { 52 NbBundle.getMessage(LogicalHandlerWizard.class, "LBL_SpecifyLogicalHandlerInfo") }; 54 55 public void initialize(WizardDescriptor wizard) { 56 57 wiz = wizard; 58 project = Templates.getProject(wiz); 59 SourceGroup[] sourceGroups = Util.getJavaSourceGroups(project); 60 61 64 if (sourceGroups.length == 0) 65 firstPanel = new FinishableProxyWizardPanel(Templates.createSimpleTargetChooser(project, sourceGroups, new BottomPanel())); 66 else 67 firstPanel = new FinishableProxyWizardPanel(JavaTemplates.createPackageChooser(project, sourceGroups, new BottomPanel(), true)); 68 69 JComponent c = (JComponent ) firstPanel.getComponent(); 70 Util.changeLabelInComponent(c, NbBundle.getMessage(Util.class, "LBL_JavaTargetChooserPanelGUI_ClassName_Label"), NbBundle.getMessage(WebServiceWizard.class, "LBL_LogicalHandler_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(WizardDescriptor wizard) { 82 } 83 84 public Set instantiate() throws IOException { 85 new WebServiceCreator(project, wiz).createLogicalHandler(); 86 87 return Collections.EMPTY_SET; 88 } 89 90 91 public WizardDescriptor.Panel current() { 92 return wizardPanels[currentPanel]; 93 } 94 95 public boolean hasNext() { 96 return currentPanel < wizardPanels.length -1; 97 } 98 99 public boolean hasPrevious() { 100 return currentPanel > 0; 101 } 102 103 public String name() { 104 return NbBundle.getMessage(WebServiceWizard.class, "LBL_Create_LogicalHandler_Title"); } 106 107 public void nextPanel() { 108 if(!hasNext()){ 109 throw new NoSuchElementException (); 110 } 111 currentPanel++; 112 } 113 114 public void previousPanel() { 115 if(!hasPrevious()){ 116 throw new NoSuchElementException (); 117 } 118 currentPanel--; 119 } 120 121 public void addChangeListener(javax.swing.event.ChangeListener l) { 122 } 123 124 public void removeChangeListener(ChangeListener l) { 125 } 126 127 128 protected int getCurrentPanelIndex() { 129 return currentPanel; 130 } 131 132 134 private class BottomPanel implements WizardDescriptor.Panel { 135 136 public void storeSettings(Object settings) { 137 } 138 139 public void readSettings(Object settings) { 140 } 141 142 public java.awt.Component getComponent() { 143 return new javax.swing.JPanel (); 144 } 145 146 public void addChangeListener(ChangeListener l) { 147 } 148 149 public void removeChangeListener(ChangeListener l) { 150 } 151 152 public boolean isValid() { 153 WebServiceCreator creator = new WebServiceCreator(project); 154 int projectType = creator.getProjectType(); 155 156 if (projectType == WebServiceCreator.JSE_PROJECT_TYPE && Util.isSourceLevel16orHigher(project)) 157 return true; 158 159 if (projectType == WebServiceCreator.JSE_PROJECT_TYPE && Util.getSourceLevel(project).equals("1.5")) { if (!PlatformUtil.hasJAXWSLibrary(project)) { 162 wiz.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(BottomPanel.class, "LBL_LogicalHandlerWarning")); return false; 164 } else 165 return true; 166 } 167 168 if (Util.isJavaEE5orHigher(project) && (projectType == WebServiceCreator.WEB_PROJECT_TYPE || projectType == WebServiceCreator.EJB_PROJECT_TYPE)) { return true; 170 } 171 172 if(!Util.isJavaEE5orHigher(project) && projectType == WebServiceCreator.WEB_PROJECT_TYPE 174 && !PlatformUtil.isJsr109Supported(project) 175 && !PlatformUtil.isJsr109OldSupported(project) ){ 176 if (Util.isSourceLevel14orLower(project)) { 178 wiz.putProperty("WizardPanel_errorMessage", 179 NbBundle.getMessage(LogicalHandlerWizard.class, "ERR_HandlerNeedProperSourceLevel")); return false; 181 } 182 if (!PlatformUtil.hasJAXWSLibrary(project)) { wiz.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(BottomPanel.class, "LBL_LogicalHandlerWarning")); return false; 185 } else 186 return true; 187 } 188 189 wiz.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(BottomPanel.class, "LBL_LogicalHandlerWarning")); 191 return false; 192 } 193 194 public HelpCtx getHelp() { 195 return new HelpCtx(LogicalHandlerWizard.class); 196 } 197 } 198 } 199 | Popular Tags |