Description
Hi, so i closed the previous issue as the main problem was actually resolved and opened this one for the follow-up question. I am really sorry to bother you again but I've been stuck with it for a VERY long time, I do not know at all how to proceed and I really need to make this thing work. So i hope that someone could help me.
When i start an eclipse plugin (part 5 of the tutorial) and try to add a new node, this is what i keep getting:
java.lang.NullPointerException: Cannot invoke "org.eclipse.gef.mvc.fx.parts.IContentPart.getRoot()" because "part" is null
at org.eclipse.gef.mvc.fx.policies.CreationPolicy.createFocusOperation(CreationPolicy.java:217)
at org.eclipse.gef.mvc.fx.policies.CreationPolicy.create(CreationPolicy.java:152)
at org.eclipse.gef.mvc.fx.policies.CreationPolicy.create(CreationPolicy.java:201)
at com.itemis.gef.tutorial.mindmap.policies.CreateNewNodeOnClickHandler.click(CreateNewNodeOnClickHandler.java:85)
at org.eclipse.gef.mvc.fx.gestures.ClickDragGesture.press(ClickDragGesture.java:351)
at org.eclipse.gef.mvc.fx.gestures.ClickDragGesture$1.handle(ClickDragGesture.java:100)
at org.eclipse.gef.mvc.fx.gestures.ClickDragGesture$1.handle(ClickDragGesture.java:1)
at javafx.base@19/com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:321)
at javafx.base@19/com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
at javafx.base@19/com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:221)
at javafx.base@19/com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
at javafx.base@19/com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
at org.eclipse.gef.fx.swt.canvas.FXCanvasEx$EventDispatcherEx.dispatchEvent(FXCanvasEx.java:155)
at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base@19/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base@19/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base@19/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics@19/javafx.scene.Scene$MouseHandler.process(Scene.java:3894)
at javafx.graphics@19/javafx.scene.Scene.processMouseEvent(Scene.java:1887)
at javafx.graphics@19/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2620)
at javafx.graphics@19/com.sun.javafx.tk.quantum.EmbeddedScene.lambda$mouseEvent$4(EmbeddedScene.java:289)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics@19/com.sun.javafx.tk.quantum.EmbeddedScene.lambda$mouseEvent$5(EmbeddedScene.java:282)
at javafx.graphics@19/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics@19/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3643)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
What I figured out till now:
SimpleMindMapApplication
works smoothly in both cases: with an emptySimpleMindMap
at launch AND when usingcreateComplexExample()
to populate a starting mindmap.SimpleMindMapPlugin
fails in both cases mentioned above. Thus, i have a suspicion that the problem is a transition from JavaFX application to Exlipse plugin.- The problem (probably) comes from the following part of code:
addContentChild()
in anAbstractContentPart
class does this operation at the very end:contentChildren.setAll(newContentChildren);
- in case of
SimpleMindMapApplication
after performing this action, new element is also added to thecontentPartMap
(which is a property of theInfiniteCanvasViewer
). in case ofSimpleMindMapPlugin
it DOES NOT happen, thus, new element is not added to thecontentPartMap
. - afterwards
CreationPolicy
class tries to retrieve new element withIContentPart<? extends Node> contentPart = viewer.getContentPartMap().get(content);
. For theSimpleMindMapApplication
it works fine, whileSimpleMindMapPlugin
returns null because an element was not added tocontentPartMap
before. LaterITransactionalOperation focusOperation = createFocusOperation(contentPart);
throws an exception mentioned above because ofcontentPart
being null. However, i cannot add any null check here because it is a library code.
The same happens when trying to create a new connection between nodes: SimpleMindMapApplication
works, SimpleMindMapPlugin
fails.
So the question is: why do they behave differently? I cannot see any place in the plugin code where you have to set some dependencies of the contentPartMap
in the InfiniteCanvasViewer
. Since it works fine for the SimpleMindMapApplication
I do not see any other possible source of error except the SimpleMindMapEditor
.
Does anyone have hints/workarounds/advices for this issue?
UPD: removing nodes fails in plugin too. Is there any specific reason why everything works well for SimpleMindMapApplication
but some stuff fails for SimpleMindMapPlugin
? E.g. incompatibility of newer gef versions with the tutorial code or something similar?
Thank you very much in advance!