Bug 324849 [Compatibility] NPE thrown when trying to close unavailable perspectives
If a perspective cannot be found anymore in their Eclipse installation, they may wish to close it. This is currently not possible. java.lang.NullPointerException at org.eclipse.ui.internal.WorkbenchPage.closePerspective(WorkbenchPage.java:1086) at org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.closePerspective(PerspectiveSwitcher.java:475) at org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.access$6(PerspectiveSwitcher.java:471) at org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher$13.widgetSelected(PerspectiveSwitcher.java:466) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.java
}
	
	
	private void openPerspective(PerspectiveDescriptor desc) {
		IWorkbenchWindow workbenchWindow = window.getContext().get(IWorkbenchWindow.class);
		IWorkbenchPage page = workbenchWindow.getActivePage();
		if (page == null) {
			try {
				
				workbenchWindow.openPage(desc.getId(),
						((Workbench) workbenchWindow.getWorkbench()).getDefaultPageInput());
			} catch (WorkbenchException e) {
				IStatus errorStatus = new Status(
						IStatus.ERROR,
						WorkbenchPlugin.PI_WORKBENCH,
						NLS.bind(WorkbenchMessages.Workbench_showPerspectiveError, desc.getLabel()),
						e);
				StatusManager.getManager().handle(errorStatus, StatusManager.SHOW);
			}
		} else {
			page.setPerspective(desc);
		}
	}
	private void selectPerspective() {
		SelectPerspectiveDialog dialog = new SelectPerspectiveDialog(psTB.getShell(), PlatformUI
				.getWorkbench().getPerspectiveRegistry());
		dialog.open();
		if (dialog.getReturnCode() == Window.CANCEL) {
			return;
		}