KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbjarproject > ui > customizer > EjbJarCompositePanelProvider


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.ejbjarproject.ui.customizer;
21
22 import java.util.List JavaDoc;
23 import java.util.ResourceBundle JavaDoc;
24 import javax.swing.JComponent JavaDoc;
25 import javax.swing.JPanel JavaDoc;
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 /**
35  *
36  * @author mkleint, rnajman
37  */

38 public class EjbJarCompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
39     
40     private static final String JavaDoc SOURCES = "Sources";
41     static final String JavaDoc LIBRARIES = "Libraries";
42
43     private static final String JavaDoc BUILD = "Build";
44     private static final String JavaDoc JAR = "Jar";
45     private static final String JavaDoc JAVADOC = "Javadoc";
46     public static final String JavaDoc RUN = "Run";
47     
48     private static final String JavaDoc WEBSERVICES = "WebServices";
49     
50     private String JavaDoc name;
51     
52     /** Creates a new instance of EjbJarCompositePanelProvider */
53     public EjbJarCompositePanelProvider(String JavaDoc name) {
54         this.name = name;
55     }
56
57     public ProjectCustomizer.Category createCategory(Lookup context) {
58         ResourceBundle JavaDoc 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"), //NOI18N
65
null,
66                     null);
67         } else if (LIBRARIES.equals(name)) {
68             toReturn = ProjectCustomizer.Category.create(
69                     LIBRARIES,
70                     bundle.getString( "LBL_Config_Libraries" ), // NOI18N
71
null,
72                     null );
73         } else if (BUILD.equals(name)) {
74             toReturn = ProjectCustomizer.Category.create(
75                     BUILD,
76                     bundle.getString( "LBL_Config_Build" ), // NOI18N
77
null,
78                     null);
79         } else if (JAR.equals(name)) {
80             toReturn = ProjectCustomizer.Category.create(
81                     JAR,
82                     bundle.getString( "LBL_Config_Jar" ), // NOI18N
83
null,
84                     null );
85         } else if (JAVADOC.equals(name)) {
86             toReturn = ProjectCustomizer.Category.create(
87                     JAVADOC,
88                     bundle.getString( "LBL_Config_Javadoc" ), // NOI18N
89
null,
90                     null );
91         } else if (RUN.equals(name)) {
92             toReturn = ProjectCustomizer.Category.create(
93                     RUN,
94                     bundle.getString( "LBL_Config_Run" ), // NOI18N
95
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 JavaDoc 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" ), // NOI18N
112
null,
113                         null );
114             }
115         }
116         
117 // assert toReturn != null : "No category for name:" + name;
118
return toReturn;
119     }
120
121     public JComponent JavaDoc createComponent(ProjectCustomizer.Category category, Lookup context) {
122         String JavaDoc 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 JavaDoc 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 JavaDoc();
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