final Label lbl = new Label(shell, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
lbl.setLayoutData(gd);
final TimerTask task = new TimerTask() {
String lastText = "";
public String formatString() {
return "FP:\n" + dlData.sExplainFP + "\n" + "SR:" + dlData.sExplainSR
+ "\n" + "TRACE:\n" + dlData.sTrace;
}
public void setText(final String s) {
lastText = s;
txtFP.setText(s);
}
public void run() {
if (shell.isDisposed())
return;
shell.getDisplay().syncExec(new Runnable() {
public void run() {
if (shell.isDisposed()) {
return;
}
String s = formatString();
if (s.compareTo(lastText) != 0) {
if (lastText.length() == 0 || btnAutoRefresh.getSelection()
|| btnRefresh.getData("Pressing") != null)
setText(s);
else
lbl.setText("Information is outdated. Press refresh.");
} else {
lbl.setText("");
}
}
});
}
};
btnAutoRefresh.addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if (btnAutoRefresh.getSelection())
lbl.setText("");
task.run();
}
});
btnRefresh.addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
btnRefresh.setData("Pressing", "1");
task.run();
btnRefresh.setData("Pressing", null);
}
});
shell.addTraverseListener(new TraverseListener() {