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 MessageHandlerWizard 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 MessageHandlerWizard create() { 47 return new MessageHandlerWizard(); 48 } 49 50 private static final String [] HANDLER_STEPS = 51 new String [] { 52 NbBundle.getMessage(MessageHandlerWizard.class, "LBL_SpecifyHandlerInfo") }; 54 55 public void initialize(WizardDescriptor wizard) { 56 57 wiz = wizard; 58 project = Templates.getProject(wiz); 59 SourceGroup[] sourceGroups = Util.getJavaSourceGroups(project); 60 61 firstPanel = JavaTemplates.createPackageChooser(project,sourceGroups, new BottomPanel()); 63 JComponent c = (JComponent )firstPanel.getComponent(); 64 Util.changeLabelInComponent(c, NbBundle.getMessage(Util.class, "LBL_JavaTargetChooserPanelGUI_ClassName_Label"), NbBundle.getMessage(WebServiceWizard.class, "LBL_Handler_Name") ); c.putClientProperty("WizardPanel_contentData", HANDLER_STEPS); 68 c.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (0)); 70 c.getAccessibleContext().setAccessibleDescription 71 (HANDLER_STEPS[0]); 72 wizardPanels = new WizardDescriptor.Panel[] {firstPanel}; 73 } 74 75 public void uninitialize(WizardDescriptor wizard) { 76 } 77 78 public Set instantiate() throws IOException { 79 new WebServiceCreator(project, wiz).createMessageHandler(); 80 81 return Collections.EMPTY_SET; 82 } 83 84 85 public WizardDescriptor.Panel current() { 86 return wizardPanels[currentPanel]; 87 } 88 89 public boolean hasNext() { 90 return currentPanel < wizardPanels.length -1; 91 } 92 93 public boolean hasPrevious() { 94 return currentPanel > 0; 95 } 96 97 public String name() { 98 return NbBundle.getMessage(WebServiceWizard.class, "LBL_Create_MessageHandler_Title"); } 100 101 public void nextPanel() { 102 if(!hasNext()){ 103 throw new NoSuchElementException (); 104 } 105 currentPanel++; 106 } 107 108 public void previousPanel() { 109 if(!hasPrevious()){ 110 throw new NoSuchElementException (); 111 } 112 currentPanel--; 113 } 114 115 public void addChangeListener(javax.swing.event.ChangeListener l) { 116 } 117 118 public void removeChangeListener(ChangeListener l) { 119 } 120 121 122 protected int getCurrentPanelIndex() { 123 return currentPanel; 124 } 125 126 128 private class BottomPanel implements WizardDescriptor.Panel { 129 130 public void storeSettings(Object settings) { 131 } 132 133 public void readSettings(Object settings) { 134 } 135 136 public java.awt.Component getComponent() { 137 return new javax.swing.JPanel (); 138 } 139 140 public void addChangeListener(ChangeListener l) { 141 } 142 143 public void removeChangeListener(ChangeListener l) { 144 } 145 146 public boolean isValid() { 147 149 WebServiceCreator creator = new WebServiceCreator(project); 151 int projectType = creator.getProjectType(); 152 if(!Util.isJavaEE5orHigher(project) && projectType == WebServiceCreator.WEB_PROJECT_TYPE 153 && !PlatformUtil.isJsr109Supported(project) 154 && !PlatformUtil.isJsr109OldSupported(project) ){ 155 if (Util.isSourceLevel14orLower(project)) { 157 wiz.putProperty("WizardPanel_errorMessage", 158 NbBundle.getMessage(LogicalHandlerWizard.class, "ERR_HandlerNeedProperSourceLevel")); return false; 160 } 161 if (!PlatformUtil.hasJAXWSLibrary(project)) { wiz.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(BottomPanel.class, "LBL_LogicalHandlerWarning")); return false; 164 } else 165 return true; 166 } 167 return true; 168 } 169 170 public HelpCtx getHelp() { 171 return new HelpCtx(MessageHandlerWizard.class); 172 } 173 174 } 175 176 } 177 | Popular Tags |