Reputation: 518
I would like to show the same data in a SWT/Jface TreeViewer and TableViewer. The question is how to store the data in a good way that both viewers can use the same data?
My raw data are stored in an array:
Id | Level | Type | Value
1 | 1 | Heading | Heading 1
2 | 2 | Text | This is a text
3 | 2 | Text | This is another text
4 | 1 | Heading | Heading 2
5 | 2 | Heading | Heading 2.1
6 | 3 | Heading | Heading 2.2
7 | 4 | Text | This is more text
...
The TreeViewer shall display the item with type "heading" only:
The TableViewer shall display the values in the same order as stored in the array.
My thoughts:
I can store the data in an ArrayList and provide it to the TableViewer by using the default ArrayContentProvider. But than I can't use this ArrayList for the TreeViewer.
Or I can store the data with parent-child relation and implement the interface ITreeContentProvider for the use in the TreeViewer. But than I can't use it for the TableViewer.
Can you give me some hint?
Background:
Maybe someone knows the software DOORS. You have an outline view on the left (TreeViewer) and a list in the main view (TableViewer). Both share the same data.
Upvotes: 0
Views: 58