1 19 20 package org.netbeans.modules.ruby.rubyproject.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.spi.project.ui.support.ProjectCustomizer; 28 import org.openide.util.Lookup; 29 import org.openide.util.NbBundle; 30 31 35 public class RubyCompositePanelProvider implements ProjectCustomizer.CompositeCategoryProvider { 36 37 private static final String SOURCES = "Sources"; 38 39 private static final String BUILD = "Build"; 40 public static final String RUN = "Run"; 41 42 private String name; 43 44 45 public RubyCompositePanelProvider(String name) { 46 this.name = name; 47 } 48 49 public ProjectCustomizer.Category createCategory(Lookup context) { 50 ResourceBundle 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" ), null, 63 (ProjectCustomizer.Category[])null); 64 } else if (RUN.equals(name)) { 65 toReturn = ProjectCustomizer.Category.create( 66 RUN, 67 bundle.getString( "LBL_Config_Run" ), null, 69 (ProjectCustomizer.Category[])null); 70 } 71 assert toReturn != null : "No category for name:" + name; 72 return toReturn; 73 } 74 75 public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) { 76 String 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 (); 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 |