afghg
afghg

Reputation: 33

Same child, different parents in a TreeViewer

I have a JFace TreeViewer where the structure is such that a child can have several parents.

When selecting a child in the viewer, I want to get the parent of that selection.

Example, with the following structure:

- parent1
    - child
- parent2
    - child

When the bottom row is selected, I want to retrieve parent2, but child.getParent() only gives me the first occurrence of a parent, and does not take which branch I selected in the tree.

Upvotes: 0

Views: 74

Answers (2)

Shashwat
Shashwat

Reputation: 2352

Create one marker interface and make all root to implement that interface and on run time add different root model.

Upvotes: 3

greg-449
greg-449

Reputation: 111142

The Tree Viewer model doesn't support this.

You will have to add additional methods to your content provider class to return the additional parents.

Upvotes: 1

Related Questions