Java ExplorerManager Filter
up vote
0
down vote
favorite
I have implemented https://blogs.oracle.com/geertjan/file-browser to show only folders (changed == in accept() to !=). However, no matter what I have done it only calls the FileFilterNodeChildren for the first level, the children of the root node. So what I get is the folders of the root node (the directory I want) but it show ALL files and folders below this level. I have put in statements that verify that the filter function is only called for the first level.
What do I need to do to filter the children of the first level and below?
java netbeans netbeans-platform filefilter
add a comment |
up vote
0
down vote
favorite
I have implemented https://blogs.oracle.com/geertjan/file-browser to show only folders (changed == in accept() to !=). However, no matter what I have done it only calls the FileFilterNodeChildren for the first level, the children of the root node. So what I get is the folders of the root node (the directory I want) but it show ALL files and folders below this level. I have put in statements that verify that the filter function is only called for the first level.
What do I need to do to filter the children of the first level and below?
java netbeans netbeans-platform filefilter
1
I'm not quite sure I understand what you're after. Do you want to only see the folders of the first level? Do you want to see folders only on any level? And did you step through your code with a debugger to see where it goes wrong? That's typically the best way to learn something about the code you copied.
– Thomas
Aug 24 at 15:53
I want to see only folders, at whatever level. I do not want to see any files in this Explorer.
– Val K
Aug 24 at 16:03
Note that the classes being used (e.g.DataFolder
) are not basic JDK classes and thus I can't help you with the specifics of that library. However, it seems that if you check for ` node.getLookup().lookup(DataFolder.class) != null` this might mean something different than "it is a folder". You'd need to read up on whatlookup
is doing to better understand what's going on. Just copy-paste won't help you in the long run.
– Thomas
Aug 24 at 16:18
Replying to Thomas: I put a breakpoint on the accept function. For the four directories at the first level (below the root) the accept function is called twice. That is, accept() is called for each of the four directories, then it is called again for each of the four directories. It is not called for any of the files or directories below the first level directories. I added a System.out.print for each of the node.getDisplayName() so that I could tell which directories it was being called on.
– Val K
Aug 24 at 16:25
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have implemented https://blogs.oracle.com/geertjan/file-browser to show only folders (changed == in accept() to !=). However, no matter what I have done it only calls the FileFilterNodeChildren for the first level, the children of the root node. So what I get is the folders of the root node (the directory I want) but it show ALL files and folders below this level. I have put in statements that verify that the filter function is only called for the first level.
What do I need to do to filter the children of the first level and below?
java netbeans netbeans-platform filefilter
I have implemented https://blogs.oracle.com/geertjan/file-browser to show only folders (changed == in accept() to !=). However, no matter what I have done it only calls the FileFilterNodeChildren for the first level, the children of the root node. So what I get is the folders of the root node (the directory I want) but it show ALL files and folders below this level. I have put in statements that verify that the filter function is only called for the first level.
What do I need to do to filter the children of the first level and below?
java netbeans netbeans-platform filefilter
java netbeans netbeans-platform filefilter
edited Aug 30 at 14:45
asked Aug 24 at 15:50
Val K
13
13
1
I'm not quite sure I understand what you're after. Do you want to only see the folders of the first level? Do you want to see folders only on any level? And did you step through your code with a debugger to see where it goes wrong? That's typically the best way to learn something about the code you copied.
– Thomas
Aug 24 at 15:53
I want to see only folders, at whatever level. I do not want to see any files in this Explorer.
– Val K
Aug 24 at 16:03
Note that the classes being used (e.g.DataFolder
) are not basic JDK classes and thus I can't help you with the specifics of that library. However, it seems that if you check for ` node.getLookup().lookup(DataFolder.class) != null` this might mean something different than "it is a folder". You'd need to read up on whatlookup
is doing to better understand what's going on. Just copy-paste won't help you in the long run.
– Thomas
Aug 24 at 16:18
Replying to Thomas: I put a breakpoint on the accept function. For the four directories at the first level (below the root) the accept function is called twice. That is, accept() is called for each of the four directories, then it is called again for each of the four directories. It is not called for any of the files or directories below the first level directories. I added a System.out.print for each of the node.getDisplayName() so that I could tell which directories it was being called on.
– Val K
Aug 24 at 16:25
add a comment |
1
I'm not quite sure I understand what you're after. Do you want to only see the folders of the first level? Do you want to see folders only on any level? And did you step through your code with a debugger to see where it goes wrong? That's typically the best way to learn something about the code you copied.
– Thomas
Aug 24 at 15:53
I want to see only folders, at whatever level. I do not want to see any files in this Explorer.
– Val K
Aug 24 at 16:03
Note that the classes being used (e.g.DataFolder
) are not basic JDK classes and thus I can't help you with the specifics of that library. However, it seems that if you check for ` node.getLookup().lookup(DataFolder.class) != null` this might mean something different than "it is a folder". You'd need to read up on whatlookup
is doing to better understand what's going on. Just copy-paste won't help you in the long run.
– Thomas
Aug 24 at 16:18
Replying to Thomas: I put a breakpoint on the accept function. For the four directories at the first level (below the root) the accept function is called twice. That is, accept() is called for each of the four directories, then it is called again for each of the four directories. It is not called for any of the files or directories below the first level directories. I added a System.out.print for each of the node.getDisplayName() so that I could tell which directories it was being called on.
– Val K
Aug 24 at 16:25
1
1
I'm not quite sure I understand what you're after. Do you want to only see the folders of the first level? Do you want to see folders only on any level? And did you step through your code with a debugger to see where it goes wrong? That's typically the best way to learn something about the code you copied.
– Thomas
Aug 24 at 15:53
I'm not quite sure I understand what you're after. Do you want to only see the folders of the first level? Do you want to see folders only on any level? And did you step through your code with a debugger to see where it goes wrong? That's typically the best way to learn something about the code you copied.
– Thomas
Aug 24 at 15:53
I want to see only folders, at whatever level. I do not want to see any files in this Explorer.
– Val K
Aug 24 at 16:03
I want to see only folders, at whatever level. I do not want to see any files in this Explorer.
– Val K
Aug 24 at 16:03
Note that the classes being used (e.g.
DataFolder
) are not basic JDK classes and thus I can't help you with the specifics of that library. However, it seems that if you check for ` node.getLookup().lookup(DataFolder.class) != null` this might mean something different than "it is a folder". You'd need to read up on what lookup
is doing to better understand what's going on. Just copy-paste won't help you in the long run.– Thomas
Aug 24 at 16:18
Note that the classes being used (e.g.
DataFolder
) are not basic JDK classes and thus I can't help you with the specifics of that library. However, it seems that if you check for ` node.getLookup().lookup(DataFolder.class) != null` this might mean something different than "it is a folder". You'd need to read up on what lookup
is doing to better understand what's going on. Just copy-paste won't help you in the long run.– Thomas
Aug 24 at 16:18
Replying to Thomas: I put a breakpoint on the accept function. For the four directories at the first level (below the root) the accept function is called twice. That is, accept() is called for each of the four directories, then it is called again for each of the four directories. It is not called for any of the files or directories below the first level directories. I added a System.out.print for each of the node.getDisplayName() so that I could tell which directories it was being called on.
– Val K
Aug 24 at 16:25
Replying to Thomas: I put a breakpoint on the accept function. For the four directories at the first level (below the root) the accept function is called twice. That is, accept() is called for each of the four directories, then it is called again for each of the four directories. It is not called for any of the files or directories below the first level directories. I added a System.out.print for each of the node.getDisplayName() so that I could tell which directories it was being called on.
– Val K
Aug 24 at 16:25
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Inside of createNodes() you need to wrap the child nodes with instances of FileFilterNode. Here is a revised version of createNodes():
@Override
protected Node createNodes(Node object) {
List<Node> result = new ArrayList<Node>();
for (Node node : super.createNodes(object)) {
if (accept(node)) {
// This is the only changed line
result.add(new FileFilterNode(node));
}
}
return result.toArray(new Node[0]);
}
This was tested in NetBeans 8.2 on Windows and works as expected. The "File Browser" displays a tree containing only folders at all levels.
Okay, this works to get the filter called for nodes below the first level. However, when I try to filter out non-directory nodes (i.e.: files) then it causes other problems. These problems are difficult to describe and are better experienced. I will be using jtree instead of bean tree because it allows me to build the tree instead of it building the tree. Thanks for everyone's help.
– Val K
Nov 7 at 18:24
I tested it on Windows with NetBeans 8.2 just now and it seems to work fine. I'm curious what the other problems are.
– Corey
Nov 7 at 18:55
I just tested it on Linux using NetBeans 9.0.1. When I expand the final directory it "silently" throws an exception. (i.e.: I see the exception information in the debugger but not in the GUI.) On all others when I expand it I see a "blank" document for each of the files filtered out, an exception is thrown in the debugger for each and every one of those files, then when it is done with this (because throwing the exceptions takes time) the "blank" documents disappear and the tree appears how I expect it to be. By "blank" I mean that the document icon is shown with no name.
– Val K
Nov 13 at 16:35
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Inside of createNodes() you need to wrap the child nodes with instances of FileFilterNode. Here is a revised version of createNodes():
@Override
protected Node createNodes(Node object) {
List<Node> result = new ArrayList<Node>();
for (Node node : super.createNodes(object)) {
if (accept(node)) {
// This is the only changed line
result.add(new FileFilterNode(node));
}
}
return result.toArray(new Node[0]);
}
This was tested in NetBeans 8.2 on Windows and works as expected. The "File Browser" displays a tree containing only folders at all levels.
Okay, this works to get the filter called for nodes below the first level. However, when I try to filter out non-directory nodes (i.e.: files) then it causes other problems. These problems are difficult to describe and are better experienced. I will be using jtree instead of bean tree because it allows me to build the tree instead of it building the tree. Thanks for everyone's help.
– Val K
Nov 7 at 18:24
I tested it on Windows with NetBeans 8.2 just now and it seems to work fine. I'm curious what the other problems are.
– Corey
Nov 7 at 18:55
I just tested it on Linux using NetBeans 9.0.1. When I expand the final directory it "silently" throws an exception. (i.e.: I see the exception information in the debugger but not in the GUI.) On all others when I expand it I see a "blank" document for each of the files filtered out, an exception is thrown in the debugger for each and every one of those files, then when it is done with this (because throwing the exceptions takes time) the "blank" documents disappear and the tree appears how I expect it to be. By "blank" I mean that the document icon is shown with no name.
– Val K
Nov 13 at 16:35
add a comment |
up vote
0
down vote
Inside of createNodes() you need to wrap the child nodes with instances of FileFilterNode. Here is a revised version of createNodes():
@Override
protected Node createNodes(Node object) {
List<Node> result = new ArrayList<Node>();
for (Node node : super.createNodes(object)) {
if (accept(node)) {
// This is the only changed line
result.add(new FileFilterNode(node));
}
}
return result.toArray(new Node[0]);
}
This was tested in NetBeans 8.2 on Windows and works as expected. The "File Browser" displays a tree containing only folders at all levels.
Okay, this works to get the filter called for nodes below the first level. However, when I try to filter out non-directory nodes (i.e.: files) then it causes other problems. These problems are difficult to describe and are better experienced. I will be using jtree instead of bean tree because it allows me to build the tree instead of it building the tree. Thanks for everyone's help.
– Val K
Nov 7 at 18:24
I tested it on Windows with NetBeans 8.2 just now and it seems to work fine. I'm curious what the other problems are.
– Corey
Nov 7 at 18:55
I just tested it on Linux using NetBeans 9.0.1. When I expand the final directory it "silently" throws an exception. (i.e.: I see the exception information in the debugger but not in the GUI.) On all others when I expand it I see a "blank" document for each of the files filtered out, an exception is thrown in the debugger for each and every one of those files, then when it is done with this (because throwing the exceptions takes time) the "blank" documents disappear and the tree appears how I expect it to be. By "blank" I mean that the document icon is shown with no name.
– Val K
Nov 13 at 16:35
add a comment |
up vote
0
down vote
up vote
0
down vote
Inside of createNodes() you need to wrap the child nodes with instances of FileFilterNode. Here is a revised version of createNodes():
@Override
protected Node createNodes(Node object) {
List<Node> result = new ArrayList<Node>();
for (Node node : super.createNodes(object)) {
if (accept(node)) {
// This is the only changed line
result.add(new FileFilterNode(node));
}
}
return result.toArray(new Node[0]);
}
This was tested in NetBeans 8.2 on Windows and works as expected. The "File Browser" displays a tree containing only folders at all levels.
Inside of createNodes() you need to wrap the child nodes with instances of FileFilterNode. Here is a revised version of createNodes():
@Override
protected Node createNodes(Node object) {
List<Node> result = new ArrayList<Node>();
for (Node node : super.createNodes(object)) {
if (accept(node)) {
// This is the only changed line
result.add(new FileFilterNode(node));
}
}
return result.toArray(new Node[0]);
}
This was tested in NetBeans 8.2 on Windows and works as expected. The "File Browser" displays a tree containing only folders at all levels.
edited Nov 7 at 18:54
answered Oct 23 at 16:44
Corey
538514
538514
Okay, this works to get the filter called for nodes below the first level. However, when I try to filter out non-directory nodes (i.e.: files) then it causes other problems. These problems are difficult to describe and are better experienced. I will be using jtree instead of bean tree because it allows me to build the tree instead of it building the tree. Thanks for everyone's help.
– Val K
Nov 7 at 18:24
I tested it on Windows with NetBeans 8.2 just now and it seems to work fine. I'm curious what the other problems are.
– Corey
Nov 7 at 18:55
I just tested it on Linux using NetBeans 9.0.1. When I expand the final directory it "silently" throws an exception. (i.e.: I see the exception information in the debugger but not in the GUI.) On all others when I expand it I see a "blank" document for each of the files filtered out, an exception is thrown in the debugger for each and every one of those files, then when it is done with this (because throwing the exceptions takes time) the "blank" documents disappear and the tree appears how I expect it to be. By "blank" I mean that the document icon is shown with no name.
– Val K
Nov 13 at 16:35
add a comment |
Okay, this works to get the filter called for nodes below the first level. However, when I try to filter out non-directory nodes (i.e.: files) then it causes other problems. These problems are difficult to describe and are better experienced. I will be using jtree instead of bean tree because it allows me to build the tree instead of it building the tree. Thanks for everyone's help.
– Val K
Nov 7 at 18:24
I tested it on Windows with NetBeans 8.2 just now and it seems to work fine. I'm curious what the other problems are.
– Corey
Nov 7 at 18:55
I just tested it on Linux using NetBeans 9.0.1. When I expand the final directory it "silently" throws an exception. (i.e.: I see the exception information in the debugger but not in the GUI.) On all others when I expand it I see a "blank" document for each of the files filtered out, an exception is thrown in the debugger for each and every one of those files, then when it is done with this (because throwing the exceptions takes time) the "blank" documents disappear and the tree appears how I expect it to be. By "blank" I mean that the document icon is shown with no name.
– Val K
Nov 13 at 16:35
Okay, this works to get the filter called for nodes below the first level. However, when I try to filter out non-directory nodes (i.e.: files) then it causes other problems. These problems are difficult to describe and are better experienced. I will be using jtree instead of bean tree because it allows me to build the tree instead of it building the tree. Thanks for everyone's help.
– Val K
Nov 7 at 18:24
Okay, this works to get the filter called for nodes below the first level. However, when I try to filter out non-directory nodes (i.e.: files) then it causes other problems. These problems are difficult to describe and are better experienced. I will be using jtree instead of bean tree because it allows me to build the tree instead of it building the tree. Thanks for everyone's help.
– Val K
Nov 7 at 18:24
I tested it on Windows with NetBeans 8.2 just now and it seems to work fine. I'm curious what the other problems are.
– Corey
Nov 7 at 18:55
I tested it on Windows with NetBeans 8.2 just now and it seems to work fine. I'm curious what the other problems are.
– Corey
Nov 7 at 18:55
I just tested it on Linux using NetBeans 9.0.1. When I expand the final directory it "silently" throws an exception. (i.e.: I see the exception information in the debugger but not in the GUI.) On all others when I expand it I see a "blank" document for each of the files filtered out, an exception is thrown in the debugger for each and every one of those files, then when it is done with this (because throwing the exceptions takes time) the "blank" documents disappear and the tree appears how I expect it to be. By "blank" I mean that the document icon is shown with no name.
– Val K
Nov 13 at 16:35
I just tested it on Linux using NetBeans 9.0.1. When I expand the final directory it "silently" throws an exception. (i.e.: I see the exception information in the debugger but not in the GUI.) On all others when I expand it I see a "blank" document for each of the files filtered out, an exception is thrown in the debugger for each and every one of those files, then when it is done with this (because throwing the exceptions takes time) the "blank" documents disappear and the tree appears how I expect it to be. By "blank" I mean that the document icon is shown with no name.
– Val K
Nov 13 at 16:35
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52007913%2fjava-explorermanager-filter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I'm not quite sure I understand what you're after. Do you want to only see the folders of the first level? Do you want to see folders only on any level? And did you step through your code with a debugger to see where it goes wrong? That's typically the best way to learn something about the code you copied.
– Thomas
Aug 24 at 15:53
I want to see only folders, at whatever level. I do not want to see any files in this Explorer.
– Val K
Aug 24 at 16:03
Note that the classes being used (e.g.
DataFolder
) are not basic JDK classes and thus I can't help you with the specifics of that library. However, it seems that if you check for ` node.getLookup().lookup(DataFolder.class) != null` this might mean something different than "it is a folder". You'd need to read up on whatlookup
is doing to better understand what's going on. Just copy-paste won't help you in the long run.– Thomas
Aug 24 at 16:18
Replying to Thomas: I put a breakpoint on the accept function. For the four directories at the first level (below the root) the accept function is called twice. That is, accept() is called for each of the four directories, then it is called again for each of the four directories. It is not called for any of the files or directories below the first level directories. I added a System.out.print for each of the node.getDisplayName() so that I could tell which directories it was being called on.
– Val K
Aug 24 at 16:25