Validate tableviewer row and display error

167 Views Asked by At

I have a editing supported tableviewer with two columns. If the text in my first column doesn't match the regex pattern specified, an error mark should be specified in the row denoting the validation error.

I tried using CellEditor but using this error mark could only be displayed in the current row selected. I want all the rows to be marked with an error mark if it fails the validation that I do in the isValid() method of ICellEditorValidator.

1

There are 1 best solutions below

3
greg-449 On

You could use the getImage method of your ColumnLabelProvider to return a suitable error image.

Since the label provider only has easy access to the content provider element for the row it would be simplest to have the cell editor set an error flag on the element that the label provider can test.

The cell editor should call the table viewer update(element, null) method when it changes the flag value to get the viewer to update the row.