Search in sources :

Example 6 with GetTargetedOperationContext

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()));
}
Also used : DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) Point2D(javafx.geometry.Point2D) GeometryNode(org.eclipse.gef.fx.nodes.GeometryNode) Node(javafx.scene.Node) DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) DockingPosition(org.osate.ge.DockingPosition) GetTargetedOperationContext(org.osate.ge.palette.GetTargetedOperationContext)

Aggregations

GetTargetedOperationContext (org.osate.ge.palette.GetTargetedOperationContext)6 Optional (java.util.Optional)5 Operation (org.osate.ge.operations.Operation)5 BasePaletteCommand (org.osate.ge.palette.BasePaletteCommand)5 TargetedPaletteCommand (org.osate.ge.palette.TargetedPaletteCommand)5 StepResultBuilder (org.osate.ge.operations.StepResultBuilder)4 Display (org.eclipse.swt.widgets.Display)3 AadlPackage (org.osate.aadl2.AadlPackage)3 BusinessObjectContext (org.osate.ge.BusinessObjectContext)3 StepResult (org.osate.ge.operations.StepResult)3 EObject (org.eclipse.emf.ecore.EObject)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)2 Aadl2Package (org.osate.aadl2.Aadl2Package)2 StringUtil (org.osate.ge.StringUtil)2 AadlCategories (org.osate.ge.aadl2.AadlCategories)2 AadlImportsUtil (org.osate.ge.aadl2.AadlImportsUtil)2 AadlImages (org.osate.ge.aadl2.internal.AadlImages)2 AadlNamingUtil (org.osate.ge.aadl2.internal.AadlNamingUtil)2 Objects (com.google.common.base.Objects)1