0

I am writing a treeviewer which displays my model, which includes three classes Project, Course and Student. Each project can have multiple courses and each course can have multiple students.

I am using the TreeViewer class of JFace.

To Display this model, I have created a treeviewer, which looks like the following.

enter image description here

I want these Courses (course1, 2 and 3) to be grouped under a node COURSES like following.

enter image description here

Is there a function to group elements under a parent by the element type? Or can I introduce this dummy node "Courses", which is actually not a part of my model.

rayobanon
  • 43
  • 1
  • 7
  • 1
    This is all just a matter of how your content provider is implemented for your model. It can tell the viewer whatever you want, as long as it fulfills the interface. – nitind Sep 13 '19 at 12:09
  • I already know this. I would like to know how to add a node "Courses" between the nodes "Project" and its children, without modifying the model ? What changes to make to the content provider? – rayobanon Sep 13 '19 at 17:33
  • 1
    The content provider is responsible for the displayed structure of the tree. So you must make the provider return some sort of 'courses' object as a child of the project with the individual courses as children of the 'courses' object. – greg-449 Sep 13 '19 at 20:05
  • As you first thought, you'd introduce a dummy node that exists only for the representation in the tree. – nitind Sep 14 '19 at 13:32
  • Thanks @greg-449. I could introduce a dummy node by following your advice. – rayobanon Sep 16 '19 at 07:47

0 Answers0