1 19 20 package org.netbeans.modules.web.project.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.modules.web.project.ProjectWebModule; 28 import org.netbeans.modules.web.project.WebProject; 29 import org.netbeans.modules.websvc.api.client.WebServicesClientSupport; 30 import org.netbeans.modules.websvc.api.webservices.WebServicesSupport; 31 import org.netbeans.spi.project.ui.support.ProjectCustomizer; 32 import org.openide.filesystems.FileObject; 33 import org.openide.util.Lookup; 34 import org.openide.util.NbBundle; 35 36 40 public class WebCompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider { 41 42 private static final String SOURCES = "Sources"; 43 static final String LIBRARIES = "Libraries"; 44 private static final String FRAMEWORKS = "Frameworks"; 45 46 private static final String BUILD = "Build"; 47 private static final String WAR = "War"; 48 private static final String JAVADOC = "Javadoc"; 49 public static final String RUN = "Run"; 50 51 private static final String WEBSERVICES = "WebServices"; 52 private static final String WEBSERVICECLIENTS = "WebServiceClients"; 53 54 private String name; 55 56 57 public WebCompositePanelProvider(String name) { 58 this.name = name; 59 } 60 61 public ProjectCustomizer.Category createCategory(Lookup context) { 62 ResourceBundle bundle = NbBundle.getBundle( CustomizerProviderImpl.class ); 63 ProjectCustomizer.Category toReturn = null; 64 65 if (SOURCES.equals(name)) { 66 toReturn = ProjectCustomizer.Category.create( 67 SOURCES, 68 bundle.getString("LBL_Config_Sources"), null, 70 null); 71 } else if (FRAMEWORKS.equals(name)) { 72 toReturn = ProjectCustomizer.Category.create( 73 FRAMEWORKS, 74 bundle.getString( "LBL_Config_Frameworks" ), null, 76 null ); 77 } else if (LIBRARIES.equals(name)) { 78 toReturn = ProjectCustomizer.Category.create( 79 LIBRARIES, 80 bundle.getString( "LBL_Config_Libraries" ), null, 82 null ); 83 } else if (BUILD.equals(name)) { 84 toReturn = ProjectCustomizer.Category.create( 85 BUILD, 86 bundle.getString( "LBL_Config_Build" ), null, 88 null); 89 } else if (WAR.equals(name)) { 90 toReturn = ProjectCustomizer.Category.create( 91 WAR, 92 bundle.getString( "LBL_Config_War" ), null, 94 null ); 95 } else if (JAVADOC.equals(name)) { 96 toReturn = ProjectCustomizer.Category.create( 97 JAVADOC, 98 bundle.getString( "LBL_Config_Javadoc" ), null, 100 null ); 101 } else if (RUN.equals(name)) { 102 toReturn = ProjectCustomizer.Category.create( 103 RUN, 104 bundle.getString( "LBL_Config_Run" ), null, 106 null ); 107 } else if (WEBSERVICES.equals(name) || WEBSERVICECLIENTS.equals(name)) { 108 WebProject project = (WebProject) context.lookup(WebProject.class); 109 ProjectWebModule wm = (ProjectWebModule) project.getLookup().lookup(ProjectWebModule.class); 110 FileObject docBase = wm.getDocumentBase(); 111 if (WEBSERVICES.equals(name)) { 112 List servicesSettings = null; 113 if (docBase != null) { 114 WebServicesSupport servicesSupport = WebServicesSupport.getWebServicesSupport(docBase); 115 if (servicesSupport != null) { 116 servicesSettings = servicesSupport.getServices(); 117 } 118 } 119 if ((servicesSettings!=null && servicesSettings.size()>0)) { 120 toReturn = ProjectCustomizer.Category.create( 121 WEBSERVICES, 122 bundle.getString( "LBL_Config_WebServices" ), null, 124 null ); 125 } 126 } else if (WEBSERVICECLIENTS.equals(name)) { 127 List serviceClientsSettings = null; 128 if (docBase != null) { 129 WebServicesClientSupport clientSupport = WebServicesClientSupport.getWebServicesClientSupport(docBase); 130 if (clientSupport != null) { 131 serviceClientsSettings = clientSupport.getServiceClients(); 132 } 133 } 134 if(serviceClientsSettings != null && serviceClientsSettings.size() > 0) { 135 toReturn = ProjectCustomizer.Category.create( 136 WEBSERVICECLIENTS, 137 bundle.getString( "LBL_Config_WebServiceClients" ), null, 139 null ); 140 } 141 } 142 } 143 144 return toReturn; 146 } 147 148 public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) { 149 String nm = category.getName(); 150 WebProjectProperties uiProps = (WebProjectProperties)context.lookup(WebProjectProperties.class); 151 if (SOURCES.equals(nm)) { 152 return new CustomizerSources(uiProps); 153 } else if (FRAMEWORKS.equals(nm)) { 154 return new CustomizerFrameworks(uiProps); 155 } else if (LIBRARIES.equals(nm)) { 156 CustomizerProviderImpl.SubCategoryProvider prov = (CustomizerProviderImpl.SubCategoryProvider)context.lookup(CustomizerProviderImpl.SubCategoryProvider.class); 157 assert prov != null : "Assuming CustomizerProviderImpl.SubCategoryProvider in customizer context"; 158 return new CustomizerLibraries(uiProps, prov); 159 } else if (BUILD.equals(nm)) { 160 return new CustomizerCompile(uiProps); 161 } else if (WAR.equals(nm)) { 162 return new CustomizerWar(uiProps); 163 } else if (JAVADOC.equals(nm)) { 164 return new CustomizerJavadoc(uiProps); 165 } else if (RUN.equals(nm)) { 166 return new CustomizerRun(uiProps); 167 } else if (WEBSERVICES.equals(nm) || WEBSERVICECLIENTS.equals(nm)) { 168 ProjectWebModule wm = (ProjectWebModule) uiProps.getProject().getLookup().lookup(ProjectWebModule.class); 169 FileObject docBase = wm.getDocumentBase(); 170 if (WEBSERVICES.equals(nm)) { 171 List servicesSettings = null; 172 if (docBase != null) { 173 WebServicesSupport servicesSupport = WebServicesSupport.getWebServicesSupport(docBase); 174 if (servicesSupport != null) { 175 servicesSettings = servicesSupport.getServices(); 176 } 177 } 178 if(servicesSettings != null && servicesSettings.size() > 0) { 179 return new CustomizerWSServiceHost( uiProps, servicesSettings ); 180 } else { 181 return new NoWebServicesPanel(); 182 } 183 } else if (WEBSERVICECLIENTS.equals(nm)) { 184 List serviceClientsSettings = null; 185 if (docBase != null) { 186 WebServicesClientSupport clientSupport = WebServicesClientSupport.getWebServicesClientSupport(docBase); 187 if (clientSupport != null) { 188 serviceClientsSettings = clientSupport.getServiceClients(); 189 } 190 } 191 if(serviceClientsSettings != null && serviceClientsSettings.size() > 0) { 192 return new CustomizerWSClientHost( uiProps, serviceClientsSettings ); 193 } else { 194 return new NoWebServiceClientsPanel(); 195 } 196 } 197 } 198 199 return new JPanel (); 200 } 201 202 public static WebCompositePanelProvider createSources() { 203 return new WebCompositePanelProvider(SOURCES); 204 } 205 206 public static WebCompositePanelProvider createFrameworks() { 207 return new WebCompositePanelProvider(FRAMEWORKS); 208 } 209 210 public static WebCompositePanelProvider createLibraries() { 211 return new WebCompositePanelProvider(LIBRARIES); 212 } 213 214 public static WebCompositePanelProvider createBuild() { 215 return new WebCompositePanelProvider(BUILD); 216 } 217 218 public static WebCompositePanelProvider createWar() { 219 return new WebCompositePanelProvider(WAR); 220 } 221 222 public static WebCompositePanelProvider createJavadoc() { 223 return new WebCompositePanelProvider(JAVADOC); 224 } 225 226 public static WebCompositePanelProvider createRun() { 227 return new WebCompositePanelProvider(RUN); 228 } 229 230 public static WebCompositePanelProvider createWebServices() { 231 return new WebCompositePanelProvider(WEBSERVICES); 232 } 233 234 public static WebCompositePanelProvider createWebServiceClients() { 235 return new WebCompositePanelProvider(WEBSERVICECLIENTS); 236 } 237 238 } 239 | Popular Tags |