You might want to disable redrawing when updating the viewer.
Viewer.getControl().setRedraw(false);
Viewer.getControl().setRedraw(true);
Sometimes this can give a better user interface. You can also schedule a ui task that you cancel when the user clicks on a new key or changes the text. For instance.
class RefreshJob extends WorkbenchJob
{
public RefreshJob()
{
super("Refresh Job");
setSystem(true);
}
public IStatus runInUIThread(IProgressMonitor monitor)
{
monitor.beginTask("Refreshing", ProgressMonitor.UNKNOWN);
m_viewer.refresh();
monitor.done();
return Status.OK_STATUS;
};
}
and then reschedule the update in a separate task.
private RefreshJob m_refreshJob = new RefreshJob();
private Text m_filterText;
void hookModifyListener()
{
m_filterText.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
m_refreshJob.cancel();
m_refreshJob.schedule(500);
}
});
}
If the user presses the Enter key, you can schedule the update task without delay,
source
share