Bug 468004 - Insert viewpart below detached viewpart
Summary: Insert viewpart below detached viewpart
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: usability
Depends on:
Blocks:
 
Reported: 2015-05-22 08:03 EDT by Koen Staal CLA
Modified: 2020-06-28 07:00 EDT (History)
2 users (show)

See Also:


Attachments
small project to reproduce (7.28 KB, application/octet-stream)
2015-05-22 09:18 EDT, Koen Staal CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Koen Staal CLA 2015-05-22 08:03:17 EDT
from https://www.eclipse.org/forums/index.php/t/1066207/
Nullpointerexception when running this code:

EModelService s = (EModelService) getSite()					.getService(EModelService.class);
									IViewPart topView = getSite()											.getPage()											.showView(PooslConstants.ID_POOSL_PETVIEW,										thread.getName(),												IWorkbenchPage.VIEW_VISIBLE);
									IViewPart botView = getSite()											.getPage()											.showView(PooslConstants.ID_POOSL_VARIABLESVIEW,													thread.getName(),													IWorkbenchPage.VIEW_VISIBLE);

MPart topPart = (MPart) topView.getSite().getService(MPart.class);
MPart botPart = (MPart) botView.getSite().getService(MPart.class);

									s.detach(topPart, 100, 100, 300, 300);								s.insert(botPart, topPart,EModelService.BELOW, 0.5f);

results in a nullpionterExceptions
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.combine(ModelServiceImpl.java:561)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.insert(ModelServiceImpl.java:597)
	at nl.esi.poosl.rotalumisclient.views.PooslDebugView$4$1.widgetSelected(PooslDebugView.java:517)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 1 Nobody - feel free to take it CLA 2015-05-22 08:10:48 EDT
Can you add a small project to reproduce?
Comment 2 Koen Staal CLA 2015-05-22 09:18:11 EDT
Created attachment 253679 [details]
small project to reproduce

small project to reproduce.
Run as Eclipse Application
Show View -> Testviews -> Main View
Click Button "Detach & Insert"
Comment 3 Koen Staal CLA 2015-07-03 07:52:23 EDT
Is there any development yet? I would like to make my implementation but because of the bug i simply cant.
Comment 4 Koen Staal CLA 2015-07-17 04:19:29 EDT
i got my solution by not using EmodelService#detach and Emodelservice#insert, but i reused some code that i found there. I think the problem  is that the emodelservice#detach creates a window with a simple setup, too simple for emodelservice#insert to work.

[code]	private void createCombinedWindow() throws PartInitException {

		EModelService service = (EModelService) getSite().getService(EModelService.class);
		Random random = new Random();
		String tempRandomSecondID = String.valueOf(random.nextInt(10000));

		IViewPart topView = getSite().getPage().showView("testbugproject.topview", tempRandomSecondID,
				IWorkbenchPage.VIEW_VISIBLE);
		IViewPart botView = getSite().getPage().showView("testbugproject.botview", tempRandomSecondID,
				IWorkbenchPage.VIEW_VISIBLE);
		MPart topPart = (MPart) topView.getSite().getService(MPart.class);
		MPart botPart = (MPart) botView.getSite().getService(MPart.class);
	
		MWindow window = service.getTopLevelWindowFor(topPart);
		MPerspective thePersp = service.getPerspectiveFor(topPart);

		MWindowElement container = wrapElementsInContainer(service, topPart, botPart);
		MTrimmedWindow newWindow = createNewWindow(service);
		newWindow.getChildren().add(container);

		if (thePersp != null) {
			thePersp.getWindows().add(newWindow);
		} else if (window != null) {
			window.getWindows().add(newWindow);
		}
	}
	
	private MWindowElement wrapElementsInContainer(EModelService service, MPartSashContainerElement top,
			MPartSashContainerElement bot) {
		if (top.getCurSharedRef() != null) {
			top = top.getCurSharedRef();
		}
		if (bot.getCurSharedRef() != null) {
			bot = bot.getCurSharedRef();
		}

		MPartSashContainer sashcontainer = service.createModelElement(MPartSashContainer.class);
		top.getParent().getChildren().remove(top);
		bot.getParent().getChildren().remove(bot);
		MPartStack newTop = wrapElementForWindow(service, top);
		MPartStack newBot = wrapElementForWindow(service, bot);
		newTop.setContainerData("5000");
		newBot.setContainerData("5000");
		sashcontainer.setHorizontal(false);
		sashcontainer.getChildren().add(newTop);
		sashcontainer.getChildren().add(newBot);
		return sashcontainer;

	}

	private MTrimmedWindow createNewWindow(EModelService service) {
		MTrimmedWindow newWindow = service.createModelElement(MTrimmedWindow.class);
		newWindow.setX(100);
		newWindow.setY(100);
		newWindow.setWidth(300);
		newWindow.setHeight(300);
		return newWindow;
	}[/code]
Comment 5 Eclipse Genie CLA 2020-06-28 07:00:08 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.