// Something is wrong, there should be at least
// one workbench window open by now.
return;
}
IWorkbenchWindow win = window;
if (perspectiveId != null) {
try {
win = getWorkbench().openWorkbenchWindow(perspectiveId,
wbAdvisor.getDefaultPageInput());
if (win == null) {
win = window;
}
} catch (WorkbenchException e) {
IDEWorkbenchPlugin
.log(
"Error opening window with welcome perspective.", e.getStatus()); //$NON-NLS-1$
return;
}
}
if (win == null) {
win = getWorkbench().getWorkbenchWindows()[0];
}
IWorkbenchPage page = win.getActivePage();
String id = perspectiveId;
if (id == null) {
id = getWorkbench().getPerspectiveRegistry()
.getDefaultPerspective();
}
if (page == null) {
try {
page = win.openPage(id, wbAdvisor.getDefaultPageInput());
} catch (WorkbenchException e) {
ErrorDialog.openError(win.getShell(),
IDEWorkbenchMessages.Problems_Opening_Page, e
.getMessage(), e.getStatus());
}
}
if (page == null) {
return;
}
if (page.getPerspective() == null) {
try {
page = getWorkbench().showPerspective(id, win);
} catch (WorkbenchException e) {
ErrorDialog
.openError(
win.getShell(),
IDEWorkbenchMessages.Workbench_openEditorErrorDialogTitle,
IDEWorkbenchMessages.Workbench_openEditorErrorDialogMessage,
e.getStatus());
return;
}
}
page.setEditorAreaVisible(true);
// see if we already have an editor
IEditorPart editor = page.findEditor(input);
if (editor != null) {
page.activate(editor);
return;
}
try {
page.openEditor(input, WELCOME_EDITOR_ID);
} catch (PartInitException e) {
ErrorDialog
.openError(
win.getShell(),
IDEWorkbenchMessages.Workbench_openEditorErrorDialogTitle,
IDEWorkbenchMessages.Workbench_openEditorErrorDialogMessage,
e.getStatus());
}
return;