1 19 20 package org.netbeans.modules.java.j2seproject.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.api.project.Project; 27 import org.netbeans.api.project.ProjectUtils; 28 import org.netbeans.modules.java.j2seproject.wsclient.CustomizerWSClientHost; 29 import org.netbeans.modules.java.j2seproject.wsclient.NoWebServiceClientsPanel; 30 import org.netbeans.modules.websvc.api.client.WebServicesClientSupport; 31 import org.netbeans.spi.project.ui.support.ProjectCustomizer; 32 import org.openide.util.Lookup; 33 import org.openide.util.NbBundle; 34 35 39 public class J2SECompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider { 40 41 private static final String SOURCES = "Sources"; 42 static final String LIBRARIES = "Libraries"; 43 44 private static final String BUILD = "Build"; 45 private static final String JAR = "Jar"; 47 private static final String JAVADOC = "Javadoc"; 48 public static final String RUN = "Run"; 49 private static final String APPLICATION = "Application"; 51 52 private static final String WEBSERVICECLIENTS = "WebServiceClients"; 53 private static final String WEBSERVICE_CATEGORY = "WebServiceCategory"; 54 55 private String name; 56 57 58 public J2SECompositePanelProvider(String name) { 59 this.name = name; 60 } 61 62 public ProjectCustomizer.Category createCategory(Lookup context) { 63 ResourceBundle bundle = NbBundle.getBundle( CustomizerProviderImpl.class ); 64 ProjectCustomizer.Category toReturn = null; 65 if (SOURCES.equals(name)) { 66 toReturn = ProjectCustomizer.Category.create( 67 SOURCES, 68 bundle.getString("LBL_Config_Sources"), 69 null, 70 null); 71 } else if (LIBRARIES.equals(name)) { 72 toReturn = ProjectCustomizer.Category.create( 73 LIBRARIES, 74 bundle.getString( "LBL_Config_Libraries" ), null, 76 null ); 77 } else if (BUILD.equals(name)) { 78 toReturn = ProjectCustomizer.Category.create( 79 BUILD, 80 bundle.getString( "LBL_Config_Build" ), null, 82 null); 83 } else if (JAR.equals(name)) { 84 toReturn = ProjectCustomizer.Category.create( 85 JAR, 86 bundle.getString( "LBL_Config_Jar" ), null, 88 null ); 89 } else if (JAVADOC.equals(name)) { 90 toReturn = ProjectCustomizer.Category.create( 91 JAVADOC, 92 bundle.getString( "LBL_Config_Javadoc" ), null, 94 null ); 95 } else if (RUN.equals(name)) { 96 toReturn = ProjectCustomizer.Category.create( 97 RUN, 98 bundle.getString( "LBL_Config_Run" ), null, 100 null ); 101 } else if (WEBSERVICECLIENTS.equals(name)) { 102 toReturn = ProjectCustomizer.Category.create( 103 WEBSERVICECLIENTS, 104 bundle.getString( "LBL_Config_WebServiceClients" ), null, 106 null); 107 } else if (APPLICATION.equals(name)) { 108 toReturn = ProjectCustomizer.Category.create( 109 APPLICATION, 110 bundle.getString( "LBL_Config_Application" ), null, 112 null); 113 } 114 assert toReturn != null : "No category for name:" + name; 115 return toReturn; 116 } 117 118 public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) { 119 String nm = category.getName(); 120 J2SEProjectProperties uiProps = (J2SEProjectProperties)context.lookup(J2SEProjectProperties.class); 121 if (SOURCES.equals(nm)) { 122 return new CustomizerSources(uiProps); 123 } else if (LIBRARIES.equals(nm)) { 124 CustomizerProviderImpl.SubCategoryProvider prov = (CustomizerProviderImpl.SubCategoryProvider)context.lookup(CustomizerProviderImpl.SubCategoryProvider.class); 125 assert prov != null : "Assuming CustomizerProviderImpl.SubCategoryProvider in customizer context"; 126 return new CustomizerLibraries(uiProps, prov); 127 } else if (BUILD.equals(nm)) { 128 return new CustomizerCompile(uiProps); 129 } else if (JAR.equals(nm)) { 130 return new CustomizerJar(uiProps); 131 } else if (JAVADOC.equals(nm)) { 132 return new CustomizerJavadoc(uiProps); 133 } else if (RUN.equals(nm)) { 134 return new CustomizerRun(uiProps); 135 } else if (WEBSERVICECLIENTS.equals(nm)) { 136 List serviceClientsSettings = null; 137 Project project = (Project)context.lookup(Project.class); 138 WebServicesClientSupport clientSupport = WebServicesClientSupport.getWebServicesClientSupport(project.getProjectDirectory()); 139 if (clientSupport != null) { 140 serviceClientsSettings = clientSupport.getServiceClients(); 141 } 142 143 if(serviceClientsSettings != null && serviceClientsSettings.size() > 0) { 144 return new CustomizerWSClientHost( uiProps, serviceClientsSettings ); 145 } else { 146 return new NoWebServiceClientsPanel(); 147 } 148 } else if (APPLICATION.equals(nm)) { 149 return new CustomizerApplication(uiProps); 150 } 151 return new JPanel (); 152 153 } 154 155 public static J2SECompositePanelProvider createSources() { 156 return new J2SECompositePanelProvider(SOURCES); 157 } 158 159 public static J2SECompositePanelProvider createLibraries() { 160 return new J2SECompositePanelProvider(LIBRARIES); 161 } 162 163 public static J2SECompositePanelProvider createBuild() { 164 return new J2SECompositePanelProvider(BUILD); 165 } 166 167 public static J2SECompositePanelProvider createJar() { 168 return new J2SECompositePanelProvider(JAR); 169 } 170 171 public static J2SECompositePanelProvider createJavadoc() { 172 return new J2SECompositePanelProvider(JAVADOC); 173 } 174 175 public static J2SECompositePanelProvider createRun() { 176 return new J2SECompositePanelProvider(RUN); 177 } 178 179 public static J2SECompositePanelProvider createWebServiceClients() { 180 return new J2SECompositePanelProvider(WEBSERVICECLIENTS); 181 } 182 183 public static J2SECompositePanelProvider createApplication() { 184 return new J2SECompositePanelProvider(APPLICATION); 185 } 186 } 187 | Popular Tags |