/* * J2SECompositePanelProvider.java * * Created on April 10, 2006, 1:44 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package org.netbeans.modules.java.j2seproject.ui.customizer; import java.util.List; import java.util.ResourceBundle; import javax.swing.JComponent; import javax.swing.JPanel; import org.netbeans.api.project.Project; import org.netbeans.modules.java.j2seproject.wsclient.CustomizerWSClientHost; import org.netbeans.modules.java.j2seproject.wsclient.NoWebServiceClientsPanel; import org.netbeans.modules.websvc.api.client.WebServicesClientSupport; import org.netbeans.spi.project.ui.support.ProjectCustomizer; import org.openide.util.Lookup; import org.openide.util.NbBundle; /** * * @author mkleint */ public class J2SECompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider { // Names of categories private static final String BUILD_CATEGORY = "BuildCategory"; private static final String RUN_CATEGORY = "RunCategory"; private static final String SOURCES = "Sources"; static final String LIBRARIES = "Libraries"; private static final String BUILD = "Build"; // private static final String BUILD_TESTS = "BuildTests"; private static final String JAR = "Jar"; private static final String JAVADOC = "Javadoc"; private static final String RUN = "Run"; // private static final String RUN_TESTS = "RunTests"; private static final String WEBSERVICECLIENTS = "WebServiceClients"; private static final String WEBSERVICE_CATEGORY = "WebServiceCategory"; private String name; /** Creates a new instance of J2SECompositePanelProvider */ public J2SECompositePanelProvider(String name) { this.name = name; } public ProjectCustomizer.Category createCategory(Lookup context) { ResourceBundle bundle = NbBundle.getBundle( CustomizerProviderImpl.class ); ProjectCustomizer.Category toReturn = null; if (SOURCES.equals(name)) { toReturn = ProjectCustomizer.Category.create( SOURCES, bundle.getString("LBL_Config_Sources"), null, null); } else if (LIBRARIES.equals(name)) { toReturn = ProjectCustomizer.Category.create( LIBRARIES, bundle.getString( "LBL_Config_Libraries" ), // NOI18N null, null ); } else if (BUILD.equals(name)) { toReturn = ProjectCustomizer.Category.create( BUILD, bundle.getString( "LBL_Config_Build" ), // NOI18N null, null); } else if (JAR.equals(name)) { toReturn = ProjectCustomizer.Category.create( JAR, bundle.getString( "LBL_Config_Jar" ), // NOI18N null, null ); } else if (JAVADOC.equals(name)) { toReturn = ProjectCustomizer.Category.create( JAVADOC, bundle.getString( "LBL_Config_Javadoc" ), // NOI18N null, null ); } else if (RUN.equals(name)) { toReturn = ProjectCustomizer.Category.create( RUN, bundle.getString( "LBL_Config_Run" ), // NOI18N null, null ); } else if (WEBSERVICECLIENTS.equals(name)) { toReturn = ProjectCustomizer.Category.create( WEBSERVICECLIENTS, bundle.getString( "LBL_Config_WebServiceClients" ), // NOI18N null, null); } assert toReturn != null : "No category for name:" + name; return toReturn; } public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) { String nm = category.getName(); J2SEProjectProperties uiProps = (J2SEProjectProperties)context.lookup(J2SEProjectProperties.class); if (SOURCES.equals(nm)) { return new CustomizerSources(uiProps); } else if (LIBRARIES.equals(nm)) { CustomizerProviderImpl.SubCategoryProvider prov = (CustomizerProviderImpl.SubCategoryProvider)context.lookup(CustomizerProviderImpl.SubCategoryProvider.class); assert prov != null : "Assuming CustomizerProviderImpl.SubCategoryProvider in customizer context"; return new CustomizerLibraries(uiProps, prov); } else if (BUILD.equals(nm)) { return new CustomizerCompile(uiProps); } else if (JAR.equals(nm)) { return new CustomizerJar(uiProps); } else if (JAVADOC.equals(nm)) { return new CustomizerJavadoc(uiProps); } else if (RUN.equals(nm)) { return new CustomizerRun(uiProps); } else if (WEBSERVICECLIENTS.equals(nm)) { List serviceClientsSettings = null; Project project = (Project)context.lookup(Project.class); WebServicesClientSupport clientSupport = WebServicesClientSupport.getWebServicesClientSupport(project.getProjectDirectory()); if (clientSupport != null) { serviceClientsSettings = clientSupport.getServiceClients(); } if(serviceClientsSettings != null && serviceClientsSettings.size() > 0) { return new CustomizerWSClientHost( uiProps, serviceClientsSettings ); } else { return new NoWebServiceClientsPanel(); } } return new JPanel(); } public static J2SECompositePanelProvider createSources() { return new J2SECompositePanelProvider(SOURCES); } public static J2SECompositePanelProvider createLibraries() { return new J2SECompositePanelProvider(LIBRARIES); } public static J2SECompositePanelProvider createBuild() { return new J2SECompositePanelProvider(BUILD); } public static J2SECompositePanelProvider createJar() { return new J2SECompositePanelProvider(JAR); } public static J2SECompositePanelProvider createJavadoc() { return new J2SECompositePanelProvider(JAVADOC); } public static J2SECompositePanelProvider createRun() { return new J2SECompositePanelProvider(RUN); } public static J2SECompositePanelProvider createWebServiceClients() { return new J2SECompositePanelProvider(WEBSERVICECLIENTS); } }