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 changeShowText(boolean showText) {
		ToolItem[] items = psTB.getItems();
		for (int i = 0; i < items.length; i++) {
			MPerspective persp = (MPerspective) items[i].getData();
			if (persp != null)
				if (showText) {
					if (persp.getLabel() != null)
						items[i].setText(persp.getLabel());
					items[i].setToolTipText(persp.getTooltip());
				} else {
					Image image = items[i].getImage();
					if (image != null) {
						items[i].setText("");
						items[i].setToolTipText(persp.getLabel());
					}
				}
		}
		
		psTB.pack();
		psTB.getShell().layout(new Control[] { psTB }, SWT.DEFER);
	}
	private void removePerspectiveItem(MPerspective toRemove) {
		ToolItem psItem = getItemFor(toRemove);
		if (psItem != null) {
			psItem.dispose();
		}
		
		psTB.pack();
		psTB.getShell().layout(new Control[] { psTB }, SWT.DEFER);