Bug 331062 NPE with EModelService's getElementLocation(MUIElement) on a model within a perspective that's not under the application
java.lang.NullPointerException at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.getElementLocation(ModelServiceImpl.java:740)
bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
public void detach(MPartSashContainerElement element, int x, int y, int width, int height) {
		
		MUIElement curParent = element.getParent();
		while (curParent != null && !(curParent instanceof MPerspective)
				&& !(curParent instanceof MWindow))
			curParent = curParent.getParent();
		if (curParent == null)
			return; 
		MTrimmedWindow newWindow = BasicFactoryImpl.INSTANCE.createTrimmedWindow();
		
		newWindow.setX(x);
		newWindow.setY(y);
		newWindow.setWidth(width);
		newWindow.setHeight(height);
		element.getParent().getChildren().remove(element);
		MWindowElement uiRoot = wrapElementForWindow(element);
		newWindow.getChildren().add(uiRoot);
		if (curParent instanceof MPerspective) {
			MPerspective persp = (MPerspective) curParent;
			persp.getWindows().add(newWindow);
			MWindow window = getTopLevelWindowFor(persp);
			IPresentationEngine renderingEngine = persp.getContext().get(IPresentationEngine.class);
			renderingEngine.createGui(newWindow, window.getWidget(), persp.getContext());
		} else if (curParent instanceof MWindow) {
			((MWindow) curParent).getWindows().add(newWindow);
		}
	}
	/**
	 * @param element
	 * @return