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
if (psList.size() > 0)
			return psList.get(0);
		return null;
	}
	private ToolItem addPerspectiveItem(MPerspective persp) {
		final ToolItem psItem = new ToolItem(psTB, SWT.RADIO);
		psItem.setData(persp);
		IPerspectiveDescriptor descriptor = getDescriptorFor(persp.getElementId());
		boolean foundImage = false;
		if (descriptor != null) {
			ImageDescriptor desc = descriptor.getImageDescriptor();
			if (desc != null) {
				psItem.setImage(desc.createImage(false));
				foundImage = true;
				psItem.setToolTipText(persp.getLabel());
			}
		}
		if (!foundImage
				|| PrefUtil.getAPIPreferenceStore().getBoolean(
						IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR)) {
			psItem.setText(persp.getLabel());
			psItem.setToolTipText(persp.getTooltip());
		}
		psItem.setSelection(persp == persp.getParent().getSelectedElement());
		psItem.addSelectionListener(new SelectionListener() {
			public void widgetSelected(SelectionEvent e) {
				MPerspective persp = (MPerspective) e.widget.getData();
				persp.getParent().setSelectedElement(persp);
			}
			public void widgetDefaultSelected(SelectionEvent e) {