1 19 20 package org.netbeans.modules.apisupport.project.ui; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import javax.swing.event.ChangeListener ; 25 import org.netbeans.api.project.Project; 26 import org.netbeans.modules.apisupport.project.NbModuleProject; 27 import org.netbeans.spi.project.ui.support.NodeFactory; 28 import org.netbeans.spi.project.ui.support.NodeList; 29 import org.openide.filesystems.FileObject; 30 import org.openide.nodes.Node; 31 32 36 public class LibrariesNodeFactory implements NodeFactory { 37 38 39 public LibrariesNodeFactory() { 40 } 41 42 public NodeList createNodes(Project p) { 43 NbModuleProject proj = p.getLookup().lookup(NbModuleProject.class); 44 assert proj != null; 45 return new LibraryNL(proj); 46 } 47 48 private static class LibraryNL implements NodeList<String > { 49 50 private NbModuleProject project; 51 52 LibraryNL(NbModuleProject prj) { 53 project = prj; 54 } 55 56 public List <String > keys() { 57 List <String > toRet = new ArrayList <String >(); 58 toRet.add(LibrariesNode.LIBRARIES_NAME); 59 if(resolveFileObjectFromProperty("test.unit.src.dir") != null) { toRet.add(UnitTestLibrariesNode.UNIT_TEST_LIBRARIES_NAME); 61 } 62 return toRet; 63 } 64 65 private FileObject resolveFileObjectFromProperty(String property){ 66 String filename = project.evaluator().getProperty(property); 67 if (filename == null) { 68 return null; 69 } 70 return project.getHelper().resolveFileObject(filename); 71 } 72 73 public void addChangeListener(ChangeListener l) { 74 } 75 76 public void removeChangeListener(ChangeListener l) { 77 } 78 79 public Node node(String key) { 80 if (key == LibrariesNode.LIBRARIES_NAME) { 81 return new LibrariesNode(project); 82 } else if (key == UnitTestLibrariesNode.UNIT_TEST_LIBRARIES_NAME) { 83 return new UnitTestLibrariesNode(project); 84 } 85 throw new AssertionError ("Unknown key: " + key); 86 } 87 88 public void addNotify() { 89 } 92 93 public void removeNotify() { 94 } 95 } 96 97 } 98 | Popular Tags |