I'm a newer in SWT and JFace, recently, I used JFace tableviewer in my project. And I need to delete items by a delete button. But it doesn't work if i refresh the tableviewer after deleting it. I want to know the reason.My code shows below:
btnDeleteConstraint.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ISelection selection = tableViewer.getSelection();
logger.debug("datatype selected");
if (selection != null || selection instanceof
IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection;
Iterator iterator = sel.iterator();
while(iterator.hasNext()) {
Object obj = iterator.next();
tableViewer.remove(obj);
}
tableViewer.refresh();
}
}
});
And i use another method called update() to set input and refresh the table in the end:
public void update()
{
tableViewer.setInput(DataTypeFactory.
getInstance().getCastList(wizard.getSourceInfo().getDBType()));
tableViewer.refresh();
}