use of org.osate.ge.palette.GetTargetedOperationContext in project osate2 by osate.
the class CreateConnectionInteraction method createGetTargetedOperationContext.
private Optional<GetTargetedOperationContext> createGetTargetedOperationContext(final MouseEvent event) {
// Find the closest diagram node
final DiagramNode targetDiagramNode = InputEventHandlerUtil.getTargetDiagramNode(editor.getGefDiagram(), event.getTarget());
if (targetDiagramNode == null) {
return Optional.empty();
}
final Node targetSceneNode = editor.getGefDiagram().getSceneNode(targetDiagramNode);
final Point2D targetPosition = getTargetPosition(targetSceneNode, event.getSceneX(), event.getSceneY());
final DockingPosition dockingPostion = AgeDiagramUtil.determineDockingPosition(targetDiagramNode, targetPosition.getX(), targetPosition.getY(), 0, 0);
return Optional.of(new GetTargetedOperationContext(targetDiagramNode, dockingPostion, editor.getQueryService()));
}
Aggregations