KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > rubyproject > ui > customizer > RubyCompositePanelProvider


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.ruby.rubyproject.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.spi.project.ui.support.ProjectCustomizer;
28 import org.openide.util.Lookup;
29 import org.openide.util.NbBundle;
30
31 /**
32  *
33  * @author mkleint
34  */

35 public class RubyCompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
36     
37     private static final String JavaDoc SOURCES = "Sources";
38     
39     private static final String JavaDoc BUILD = "Build";
40     public static final String JavaDoc RUN = "Run";
41     
42     private String JavaDoc name;
43     
44     /** Creates a new instance of RubyCompositePanelProvider */
45     public RubyCompositePanelProvider(String JavaDoc name) {
46         this.name = name;
47     }
48
49     public ProjectCustomizer.Category createCategory(Lookup context) {
50         ResourceBundle JavaDoc bundle = NbBundle.getBundle( CustomizerProviderImpl.class );
51         ProjectCustomizer.Category toReturn = null;
52         if (SOURCES.equals(name)) {
53             toReturn = ProjectCustomizer.Category.create(
54                     SOURCES,
55                     bundle.getString("LBL_Config_Sources"),
56                     null,
57                     (ProjectCustomizer.Category[])null);
58         } else if (BUILD.equals(name)) {
59             toReturn = ProjectCustomizer.Category.create(
60                     BUILD,
61                     bundle.getString( "LBL_Config_Build" ), // NOI18N
62
null,
63                     (ProjectCustomizer.Category[])null);
64         } else if (RUN.equals(name)) {
65             toReturn = ProjectCustomizer.Category.create(
66                     RUN,
67                     bundle.getString( "LBL_Config_Run" ), // NOI18N
68
null,
69                     (ProjectCustomizer.Category[])null);
70         }
71         assert toReturn != null : "No category for name:" + name;
72         return toReturn;
73     }
74
75     public JComponent JavaDoc createComponent(ProjectCustomizer.Category category, Lookup context) {
76         String JavaDoc nm = category.getName();
77         RubyProjectProperties uiProps = (RubyProjectProperties)context.lookup(RubyProjectProperties.class);
78         if (SOURCES.equals(nm)) {
79             return new CustomizerSources(uiProps);
80         } else if (BUILD.equals(nm)) {
81             return new CustomizerCompile(uiProps);
82         } else if (RUN.equals(nm)) {
83             return new CustomizerRun(uiProps);
84         }
85         return new JPanel JavaDoc();
86
87     }
88
89     public static RubyCompositePanelProvider createSources() {
90         return new RubyCompositePanelProvider(SOURCES);
91     }
92
93     public static RubyCompositePanelProvider createBuild() {
94         return new RubyCompositePanelProvider(BUILD);
95     }
96
97     public static RubyCompositePanelProvider createRun() {
98         return new RubyCompositePanelProvider(RUN);
99     }
100 }
101
Popular Tags