Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Cannot Edit cells of table using TableViewerColumn.setEditingSupport(Not Able the edit cells of the table)
Cannot Edit cells of table using TableViewerColumn.setEditingSupport [message #1752126] Thu, 19 January 2017 05:13 Go to next message
Kallol Ghose is currently offline Kallol GhoseFriend
Messages: 3
Registered: January 2017
Junior Member

I m trying to edit my table cell using TextCellEditor but the extended function of EditingSupport are not getting called -

My code is as follows -

//Creation of tableviewer and the columns
TableViewer testscriptsViewer = new TableViewer(script_composite, SWT.BORDER | SWT.FULL_SELECTION);
testscriptTable = testscriptsViewer.getTable();
testscriptTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

TableViewerColumn snoViewer = new TableViewerColumn(testscriptsViewer, SWT.NONE);
TableColumn snoCol = snoViewer.getColumn();

TableViewerColumn oprViewer = new TableViewerColumn(testscriptsViewer, SWT.NONE);
TableColumn operationCol = oprViewer.getColumn();
oprViewer.setEditingSupport(new TableColumnsEditable(testscriptsViewer));

TableViewerColumn pgViewer = new TableViewerColumn(testscriptsViewer, SWT.NONE);
TableColumn pageNameCol = pgViewer.getColumn();
pageNameCol.setText("Page Name");
pgViewer.setEditingSupport(new TableColumnsEditable(testscriptsViewer));

TableViewerColumn objViewer = new TableViewerColumn(testscriptsViewer, SWT.NONE);
TableColumn objCol = objViewer.getColumn();
objCol.setText("Object Name");
objViewer.setEditingSupport(new TableColumnsEditable(testscriptsViewer));

TableViewerColumn argColViewer = new TableViewerColumn(testscriptsViewer, SWT.NONE);
TableColumn argCol = argColViewer.getColumn();
argColViewer.setEditingSupport(new TableColumnsEditable(testscriptsViewer));

TableViewerColumn varColViewer = new TableViewerColumn(testscriptsViewer, SWT.NONE);
TableColumn varNameCol = varColViewer.getColumn();
varNameCol.setText("Variable Name");
varColViewer.setEditingSupport(new TableColumnsEditable(testscriptsViewer));

//Editing Support Class

public class TableColumnsEditable extends EditingSupport
private TableViewer tableViewer = null;
private CellEditor editor = null;

public TableColumnsEditable(TableViewer viewer) {
// TODO Auto-generated constructor stub
this.tableViewer = viewer;
editor = new TextCellEditor(tableViewer.getTable());

protected CellEditor getCellEditor(Object element) {
// TODO Auto-generated method stub
return editor;

protected boolean canEdit(Object element) {
// TODO Auto-generated method stub
return true;

protected Object getValue(Object element) {
// TODO Auto-generated method stub
return element.toString();

protected void setValue(Object element, Object value) {
// TODO Auto-generated method stub
element = value;
getViewer().update(value, null);


Please make this work


Re: Cannot Edit cells of table using TableViewerColumn.setEditingSupport [message #1752202 is a reply to message #1752126] Thu, 19 January 2017 20:50 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

Your setValue() method does nothing: you need to change the content of `element`. And `update()` takes the object to show, not the new content that's being set.
protected void setValue(Object element, Object value) {
// TODO Auto-generated method stub
element = value;  // <--- this needs to do something like "element.setText((String)value))"
getViewer().update(value, null);

Take a look at the JFace example.
Previous Topic:Global Key Listener
Next Topic:Where is Neon update site for SWT GTK plugin
Goto Forum:

Current Time: Fri Apr 23 15:23:51 GMT 2021

Powered by FUDForum. Page generated in 0.01511 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top