Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » JavaFX + GEF5 + E4 RCP. EventHandling(Continuing previous topic, now to the EventHandle)  () 1 Vote
JavaFX + GEF5 + E4 RCP. EventHandling [message #1766880] Wed, 28 June 2017 13:40 Go to next message
Mike Shimko is currently offline Mike ShimkoFriend
Messages: 9
Registered: May 2017
Location: Moscow
Junior Member
Continuing my application started at msg #1764188
As you know my application consists with 2 parts, input and output part.
I've successfully implemented GEF5 view in my output part. Now the task is
to show sentence typed in the input part as a GEF graph.
For this i've created button in input part,after pressing the button the sentence should be displayed as a graph in output part.

So the user should type in his sentence.
The trouble is when i launch the application and try to type anything i got following Exception:
java.lang.NullPointerException
	at org.eclipse.gef.mvc.fx.gestures.DefaultHandlerResolver.resolve(DefaultHandlerResolver.java:65)
	at org.eclipse.gef.mvc.fx.gestures.TypeStrokeGesture$4.handle(TypeStrokeGesture.java:244)
	at org.eclipse.gef.mvc.fx.gestures.TypeStrokeGesture$4.handle(TypeStrokeGesture.java:1)
	at com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:282)
	at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
	at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:223)
	at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Scene$KeyHandler.process(Scene.java:3964)
	at javafx.scene.Scene$KeyHandler.access$1800(Scene.java:3910)
	at javafx.scene.Scene.impl_processKeyEvent(Scene.java:2040)
	at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2501)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:216)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:148)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$353(GlassViewEventHandler.java:247)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:246)
	at com.sun.glass.ui.View.handleKeyEvent(View.java:546)
	at com.sun.glass.ui.View.notifyKey(View.java:966)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
	at java.lang.Thread.run(Thread.java:745)


It someshow refers to the typestroke gesture, but in other (output part) pane.
So that means that both listeners is active,and one of them is generating exception each time i press a button.

Is there any way to turn it off?

[Updated on: Wed, 28 June 2017 13:42]

Report message to a moderator

Re: JavaFX + GEF5 + E4 RCP. EventHandling [message #1766886 is a reply to message #1766880] Wed, 28 June 2017 14:38 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi Mike,

the scenario is as follows: TypeStrokeGesture registers an event filter for keyboard events on the JavaFX Scene. When any keyboard event occurs, the gesture determines the viewer that is responsible for handling the event (based on the event target), and delegates to the IHandlerResolver to determine the handlers that will process the event. However, for target nodes that are not controlled by an IViewer, null is passed to the IHandlerResolver as the IViewer. The DefaultHandlerResolver does not check if the passed-in IViewer is null, but uses it to access the domain. This is where the NullPointerException is thrown.

In order to work around the issue, you can exchange the IHandlerResolver implementation, and only pass the arguments to super.resolve() if the given IViewer is not null. On the GEF side, we can fix the TypeStrokeGesture, i.e. only delegate to the handler resolver if an IViewer could be determined for the event. I created a Bugzilla for the issue [1].

If you encounter problems with the workaround, or the behavior (response to keyboard events) does not meet your needs or expectations, please share your findings here, or directly at the Bugzilla.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=518893

Best regards,
Matthias
Re: JavaFX + GEF5 + E4 RCP. EventHandling [message #1766902 is a reply to message #1766886] Wed, 28 June 2017 16:09 Go to previous messageGo to next message
Mike Shimko is currently offline Mike ShimkoFriend
Messages: 9
Registered: May 2017
Location: Moscow
Junior Member
Matthias Wienand wrote on Wed, 28 June 2017 14:38

...
you can exchange the IHandlerResolver implementation, and only pass the arguments to super.resolve() if the given IViewer is not null.
...


I got no idea where to start.Could you explain your idea simplier ? Or with the line of code?
Re: JavaFX + GEF5 + E4 RCP. EventHandling [message #1766908 is a reply to message #1766902] Wed, 28 June 2017 16:45 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
In order to exchange the IHandlerResolver, you need to subclass DefaultHandlerResolver, as follows:
public class CustomHandlerResolver extends DefaultHandlerResolver {
    @Override
    public <T extends IHandler> List<? extends T> resolve(IGesture gesture, Node target, IViewer viewer,
            Class<T> handlerType) {
        if (viewer == null) {
            return Collections.emptyList();
        }
        return super.resolve(gesture, target, viewer, handlerType);
    }
}


Secondly, you need to adjust the bindings in the module, as follows:
public class CustomModule extends MvcFxModule {
    // ...
    @Override
    protected void bindIHandlerResolver() {
        binder().bind(IHandlerResolver.class).to(CustomHandlerResolver.class);
    }
}


That should do the trick. Currently, I cannot try this out, so you need to experiment with it to find out if it is a sufficient workaround.

Best regards,
Matthias
Re: JavaFX + GEF5 + E4 RCP. EventHandling [message #1766918 is a reply to message #1766908] Wed, 28 June 2017 17:26 Go to previous messageGo to next message
Mike Shimko is currently offline Mike ShimkoFriend
Messages: 9
Registered: May 2017
Location: Moscow
Junior Member
Thank you!
I will look into the problem
Re: JavaFX + GEF5 + E4 RCP. EventHandling [message #1767085 is a reply to message #1766908] Fri, 30 June 2017 13:48 Go to previous message
Mike Shimko is currently offline Mike ShimkoFriend
Messages: 9
Registered: May 2017
Location: Moscow
Junior Member
It worked!
I've created 2 additional classes as you suggested.
Copied ZestFXmodule into my CustomModule and added your method bindIHandlerResolver().

Previous Topic:GEF5 Node building
Next Topic:[GEF5] Oxygen target won't load
Goto Forum:
  


Current Time: Thu Apr 18 09:07:56 GMT 2024

Powered by FUDForum. Page generated in 0.02127 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top