Bug 313328 Close parts under part stacks with middle mouse click
bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
}
		
		if (parentElement.getSelectedElement() == child) {
			if (ctf.getTopRight() != null) {
				Control curTB = ctf.getTopRight();
				ctf.setTopRight(null);
				if (!curTB.isDisposed()) {
					MUIElement tbME = (MUIElement) curTB
							.getData(AbstractPartRenderer.OWNING_ME);
					if (tbME instanceof MRenderedToolBar)
						renderer.removeGui(tbME);
					else
						curTB.dispose();
				}
			}
			
			
			MUIElement defaultSel = getFirstVisibleElement(parentElement);
			parentElement.setSelectedElement(defaultSel);
		}
	}
	private MUIElement getFirstVisibleElement(
			MElementContainer<MUIElement> stack) {
		
		for (MUIElement mPart : stack.getChildren()) {
			if (mPart.isToBeRendered())
				return mPart;
		}
		return null;
	}