if (IPreferenceConstants.OPM_NEW_WINDOW != mode) {
IWorkbenchPage page = win.getActiveWorkbenchPage();
IPerspectiveDescriptor desc = getPerspectiveRegistry()
.findPerspectiveWithId(perspectiveId);
if (desc == null) {
throw new WorkbenchException(
NLS
.bind(
WorkbenchMessages.WorkbenchPage_ErrorCreatingPerspective,
perspectiveId));
}
win.getShell().open();
if (page == null) {
page = win.openPage(perspectiveId, input);
} else {
page.setPerspective(desc);
}
return page;
}
}
// If the specified window has no active perspective, then open the
// requested perspective and show the specified window.
if (win != null) {
IWorkbenchPage page = win.getActiveWorkbenchPage();
IPerspectiveDescriptor persp = null;
if (page != null) {
persp = page.getPerspective();
}
if (persp == null) {
IPerspectiveDescriptor desc = getPerspectiveRegistry()
.findPerspectiveWithId(perspectiveId);
if (desc == null) {
throw new WorkbenchException(
NLS
.bind(
WorkbenchMessages.WorkbenchPage_ErrorCreatingPerspective,
perspectiveId));
}