1 19 20 package org.netbeans.modules.java.freeform.ui; 21 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.ActionListener ; 24 import javax.swing.JComponent ; 25 import org.netbeans.api.project.Project; 26 import org.netbeans.modules.ant.freeform.spi.ProjectAccessor; 27 import org.netbeans.modules.ant.freeform.spi.support.Util; 28 import org.netbeans.modules.java.freeform.LookupProviderImpl; 29 import org.netbeans.spi.project.AuxiliaryConfiguration; 30 import org.netbeans.spi.project.ui.support.ProjectCustomizer; 31 import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category; 32 import org.openide.filesystems.FileUtil; 33 import org.openide.util.Lookup; 34 import org.openide.util.NbBundle; 35 import org.openide.util.lookup.InstanceContent; 36 37 41 public class SourceFoldersCategoryProvider implements ProjectCustomizer.CompositeCategoryProvider { 42 43 44 public SourceFoldersCategoryProvider() { 45 } 46 47 public Category createCategory(Lookup context) { 48 AuxiliaryConfiguration aux = context.lookup(AuxiliaryConfiguration.class); 49 final ProjectAccessor acc = context.lookup(ProjectAccessor.class); 50 Project project = context.lookup(Project.class); 51 assert aux != null; 52 assert acc != null; 53 assert project != null; 54 if (LookupProviderImpl.isMyProject(aux)) { 55 Category cat = ProjectCustomizer.Category.create("SourceFolders", NbBundle.getMessage(ClasspathPanel.class, "LBL_ProjectCustomizer_Category_Sources"), null, null); 57 final ProjectModel pm = ProjectModel.createModel(Util.getProjectLocation(acc.getHelper(), acc.getEvaluator()), 58 FileUtil.toFile(project.getProjectDirectory()), acc.getEvaluator(), acc.getHelper()); 59 InstanceContent ic = context.lookup(InstanceContent.class); 60 assert ic != null; 61 ic.add(pm); 62 cat.setOkButtonListener(new ActionListener () { 63 public void actionPerformed(ActionEvent arg0) { 64 ProjectModel.saveProject(acc.getHelper(), pm); 66 } 67 }); 68 return cat; 69 } 70 return null; 71 } 72 73 public JComponent createComponent(Category category, Lookup context) { 74 ProjectModel pm = context.lookup(ProjectModel.class); 75 ProjectAccessor acc = context.lookup(ProjectAccessor.class); 76 assert pm != null; 77 SourceFoldersPanel panel = new SourceFoldersPanel(false); 78 panel.setModel(pm, acc.getHelper()); 79 return panel; 80 81 } 82 83 } 84 | Popular Tags |