3

I want to completely hide the 1st column in TreeViewer. If I hide it with setWidth(0) then the next visible column gets triangles and paddings. The most silly way is to dispose TreeViewer and create TableViewer every time when 1st column is hidden. Is there any reliable way to solve this?

Edited. Illustration:

demonstration

  1. The original table with id and label columns
  2. The table with hidden id column. Width is 1px. Dotted separator is very ugly.
  3. The table with hidden id column. Width is 0px. Now 2nd column has reformatted elements.

PS I may successful hide 1st id column with mouse at runtime (no dotted separator and 2nd column look the same). But how do this by code? I tied to read JFace source code, but didn't find any useful public methods.

Ezhik
  • 876
  • 6
  • 23
  • What do you mean with "_gets triangles and paddings_"? Can you maybe add a screenshot? – Baz Mar 03 '13 at 10:48
  • Interesting problem. Can you tell us why you want to do this and not _just_ use a `TableViewer` with custom `IContentProvider`? – Tonny Madsen Mar 03 '13 at 12:36
  • 1
    Hmm. The 1st column is tree. Do you want that I re implement tree logic for the 1st column with `TableViewer`? User may hide/unhide the 1st column at any time. – Ezhik Mar 03 '13 at 12:52
  • Hi! I think the catch is that the triangles and paddings are not part of the "First column" perse, they belong to the entire item (Row) that is the root of a sub system, what I mean is, if you implement a Tree that alows columns toi be moved and rearranged, the Triangles and Indentation does not move with the First column as you move it, they always stay at the left most part of the tree, so, I think what you are trying to do is impossible... You should try to use a table and implement the functionality yourself... – Mostafa Zeinali Dec 18 '13 at 09:38
  • Thank you. Yes, I did as you say. Such design is crude for me and I want to find a better solution. – Ezhik Dec 18 '13 at 16:20

1 Answers1

0

You have to handle this in your implementation of ITreeContentProvider, in your getElements() your should not return the root element, instead you return its children. in the getParent() your should return null for the root.

unique_ptr
  • 586
  • 1
  • 8
  • 22