3

I am developing an application using JFace on Eclipse 3.6 and I would like to have actual widgets - mostly checkboxes and buttons - in a TableViewer. Everything I have found seems to suggest that this is not possible at the moment.

My current workaround involves having a MouseListener for the wrapped Table control, where the mouseDown event coordinates are translated to cells using the getCell() method and acted upon. I then use the content provider to supply images and formatted text that somewhat approach the look of the respective widgets.

The problem is that the result is not native-looking at all. There are some workarounds involving taking screenshots of the actual native widgets, but this has a few problems:

  • It's a hack
  • The captured widgets ocassionally become visible, creating a flickering artifact on the screen
  • It requires image handling tricks to make the captured image blend with the table colours
  • It does not scale well when e.g. buttons with different contents are required

Is there a way to embed widgets in TableViewer cells without using such cumbersome methods? The underlying SWT Table can certainly do that, but the TableViewer interface does not seem to support this...

thkala
  • 76,870
  • 21
  • 145
  • 185

1 Answers1

0

You can use celleditors for this. It is not exactly what you want, as the widgets are only displayed during editing, but I think, it is quite close.

See http://wiki.eclipse.org/JFaceSnippets#Snippet027ComboBoxCellEditors or the other CellEditor examples on the wiki page.

Zoltán Ujhelyi
  • 13,598
  • 2
  • 30
  • 36