Bug 309698 Disposing parent context does not cause objects injected by a child context to be destroyed
The test below fails. static class Target { int pc = 0; int pd = 0; @Inject @Named("o") Object o; @PostConstruct void pc() { pc++; } @PreDestroy void pd() { pd++; } } public void testV() { IEclipseContext context = EclipseContextFactory.create(); IEclipseContext child = EclipseContextFactory.create(context, null); child.set("o", new Object()); Target target = (Target) ContextInjectionFactory.make(Target.class, child); assertEquals(1, target.pc); ((IDisposable) context).dispose(); assertEquals(1, target.pd); }
bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/workbench/ui/renderers/swt/SWTPartRenderer.java
*/
	protected int calcVisibleIndex(MUIElement element) {
		MElementContainer<MUIElement> parent = element.getParent();
		int curIndex = 0;
		for (MUIElement child : parent.getChildren()) {
			if (child == element) {
				return curIndex;
			}
			if (child.getWidget() != null)
				curIndex++;
		}
		return -1;
	}
	/*
	 * HACK: Create a wrapper composite with appropriate layout for the purpose
	 * of styling margins. See bug #280632
	 */
	protected Composite createWrapperForStyling(Composite parentWidget,
			IEclipseContext context) {
		Composite layoutHolder = new Composite(parentWidget, SWT.NONE);
		addLayoutForStyling(layoutHolder);
		layoutHolder.setData("org.eclipse.e4.ui.css.swt.marginWrapper", true); 
		final IStylingEngine engine = (IStylingEngine) context
				.get(IStylingEngine.SERVICE_NAME);
		engine.setClassname(layoutHolder, "marginWrapper"); 
		return layoutHolder;
	}
	/*
	 * HACK: Add layout information to the composite for the purpose of styling
	 * margins. See bug #280632