0

enter image description here

I need a Java SWT widget that can help me achieve what is shown in box 3. It should have the indentation of a tree but not display the twistie. Have tried NatTable too.. but it doesn't help.

Else, are there any hacks to achieve this?

Divya Dev
  • 125
  • 9
  • So you only want the indentation, but nothing else that the `TreeViewer` gives you over the `TableViewer`? – Baz Aug 24 '16 at 11:55
  • `TreeViewer` has an `updatePlus` method, I guess you could override it achieve what you want. – SomeDude Aug 24 '16 at 12:03
  • 2
    @svasa `updatePlus` only set the expanded / collapsed state, it does not actually draw the twistie - the native control does that. – greg-449 Aug 24 '16 at 12:15
  • In NatTable you can register a tree painter with empty icons as a hack – Dirk Fauth Aug 24 '16 at 12:39
  • @greg-449 you are right, It was just a guess. – SomeDude Aug 24 '16 at 13:16
  • @Baz you are absolutely right. – Divya Dev Aug 24 '16 at 13:47
  • @Dirk I am not allowed to use nebula widgets – Divya Dev Aug 24 '16 at 13:48
  • @greg-449 when you mean the native control, can i do some amendments there? – Divya Dev Aug 24 '16 at 13:49
  • The native control is the tree API used by the particular OS to draw a tree. It is different from each OS, for example on Mac OS X `NSOutlineView` is used, on Linux it will be some GTK API and something else again on Windows. So you could only change this if the native control API supports turning off the twistie and you would have to have a detailed knowledge of the API and SWT for each platform you are interested in. – greg-449 Aug 24 '16 at 13:56
  • Well, apart from using space (highly not allowed), can i indent content in the TableViewer like a treeViewer? – Divya Dev Aug 24 '16 at 14:04

1 Answers1

1

As you are not allowed to use Nebula widgets and the customization of the native widgets below on OS layer is not recommended (it might break with each OS update) the only solution I would see is to use custom drawing. Maybe by painting over the icons.

How to do custom drawing in a table or tree is explained here: https://www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html

Dirk Fauth
  • 4,128
  • 2
  • 13
  • 23