Skip to main content

JXTreeTable rowFilter

4 replies [Last post]
bolsover
Offline
Joined: 2005-01-10
Points: 0

Is it possible to set a rowfilter on a JXTreeTable; so far, my efforts have failed to filter any rows... is it possible? Or do I have to use some other mechanism to remove unwanted nodes (always leaf nodes) from the display?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
lapacho
Offline
Joined: 2009-09-08
Points: 0

Well, I have written a quick'n'dirty approach of the above idea.

This was the triggering question with the answer:

http://stackoverflow.com/questions/9234297/filtering-on-a-jtree/11297297...

and this is the code:

https://github.com/gentunian/FilteredTreeTableModel

Regards,

kschaefe
Offline
Joined: 2006-06-08
Points: 0

JXTreeTable is not sortable despite being a subclass of JXTable. We simply do not have a sorter capable of displaying the data as we would expect. setRowSorter is overridden to do nothing.

We are collecting ideas for how to sort JXTree(Table)s in the wiki, but nothing in progress yet.

Karl

lapacho
Offline
Joined: 2009-09-08
Points: 0

Filtering should be different than sorting. Sorting may rearrange nodes relationship keeping the model structure visible. Filtering should hide parent/child nodes from the view. Despite of sound similarly, filtering should not imply sorting, as it less "destructive" in a hiearchichal data.

What should mean sorting a tree anyway? You could end up a child being a parent of its parent because now sorting precedes in the hierarchy. That's something I don't want. I want to keep my hiearchy.

Filtering, instead, should only show/hide nodes without altering the hiearchy. That would be something like pruning the tree.

Filtering could also have the option of pruning the tree including the subtree of the node found. So, when you found a node, you stop filtering in its children and continue pruning the rest of the tree.

Basically, I think you could implement filtering by having a filteredRoot and moving nodes (subtrees) to that filteredRoot. When removing the filter, nodes will be added to their original parents, always keeping the hiearchy in the tree.

I'm working in the above idea of filtering. A parallel model which stores a Map of relationship child->parent to be later on restored when filter is removed. Then filtering reduces to move nodes to a filteredRoot and then restored when filter is removed.

kschaefe
Offline
Joined: 2006-06-08
Points: 0

The problem is that core supports filtering out of sorting. I guess we could only support identity sorting...

Karl