Community
Participate
Working Groups
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)
Can you add a small project to reproduce?
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"
Is there any development yet? I would like to make my implementation but because of the bug i simply cant.
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]
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.