Search in sources :

Example 6 with ConnectionService

use of org.eclipse.sapphire.ui.diagram.ConnectionService in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _handleWorkflowNodeMetaChange.

private void _handleWorkflowNodeMetaChange(WorkflowNodeMetadata workflowNodeMetadata) {
    WorkflowNode workflowNode = workflowNodeMetadata.nearest(WorkflowNode.class);
    if (workflowNode == null) {
        return;
    }
    DiagramNodePart nodePart = _part().getDiagramNodePart(workflowNode);
    if (nodePart != null) {
        Position position = workflowNodeMetadata.getPosition();
        Value<Integer> valueX = position.getX();
        Value<Integer> valueY = position.getY();
        DiagramNodeBounds nodeBounds = nodePart.getNodeBounds();
        if ((nodeBounds.getX() != valueX.content()) || (nodeBounds.getY() != valueY.content())) {
            nodePart.setNodeBounds(new DiagramNodeBounds(valueX.content(), valueY.content()));
        }
    }
    ConnectionService connService = _part().service(ConnectionService.class);
    if (workflowNode instanceof CanTransition) {
        CanTransition canTransition = (CanTransition) workflowNode;
        ElementList<Transition> transitions = canTransition.getTransitions();
        for (Transition transition : transitions) {
            List<Point> bendpoints = new ArrayList<>();
            DiagramConnectionPart connPart = _getConnectionPart(connService, transition);
            if (connPart != null) {
                TransitionMetadata transitionMetadata = _getTransitionMetadata(transition, workflowNodeMetadata);
                if (transitionMetadata != null) {
                    for (ConnectionBendpoint bendpoint : transitionMetadata.getBendpoints()) {
                        bendpoints.add(new Point(bendpoint.getX().content(), bendpoint.getY().content()));
                    }
                    connPart.resetBendpoints(bendpoints);
                }
            }
        }
    }
}
Also used : ConnectionService(org.eclipse.sapphire.ui.diagram.ConnectionService) ConnectionBendpoint(com.liferay.ide.kaleo.core.model.ConnectionBendpoint) Position(com.liferay.ide.kaleo.core.model.Position) TransitionMetadata(com.liferay.ide.kaleo.core.model.TransitionMetadata) ArrayList(java.util.ArrayList) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Point(org.eclipse.sapphire.ui.Point) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) DiagramNodeBounds(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds) DiagramConnectionPart(org.eclipse.sapphire.ui.diagram.DiagramConnectionPart) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) DiagramNodePart(org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)

Aggregations

ConnectionService (org.eclipse.sapphire.ui.diagram.ConnectionService)6 DiagramConnectionPart (org.eclipse.sapphire.ui.diagram.DiagramConnectionPart)6 DiagramNodePart (org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)5 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)4 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)3 ConnectionBendpoint (com.liferay.ide.kaleo.core.model.ConnectionBendpoint)3 Position (com.liferay.ide.kaleo.core.model.Position)3 Transition (com.liferay.ide.kaleo.core.model.Transition)3 TransitionMetadata (com.liferay.ide.kaleo.core.model.TransitionMetadata)3 WorkflowNodeMetadata (com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata)3 Point (org.eclipse.sapphire.ui.Point)3 SapphireDiagramEditorPagePart (org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart)3 ArrayList (java.util.ArrayList)2 DiagramNodeBounds (org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds)2