Ismail Sen
Ismail Sen

Reputation: 581

Remove SWT TableEditor

I'm facing an issue with Java swt. In my RCP application I run a thread that clear a table every time I start it so it could display again elements from a list. The new list has been updated.

The problem is when I run the thread, uploadInformationTab.removeAll() or uploadInformationtab.clearAll()remove|clear all the items except the items where I've seted TableEditor progressBarEditor=new TableEditor(uploadInformationTab)and TableEditor checkBoxEditor=new TableEditor(uploadInformationTab).

I can't find a solution to this issue.

I hope that my question is clear enough.

Upvotes: 2

Views: 1895

Answers (1)

greg-449
greg-449

Reputation: 111142

You probably need to dispose of any editor you have set when you set the new values in the table. Something like:

Control oldEditor = progressBarEditor.getEditor();
if (oldEditor != null) oldEditor.dispose();

oldEditor = checkBoxEditor.getEditor();
if (oldEditor != null) oldEditor.dispose();

Note: If this is an Eclipse RCP you could use the JFace TableViewer and EditingSupport which are a lot easier to use.

Update:

Table.clearAll() just clears the text and icons from all the rows in the table. It leaves the number of rows unchanged. Table.removeAll() sets the table to be empty, completely deleting all existing rows.

Upvotes: 3

Related Questions