Skip to content
Advertisement

How can I create a checkbox in a TableViewer of JFace?

I have created a tableViewer with two columns and I want to make one of them a checkbox. To do that I have created a CheckBoxCellEditor, but I don´t know why it isn´t working.

The column called tableName displays it´s values OK.

The column specification is the following.

JavaScript

And the EditingSupport is the following:

JavaScript

The TableMetaData object decides if the Checkbox is going to be selected or not. How can I fix my code in order to make it work?

Thank you.

Advertisement

Answer

To make it work I used Vogella´s solution using images. The problem is that the images can´t be centered in the table´s cell and they appear in the left of them. I have tried to use “X” and “-“, but I don´t know what happens with the first column that it neither centers the text. So to fix that problem I have changed column´s order and I have used unicode characters.

The solution code is the following for editing support:

JavaScript

And the following to create the columns:

JavaScript

Solution Image

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement