1 19 20 package org.netbeans.modules.j2ee.ejbjarproject.ui.customizer; 21 22 import java.util.List ; 23 import java.util.ResourceBundle ; 24 import javax.swing.JComponent ; 25 import javax.swing.JPanel ; 26 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject; 27 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProvider; 28 import org.netbeans.modules.websvc.api.webservices.WebServicesSupport; 29 import org.netbeans.spi.project.ui.support.ProjectCustomizer; 30 import org.openide.filesystems.FileObject; 31 import org.openide.util.Lookup; 32 import org.openide.util.NbBundle; 33 34 38 public class EjbJarCompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider { 39 40 private static final String SOURCES = "Sources"; 41 static final String LIBRARIES = "Libraries"; 42 43 private static final String BUILD = "Build"; 44 private static final String JAR = "Jar"; 45 private static final String JAVADOC = "Javadoc"; 46 public static final String RUN = "Run"; 47 48 private static final String WEBSERVICES = "WebServices"; 49 50 private String name; 51 52 53 public EjbJarCompositePanelProvider(String name) { 54 this.name = name; 55 } 56 57 public ProjectCustomizer.Category createCategory(Lookup context) { 58 ResourceBundle bundle = NbBundle.getBundle( EjbJarCompositePanelProvider.class ); 59 ProjectCustomizer.Category toReturn = null; 60 61 if (SOURCES.equals(name)) { 62 toReturn = ProjectCustomizer.Category.create( 63 SOURCES, 64 bundle.getString("LBL_Config_Sources"), null, 66 null); 67 } else if (LIBRARIES.equals(name)) { 68 toReturn = ProjectCustomizer.Category.create( 69 LIBRARIES, 70 bundle.getString( "LBL_Config_Libraries" ), null, 72 null ); 73 } else if (BUILD.equals(name)) { 74 toReturn = ProjectCustomizer.Category.create( 75 BUILD, 76 bundle.getString( "LBL_Config_Build" ), null, 78 null); 79 } else if (JAR.equals(name)) { 80 toReturn = ProjectCustomizer.Category.create( 81 JAR, 82 bundle.getString( "LBL_Config_Jar" ), null, 84 null ); 85 } else if (JAVADOC.equals(name)) { 86 toReturn = ProjectCustomizer.Category.create( 87 JAVADOC, 88 bundle.getString( "LBL_Config_Javadoc" ), null, 90 null ); 91 } else if (RUN.equals(name)) { 92 toReturn = ProjectCustomizer.Category.create( 93 RUN, 94 bundle.getString( "LBL_Config_Run" ), null, 96 null ); 97 } else if (WEBSERVICES.equals(name)) { 98 EjbJarProject project = (EjbJarProject) context.lookup(EjbJarProject.class); 99 EjbJarProvider ejbJarProvider = (EjbJarProvider) project.getLookup().lookup(EjbJarProvider.class); 100 FileObject metaInf = ejbJarProvider.getMetaInf(); 101 List servicesSettings = null; 102 if (metaInf != null) { 103 WebServicesSupport servicesSupport = WebServicesSupport.getWebServicesSupport(metaInf); 104 if (servicesSupport != null) { 105 servicesSettings = servicesSupport.getServices(); 106 } 107 } 108 if ((servicesSettings!=null && servicesSettings.size()>0)) { 109 toReturn = ProjectCustomizer.Category.create( 110 WEBSERVICES, 111 bundle.getString( "LBL_Config_WebServices" ), null, 113 null ); 114 } 115 } 116 117 return toReturn; 119 } 120 121 public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) { 122 String nm = category.getName(); 123 EjbJarProjectProperties uiProps = (EjbJarProjectProperties) context.lookup(EjbJarProjectProperties.class); 124 if (SOURCES.equals(nm)) { 125 return new CustomizerSources(uiProps); 126 } else if (LIBRARIES.equals(nm)) { 127 CustomizerProviderImpl.SubCategoryProvider prov = (CustomizerProviderImpl.SubCategoryProvider)context.lookup(CustomizerProviderImpl.SubCategoryProvider.class); 128 assert prov != null : "Assuming CustomizerProviderImpl.SubCategoryProvider in customizer context"; 129 return new CustomizerLibraries(uiProps, prov); 130 } else if (BUILD.equals(nm)) { 131 return new CustomizerCompile(uiProps); 132 } else if (JAR.equals(nm)) { 133 return new CustomizerJar(uiProps); 134 } else if (JAVADOC.equals(nm)) { 135 return new CustomizerJavadoc(uiProps); 136 } else if (RUN.equals(nm)) { 137 return new CustomizerRun(uiProps); 138 } else if (WEBSERVICES.equals(nm)) { 139 EjbJarProvider ejbJarProvider = (EjbJarProvider) uiProps.getProject().getLookup().lookup(EjbJarProvider.class); 140 FileObject metaInf = ejbJarProvider.getMetaInf(); 141 List servicesSettings = null; 142 if (metaInf != null) { 143 WebServicesSupport servicesSupport = WebServicesSupport.getWebServicesSupport(metaInf); 144 if (servicesSupport != null) { 145 servicesSettings = servicesSupport.getServices(); 146 } 147 } 148 if(servicesSettings != null && servicesSettings.size() > 0) { 149 return new CustomizerWSServiceHost( uiProps, servicesSettings ); 150 } else { 151 return new NoWebServicesPanel(); 152 } 153 } 154 155 return new JPanel (); 156 } 157 158 public static EjbJarCompositePanelProvider createSources() { 159 return new EjbJarCompositePanelProvider(SOURCES); 160 } 161 162 public static EjbJarCompositePanelProvider createLibraries() { 163 return new EjbJarCompositePanelProvider(LIBRARIES); 164 } 165 166 public static EjbJarCompositePanelProvider createBuild() { 167 return new EjbJarCompositePanelProvider(BUILD); 168 } 169 170 public static EjbJarCompositePanelProvider createJar() { 171 return new EjbJarCompositePanelProvider(JAR); 172 } 173 174 public static EjbJarCompositePanelProvider createJavadoc() { 175 return new EjbJarCompositePanelProvider(JAVADOC); 176 } 177 178 public static EjbJarCompositePanelProvider createRun() { 179 return new EjbJarCompositePanelProvider(RUN); 180 } 181 182 public static EjbJarCompositePanelProvider createWebServices() { 183 return new EjbJarCompositePanelProvider(WEBSERVICES); 184 } 185 186 } 187 | Popular Tags |