As it is SWTException, I used the syncExec method , but even I could not ressolve the SWTException issue from my code. Please suggest.
public class SampleSwtAction implements IWorkbenchWindowActionDelegate {
开发者_如何学JAVAprivate IWorkbenchWindow window;
public SampleSwtAction() {
}
public void run(IAction action) {
MessageDialog.openInformation(
window.getShell(),
"SampleSwt",
"Hello,Run swt application");
window.getShell().getDisplay().syncExec(
new Runnable() {
public void run(){
Display firstDisplay = new Display();
Shell firstShell = new Shell(firstDisplay);
firstShell.setText("Sample SWT application");
firstShell.setSize(200,100);
firstShell.open ();
while (!firstShell.isDisposed()) {
if (!firstDisplay.readAndDispatch())
firstDisplay.sleep ();
}
firstDisplay.dispose ();
}
});
}
public void selectionChanged(IAction action, ISelection selection) {
}
public void dispose() {
}
public void init(IWorkbenchWindow window) {
this.window = window;
}
}
Just a guess, but you define a new Display
'firstDisplay
' within your Runnable
.
Shouldn't' you also put a syncExec(Runable)
for all actions (updating the UI) you are taking on that display?
Actually, the OP Abhishek Choudhary reports he doesn't need the extra display 'firstDisplay
' and performs all he need to do within the single syncExec(Runable)
, with the default Display
.
精彩评论