Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » GEF4 Add extra visual elements
GEF4 Add extra visual elements [message #1739732] Thu, 04 August 2016 12:13 Go to next message
Vlad Buzea is currently offline Vlad BuzeaFriend
Messages: 7
Registered: August 2016
Junior Member
I'm using the GEF4 Zest JFace library (or bundle) to create an Eclipse RCP application. A lot of the necessary functionality is coverd by the used Policies, but I need to add an extra visual element: VBox (or a Panel) with the graph name and a short description. This is not a graph node, so I have placed it in the Canvas Overlay Group of the ZestContentViewer.

final Group canvasOverlay = ui.getGraphViewer().getFXViewer().getCanvas().getOverlayGroup();
canvasOverlay.getChildren().add(metaPanel);
The method ui.getGraphViewer returns the ZestContentViewer and the metaPanelis the VBox containing the javafx TextFields.

Everything works fine, until I write something in the TextFields. When I press one of the arrow keys, the entire graph displayed is also moved. Similarly, when I drag the metaPanel a rectangular selection is also started. Is there a way to fix this? I'm not sure this is the right place to put the component, but I do not have any other ideas.
Re: GEF4 Add extra visual elements [message #1742641 is a reply to message #1739732] Tue, 06 September 2016 10:01 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 139
Registered: March 2015
Senior Member
Hi,

this is due to the tools registering event filters on the scene, i.e. they will process all events. If no part can be identified as the target for an event, the root part is used as the target part. At the root part, a policy scrolls when arrow keys are pressed and allows marquee selection when the mouse is dragged.

Since an ITargetPolicyResolver is used to determine the policies that should be executed, you can exchange it and return an empty list for the meta panel:

- MvcFxModule#bindITargetPolicyResolver() registers DefaultTargetPolicyResolver for ITargetPolicyResolver. This can be overridden and a CustomTargetPolicyResolver can be used.
- Within the CustomTargetPolicyResolver (extends DefaultTargetPolicyResolver) you can test if the target node is your meta panel:
	@Override
	@SuppressWarnings({ "serial", "unchecked" })
	public <T extends IPolicy<Node>> List<? extends T> getTargetPolicies(
			ITool<Node> contextTool, Node target, IViewer<Node> viewer,
			Class<T> policyClass) {
		if (target instanceof MyMetaPanel) {
			return Collections.emptyList();
		}
		return super.getTargetPolicies(...);
	}


Best regards,
Matthias
Re: GEF4 Add extra visual elements [message #1743833 is a reply to message #1742641] Tue, 20 September 2016 07:26 Go to previous message
Vlad Buzea is currently offline Vlad BuzeaFriend
Messages: 7
Registered: August 2016
Junior Member
Thanks Matthias!
The solution you proposed works best for my problem.
Previous Topic:[GEF4] layout algorithm with line break?
Next Topic:Handle on Mouse event for gef.graph.Node
Goto Forum:
  


Current Time: Thu Apr 19 12:09:23 GMT 2018

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

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