KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > j2seproject > ui > customizer > J2SECompositePanelProvider


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.java.j2seproject.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.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 /**
36  *
37  * @author mkleint
38  */

39 public class J2SECompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
40     
41     private static final String JavaDoc SOURCES = "Sources";
42     static final String JavaDoc LIBRARIES = "Libraries";
43     
44     private static final String JavaDoc BUILD = "Build";
45 // private static final String BUILD_TESTS = "BuildTests";
46
private static final String JavaDoc JAR = "Jar";
47     private static final String JavaDoc JAVADOC = "Javadoc";
48     public static final String JavaDoc RUN = "Run";
49 // private static final String RUN_TESTS = "RunTests";
50
private static final String JavaDoc APPLICATION = "Application";
51     
52     private static final String JavaDoc WEBSERVICECLIENTS = "WebServiceClients";
53     private static final String JavaDoc WEBSERVICE_CATEGORY = "WebServiceCategory";
54
55     private String JavaDoc name;
56     
57     /** Creates a new instance of J2SECompositePanelProvider */
58     public J2SECompositePanelProvider(String JavaDoc name) {
59         this.name = name;
60     }
61
62     public ProjectCustomizer.Category createCategory(Lookup context) {
63         ResourceBundle JavaDoc 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" ), // NOI18N
75
null,
76                     null );
77         } else if (BUILD.equals(name)) {
78             toReturn = ProjectCustomizer.Category.create(
79                     BUILD,
80                     bundle.getString( "LBL_Config_Build" ), // NOI18N
81
null,
82                     null);
83         } else if (JAR.equals(name)) {
84             toReturn = ProjectCustomizer.Category.create(
85                     JAR,
86                     bundle.getString( "LBL_Config_Jar" ), // NOI18N
87
null,
88                     null );
89         } else if (JAVADOC.equals(name)) {
90             toReturn = ProjectCustomizer.Category.create(
91                     JAVADOC,
92                     bundle.getString( "LBL_Config_Javadoc" ), // NOI18N
93
null,
94                     null );
95         } else if (RUN.equals(name)) {
96             toReturn = ProjectCustomizer.Category.create(
97                     RUN,
98                     bundle.getString( "LBL_Config_Run" ), // NOI18N
99
null,
100                     null );
101         } else if (WEBSERVICECLIENTS.equals(name)) {
102             toReturn = ProjectCustomizer.Category.create(
103                     WEBSERVICECLIENTS,
104                     bundle.getString( "LBL_Config_WebServiceClients" ), // NOI18N
105
null,
106                     null);
107         } else if (APPLICATION.equals(name)) {
108             toReturn = ProjectCustomizer.Category.create(
109                     APPLICATION,
110                     bundle.getString( "LBL_Config_Application" ), // NOI18N,
111
null,
112                     null);
113         }
114         assert toReturn != null : "No category for name:" + name;
115         return toReturn;
116     }
117
118     public JComponent JavaDoc createComponent(ProjectCustomizer.Category category, Lookup context) {
119         String JavaDoc 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 JavaDoc 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 JavaDoc();
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