Reputation: 4739
I'm currently creating a project type in Netbeans. I followed the basic tutorial but added a few things.
This is the logical view
public org.openide.nodes.Node createLogicalView() {
FileObject root = project.getProjectDirectory();
DataFolder findFolder = DataFolder.findFolder( root );
Node node = findFolder.getNodeDelegate();
return new TextNode( node, project );
}
Basically the root is the project folder.
This is my filter node.
private static final class TextNode extends FilterNode {
final NodeJSProject project;
public TextNode( Node node, NodeJSProject project ) {
super( node, new NodeJSProjectNode( node ),
new ProxyLookup( new Lookup[]{
Lookups.singleton( project ),
node.getLookup()
} ) );
this.project = project;
}
And my custom override for filter node.
public static class NodeJSProjectNode extends FilterNode.Children {
public NodeJSProjectNode( Node node ) {
super( node );
}
@Override
protected Node[] createNodes( Node key ) {
//key.getName() only returning root objects. No children
if ( key.getName().startsWith( "." ) ) {
return new Node[]{};
}
return new Node[]{ copyNode( key ) };
}
}
Basically I'm trying to ignore hidden files. I was thinking this was done by the IDE already but I guess not. The code I currently have works for the the root directory. It will not add .DS_Store, .git, etc. I'm trying to ignore all folders/files in the child directories. I'm not sure how this is done using the createNodes method. The only key's that seem to be coming in are the root nodes/files.
Upvotes: 2
Views: 568
Reputation: 14868
I have been following same tutorial and I have been able to realise a result that suits my special case; in my project type I want to see only 'xlsx' or 'xls' or 'txt' file types.
But I can see you took a different turn than the tutorial directs. Here's your constructor for TextNode
super( node, new NodeJSProjectNode( node ),
new ProxyLookup( new Lookup[]{
Lookups.singleton( project ),
node.getLookup()
} ) );
This is the tutorial's template:
super(node,
NodeFactorySupport.createCompositeChildren(
project,
"Projects/org-customer-project/Nodes"),
// new FilterNode.Children(node),
new ProxyLookup(
new Lookup[]{
Lookups.singleton(project),
node.getLookup()
}));
If you were to follow the tutorial as it goes, I believe I can help.
Upvotes: 1