1 19 20 package org.netbeans.modules.websvc.core.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.modules.websvc.core.CreatorProvider; 30 import org.netbeans.modules.websvc.core.HandlerCreator; 31 import org.netbeans.spi.java.project.support.ui.templates.JavaTemplates; 32 import org.netbeans.spi.project.ui.templates.support.Templates; 33 import org.openide.WizardDescriptor; 34 import javax.swing.event.ChangeListener ; 35 import org.openide.util.HelpCtx; 36 import org.openide.util.NbBundle; 37 import org.netbeans.modules.j2ee.common.Util; 38 39 public class MessageHandlerWizard implements WizardDescriptor.InstantiatingIterator { 40 public int currentPanel = 0; 41 private WizardDescriptor.Panel [] wizardPanels; 42 private WizardDescriptor.Panel firstPanel; private WizardDescriptor wiz; 44 private Project project; 45 private String handlerName; 46 public static final String JAVAC_CLASSPATH = "javac.classpath"; 48 public static MessageHandlerWizard create() { 49 return new MessageHandlerWizard(); 50 } 51 52 private static final String [] HANDLER_STEPS = 53 new String [] { 54 NbBundle.getMessage(MessageHandlerWizard.class, "LBL_SpecifyHandlerInfo") }; 56 57 public void initialize(WizardDescriptor wizard) { 58 59 wiz = wizard; 60 project = Templates.getProject(wiz); 61 SourceGroup[] sourceGroups = Util.getJavaSourceGroups(project); 62 63 firstPanel = JavaTemplates.createPackageChooser(project,sourceGroups, new BottomPanel()); 65 JComponent c = (JComponent )firstPanel.getComponent(); 66 Util.changeLabelInComponent(c, NbBundle.getMessage(MessageHandlerWizard.class, "LBL_JavaTargetChooserPanelGUI_ClassName_Label"), NbBundle.getMessage(MessageHandlerWizard.class, "LBL_Handler_Name") ); c.putClientProperty("WizardPanel_contentData", HANDLER_STEPS); 70 c.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (0)); 72 c.getAccessibleContext().setAccessibleDescription 73 (HANDLER_STEPS[0]); 74 wizardPanels = new WizardDescriptor.Panel[] {firstPanel}; 75 } 76 77 public void uninitialize(WizardDescriptor wizard) { 78 } 79 80 public Set instantiate() throws IOException { 81 HandlerCreator creator = CreatorProvider.getHandlerCreator(project, wiz); 83 if (creator!=null) creator.createMessageHandler(); 84 85 return Collections.EMPTY_SET; 86 } 87 88 89 public WizardDescriptor.Panel current() { 90 return wizardPanels[currentPanel]; 91 } 92 93 public boolean hasNext() { 94 return currentPanel < wizardPanels.length -1; 95 } 96 97 public boolean hasPrevious() { 98 return currentPanel > 0; 99 } 100 101 public String name() { 102 return NbBundle.getMessage(MessageHandlerWizard.class, "LBL_Create_MessageHandler_Title"); } 104 105 public void nextPanel() { 106 if(!hasNext()){ 107 throw new NoSuchElementException (); 108 } 109 currentPanel++; 110 } 111 112 public void previousPanel() { 113 if(!hasPrevious()){ 114 throw new NoSuchElementException (); 115 } 116 currentPanel--; 117 } 118 119 public void addChangeListener(javax.swing.event.ChangeListener l) { 120 } 121 122 public void removeChangeListener(ChangeListener l) { 123 } 124 125 126 protected int getCurrentPanelIndex() { 127 return currentPanel; 128 } 129 130 132 private class BottomPanel implements WizardDescriptor.Panel { 133 134 public void storeSettings(Object settings) { 135 } 136 137 public void readSettings(Object settings) { 138 } 139 140 public java.awt.Component getComponent() { 141 return new javax.swing.JPanel (); 142 } 143 144 public void addChangeListener(ChangeListener l) { 145 } 146 147 public void removeChangeListener(ChangeListener l) { 148 } 149 150 public boolean isValid() { 151 153 ProjectInfo creator = new ProjectInfo(project); 155 int projectType = creator.getProjectType(); 156 if(!Util.isJavaEE5orHigher(project) && projectType == ProjectInfo.WEB_PROJECT_TYPE 157 && !PlatformUtil.isJsr109Supported(project) 158 && !PlatformUtil.isJsr109OldSupported(project) ){ 159 if (Util.isSourceLevel14orLower(project)) { 161 wiz.putProperty("WizardPanel_errorMessage", 162 NbBundle.getMessage(MessageHandlerWizard.class, "ERR_HandlerNeedProperSourceLevel")); return false; 164 } 165 if (!PlatformUtil.hasJAXWSLibrary(project)) { wiz.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(BottomPanel.class, "LBL_LogicalHandlerWarning")); return false; 168 } else 169 return true; 170 } 171 return true; 172 } 173 174 public HelpCtx getHelp() { 175 return new HelpCtx(MessageHandlerWizard.class); 176 } 177 178 } 179 180 } 181 | Popular Tags |