Refresh SWT elements periodicaly

To refresh elements in a SWT Widget is quite easy. You don’t need to use display.syncExec(). Just use the display.timerExec() method recoursivly. Here is a simple codesnip for refreshing a TreeView:

The createPartControl Method of your ViewPart class
(or any other startup method of the control) :

public void createPartControl(Composite parent) {
  ... init the control

  //start refresh
  refresh(parent.getDisplay());
}

The refresh method:
private void refresh(Display display){
  display.timerExec(ddtsPollDelay,new Runnable() {
     public void run() {
        ... update code ...

        //recursive call
        refreshTree();
     }
  });
}

SWT is nice and easy…

HotFix for: Unhandled event loop exception in MyEclipse 6.0

These days i got an “Unhandled event loop exception” in MyEclipse, which made me unable to work because a PopUp was shown every minute. The complete exception:

Caused by: java.lang.IllegalArgumentException:
Argument cannot be null
at org.eclipse.swt.SWT.error(SWT.java:3547)
at org.eclipse.swt.SWT.error(SWT.java:3481)
at org.eclipse.swt.SWT.error(SWT.java:3452)
at org.eclipse.swt.widgets.Widget.error(Widget.java:432)
at org.eclipse.swt.widgets.Link.setText(Link.java:571)
at org.eclipse.ui.internal.progress.ProgressInfoItem.
updateText(ProgressInfoItem.java:773)
at org.eclipse.ui.internal.progress.ProgressInfoItem.
setLinkText(ProgressInfoItem.java:759)
at org.eclipse.ui.internal.progress.ProgressInfoItem.
refresh(ProgressInfoItem.java:530)
at org.eclipse.ui.internal.progress.ProgressInfoItem.
setDisplayed(ProgressInfoItem.java:902)
at org.eclipse.ui.internal.progress.ProgressInfoItem.
setDisplayed(ProgressInfoItem.java:888)

shows that the reason is a given null argument in setText(). The Problem is disscused in the MyEclipse forum but there is no actual fix.

For this reason my colleague Thomas and me patched the class. To fix the bug just change the jar located under: [MyEclipseHome]
\eclipse\plugins\org.eclipse.swt.win32.win32.x86_3.3.0.v3346.jar with our patched version.