KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > railsprojects > ui > customizer > RailsCompositePanelProvider


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.railsprojects.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 RailsCompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider {
36     
37     private static final String JavaDoc BUILD = "Build";
38     public static final String JavaDoc RUN = "Run";
39     
40     private String JavaDoc name;
41     
42     /** Creates a new instance of RailsCompositePanelProvider */
43     public RailsCompositePanelProvider(String JavaDoc name) {
44         this.name = name;
45     }
46
47     public ProjectCustomizer.Category createCategory(Lookup context) {
48         ResourceBundle JavaDoc bundle = NbBundle.getBundle( CustomizerProviderImpl.class );
49         ProjectCustomizer.Category toReturn = null;
50         if (BUILD.equals(name)) {
51             toReturn = ProjectCustomizer.Category.create(
52                     BUILD,
53                     bundle.getString( "LBL_Config_Build" ), // NOI18N
54
null,
55                     (ProjectCustomizer.Category[])null);
56         } else if (RUN.equals(name)) {
57             toReturn = ProjectCustomizer.Category.create(
58                     RUN,
59                     bundle.getString( "LBL_Config_Run" ), // NOI18N
60
null,
61                     (ProjectCustomizer.Category[])null);
62         }
63         assert toReturn != null : "No category for name:" + name;
64         return toReturn;
65     }
66
67     public JComponent JavaDoc createComponent(ProjectCustomizer.Category category, Lookup context) {
68         String JavaDoc nm = category.getName();
69         RailsProjectProperties uiProps = (RailsProjectProperties)context.lookup(RailsProjectProperties.class);
70         if (BUILD.equals(nm)) {
71             return new CustomizerCompile(uiProps);
72         } else if (RUN.equals(nm)) {
73             return new CustomizerRun(uiProps);
74         }
75         return new JPanel JavaDoc();
76
77     }
78
79     public static RailsCompositePanelProvider createBuild() {
80         return new RailsCompositePanelProvider(BUILD);
81     }
82
83     public static RailsCompositePanelProvider createRun() {
84         return new RailsCompositePanelProvider(RUN);
85     }
86 }
87
Popular Tags