1 19 20 package org.netbeans.modules.ant.freeform.ui; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import javax.swing.JComponent ; 25 import org.netbeans.api.project.Project; 26 import org.netbeans.modules.ant.freeform.FreeformProject; 27 import org.netbeans.modules.ant.freeform.spi.ProjectAccessor; 28 import org.netbeans.modules.ant.freeform.spi.ProjectNature; 29 import org.netbeans.modules.ant.freeform.spi.TargetDescriptor; 30 import org.netbeans.spi.project.AuxiliaryConfiguration; 31 import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category; 32 import org.openide.util.Lookup; 33 import org.openide.util.NbBundle; 34 35 36 40 public class TargetMappingCategoryProvider implements org.netbeans.spi.project.ui.support.ProjectCustomizer.CompositeCategoryProvider { 41 42 43 public TargetMappingCategoryProvider() { 44 } 45 46 public Category createCategory(Lookup context) { 47 FreeformProject project = context.lookup(FreeformProject.class); 48 assert project != null; 49 if (project.usesAntScripting()) { 50 return org.netbeans.spi.project.ui.support.ProjectCustomizer.Category.create("targetMapping", 51 NbBundle.getMessage(TargetMappingPanel.class, "LBL_ProjectCustomizer_Category_Targets"), null); 52 } 53 return null; 54 } 55 56 public JComponent createComponent(Category category, Lookup context) { 57 Project project = context.lookup(Project.class); 58 ProjectAccessor acc = context.lookup(ProjectAccessor.class); 59 AuxiliaryConfiguration aux = context.lookup(AuxiliaryConfiguration.class); 60 assert aux != null; 61 assert acc != null; 62 assert project != null; 63 64 List <TargetDescriptor> extraTargets = new ArrayList <TargetDescriptor>(); 65 for (ProjectNature pn : FreeformProject.PROJECT_NATURES.allInstances()) { 66 extraTargets.addAll(pn.getExtraTargets(project, acc.getHelper(), acc.getEvaluator(), aux)); 67 } 68 69 TargetMappingPanel panel = new TargetMappingPanel(extraTargets, acc.getEvaluator(), acc.getHelper()); 70 category.setOkButtonListener(panel.getCustomizerOkListener()); 71 return panel; 72 } 73 74 } 75 | Popular Tags |