1 19 20 package org.netbeans.modules.junit.wizards; 21 22 import org.openide.filesystems.FileObject; 23 import org.openide.loaders.DataObject; 24 import org.openide.nodes.Children; 25 import org.openide.nodes.FilterNode; 26 import org.openide.nodes.Node; 27 28 32 public class JavaChildren extends FilterNode.Children { 33 34 private static final String JAVA_MIME_TYPE = "text/x-java"; 36 public JavaChildren(Node parent) { 37 super(parent); 38 } 39 40 @Override 41 protected Node[] createNodes(Node originalNode) { 42 Node newNode; 43 44 DataObject dataObj = originalNode.getCookie(DataObject.class); 45 if (dataObj == null) { 46 newNode = copyNode(originalNode); 47 } else { 48 FileObject primaryFile = dataObj.getPrimaryFile(); 49 if (primaryFile.isFolder()) { 50 newNode = new FilterNode(originalNode, new JavaChildren(originalNode)); 51 } else if (primaryFile.getMIMEType().equals(JAVA_MIME_TYPE)) { 52 newNode = new FilterNode(originalNode, Children.LEAF); 53 newNode.setDisplayName(primaryFile.getName()); 54 } else { 55 newNode = null; 56 } 57 } 58 59 return (newNode != null) ? new Node[] {newNode} 60 : new Node[0]; 61 } 62 63 } 64 | Popular Tags |