}
ConnectorServletHelper.setBaseDir(sourceEditor.getFile().getParent());
try {
final Display display = Display.getCurrent();
final ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(getSite().getShell());
final IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
monitor.beginTask(WYSIWYGPlugin.getResourceString("editor.task.init_wysiwyg"), 10);
WYSIWYGPlugin.getDefault().startWebServer(monitor, 9);
monitor.subTask(WYSIWYGPlugin.getResourceString("editor.subtask.waiting_init"));
display.asyncExec(new Runnable() {
public void run() {
monitorDialog.setCancelable(true);
browser.setUrl(WYSIWYGPlugin.getDefault().getEditorURL());
}
});
monitorDialog.setCancelable(true);
while (!isBrowserLoaded() && !monitor.isCanceled()) {
Thread.sleep(1000);
}
monitor.worked(1);
display.asyncExec(new Runnable() {
public void run() {
setActivePage(0);
}
});
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
};
display.asyncExec(new Runnable() {
public void run() {
try {
monitorDialog.run(true, false, runnable);
} catch (InvocationTargetException e) {
DesignerLogger.logError(WYSIWYGPlugin.getResourceString("wysiwyg.design.create_error"), e.getTargetException());
} catch (InterruptedException e) {
WYSIWYGPlugin.logError("Web editor page", e);
}