Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Tables And Trees And NativeControls

Revision as of 07:22, 15 June 2007 by Tom.schindl.bestsolution.at (Talk | contribs) (New page: == The Problem == People often face the problem that they want to show native controls into Tables and Trees. Common use cases are: * CheckBox-Widget in column other than the first 1 * R...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Problem

People often face the problem that they want to show native controls into Tables and Trees.

Common use cases are:

  • CheckBox-Widget in column other than the first 1
  • Radio-Boxes, Buttons

The Solutions to the problem

SWT: Place SWT-Controls into the Tree/Table-Widget Snippet

This solution has the draw-back to that you'll allocate a resource for every cell you'll display this control in even if the row is not shown because SWT doesn't inform you which controls are in/out of your view-area. For discussion and a possible solution take a look at this Blog-Entry. Another problem is that this is doesn't play nice with JFace which doesn't provide a way to show native-controls in TreeViewer/TableViewer (see JFace-Feature-Request). To summerize this is not a very good solution because it suffers from the problem of extremely many resources

SWT: Use Images instead of Widgets

This solution is fairly straight forward if you provide Images instead of Native-Widgets you'll only have to allocate the image once and reuse it everywhere. This way your resource allocation count is very low and table/tree performance is much better. Many people have not used this possibility because they thought that this would break the platform L&F which was one of things they abandoned Swing and switched to SWT. But this limitation can be overcome fairly easy by caputuring a Screen-Shot from the Control on the fly and presenting it. So the Widget looks as native as possible (without the hover-effects currently). The solution is presented in this Blog-Entry. Another advantage is that this plays nicely with the JFace-Viewer-Framework.

SWT: Use Owner Draw

Since 3.2 you can but your Table/Tree into OwnerDraw mode and draw the cell contents yourself. This way you can draw a faked button, ... in any control. Since 3.3 JFace provides API to easily use OwnerDraw in combination with LabelProviders. For more information on Owner Draw please refer to this Aritcle and JFace Snippets

Nebula: Use CompositeTable

The nebula project contains a control who mimics a Table using native widgets and to try to bring the resource allocation count down to a useable number it reuses controls and only holds these ones currently shown. For more detailed information and status of this widget please ask at the nebula-newsgroup (search the newsgroup and nebula-dev-mailing list about known limitations and possible work-arounds). A known draw back currently is that CompositeTable doesn't provide a JFace-Viewer-API. Examples can be found here

Nebula: Use Grid

The Grid-Control is also custom drawn and you can even customize it by deploying your own renders (besides that it has many other cool features not part of SWT-Tree/SWT-Table). When using 3.3 you even have the possibility to use JFace-Viewers. For more information and status please ask at the nebula-newsgroup. For examples can be found here and here. Checkboxes in arbitary columns are supported out of the box.

Back to the top