GEF4 Add extra visual elements [message #1739732] |
Thu, 04 August 2016 08:13  |
Eclipse User |
|
|
|
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 06:01   |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.05794 seconds