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
IPerspectiveDescriptor descriptor = dialog.getSelection();
		if (descriptor != null) {
			MPerspective persp = getPerspectiveFor(descriptor);
			if (persp != null) {
				if (!persp.isToBeRendered())
					persp.setToBeRendered(true);
				persp.getParent().setSelectedElement(persp);
			} else {
				openPerspective((PerspectiveDescriptor) descriptor);
			}
		}
	}
	private void openMenuFor(ToolItem item, MPerspective persp) {
		final Menu menu = new Menu(psTB);
		menu.setData(persp);
		if (persp.isVisible()) {
			addCloseItem(menu);
		}
		if (persp.getParent().getSelectedElement() == persp) {
			addResetItem(menu);
		}
		new MenuItem(menu, SWT.SEPARATOR);
		
		addShowTextItem(menu);
		Rectangle bounds = item.getBounds();
		Point point = psTB.toDisplay(bounds.x, bounds.y + bounds.height);
		menu.setLocation(point.x, point.y);
		menu.setVisible(true);
		menu.addMenuListener(new MenuListener() {
			public void menuHidden(MenuEvent e) {