I have a tree structure that is added to an XViewer
(XViewer
is essentially an enhanced TreeViewer
). I would like to display the data using two different views (depending on a radio button that the user clicks on). If the user chooses the first view, they will see the data in tree form. If the user chooses the second view, they will see a flattened version of the data that is table-like.
Is it possible to use ViewerFilter
(and possibly some other kind of filtering) to be able to switch the presentation of the data on the fly? Or do I have to keep track of different data structures and manually switch them when a user clicks on a radio button? Ex: maintain setInput(tree)
and setInput(List)
? I would prefer to only maintain one data structure as the input and present it in different ways.
A quick example is shown below.
public class Foo{
int myIntOne;
String myStringOne;
String myStringTwo;
public Foo(int i, String s1, String s2){
myIntOne = i;
myStringOne = s1;
myStringTwo = s2;
}
}
public class Example extends XViewer{
public void someMethod(){
//Create some fake data
Foo a = new Foo(1,"John","Doe");
Foo a1 = new Foo(1,"Mike","Doe");
Foo b = new Foo(2,"Steve","Smith");
Foo c = new Foo(3,"Roger","Jones");
// Combine them into a tree structure
// Not shown since outside scope of question
setInput(treeStructure);
}
}
========
View one
========
All
-----
Doe
-John
-Mike
Smith
- Steve
Jones
- Roger
========
View Two
========
FName | LName | Number
----------------------
John | Doe | 1
Mike | Doe | 1
Steve | Smith | 2
Roger | Jones | 3
The issue with using the ViewerFilter
is that it shows rows for all parent nodes. I don't want the parent node(s) to be visible and I don't want to be able to drill into the node that I want displayed. Is there a way to remove/hide those rows?
Basically, my issue looks very similar (visually) to the picture shown in this post: Hiding empty parents - JFace's TreeViewer
I cannot use a FilteredTree
since I am already using an XViewer
and I don't need a text input field.
I tried playing around with the XViewerLabelProvider
, but it still returns blank tree rows for the nodes I am not interested in.
Any suggestions? Thanks!