Search in sources :

Example 1 with TransitionMetadata

use of com.liferay.ide.kaleo.core.model.TransitionMetadata in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _handleConnectionBendpointChange.

private void _handleConnectionBendpointChange(Transition transition) {
    ConnectionService connService = _part().service(ConnectionService.class);
    DiagramConnectionPart connPart = _getConnectionPart(connService, transition);
    if (connPart != null) {
        List<Point> bendpoints = new ArrayList<>();
        WorkflowNode wfNode = transition.nearest(WorkflowNode.class);
        ElementHandle<WorkflowNodeMetadata> nodeMetadata = wfNode.getMetadata();
        WorkflowNodeMetadata metadata = nodeMetadata.content(false);
        TransitionMetadata transitionMetadata = _getTransitionMetadata(transition, metadata);
        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) TransitionMetadata(com.liferay.ide.kaleo.core.model.TransitionMetadata) DiagramConnectionPart(org.eclipse.sapphire.ui.diagram.DiagramConnectionPart) ArrayList(java.util.ArrayList) WorkflowNodeMetadata(com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata) Point(org.eclipse.sapphire.ui.Point) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode)

Example 2 with TransitionMetadata

use of com.liferay.ide.kaleo.core.model.TransitionMetadata in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _writeTransitionBendPoints.

private void _writeTransitionBendPoints(Transition transition, DiagramConnectionPart connPart) {
    WorkflowNode workflowNode = transition.nearest(WorkflowNode.class);
    ElementHandle<WorkflowNodeMetadata> nodeMetadata = workflowNode.getMetadata();
    WorkflowNodeMetadata metadata = nodeMetadata.content(true);
    TransitionMetadata transitionMetadata = _getTransitionMetadata(transition, metadata, true);
    transitionMetadata.setName(transition.getName().content());
    ElementList<ConnectionBendpoint> bendpointsInMetadataList = transitionMetadata.getBendpoints();
    int bendpointsInMetadataSize = bendpointsInMetadataList.size();
    List<Point> bendpointsInPartList = connPart.getBendpoints();
    int bendpointsInPartSize = bendpointsInPartList.size();
    for (int i = 0, n = min(bendpointsInMetadataSize, bendpointsInPartSize); i < n; i++) {
        ConnectionBendpoint bendpointInMetadata = bendpointsInMetadataList.get(i);
        Point bendpointInPart = bendpointsInPartList.get(i);
        if (bendpointInMetadata.getX().content() != bendpointInPart.getX()) {
            bendpointInMetadata.setX(bendpointInPart.getX());
        }
        if (bendpointInMetadata.getY().content() != bendpointInPart.getY()) {
            bendpointInMetadata.setY(bendpointInPart.getY());
        }
    }
    if (bendpointsInMetadataSize < bendpointsInPartSize) {
        for (int i = bendpointsInMetadataSize; i < bendpointsInPartSize; i++) {
            ConnectionBendpoint bendpointInMetadata = bendpointsInMetadataList.insert();
            Point bendpointInPart = bendpointsInPartList.get(i);
            bendpointInMetadata.setX(bendpointInPart.getX());
            bendpointInMetadata.setY(bendpointInPart.getY());
        }
    } else if (bendpointsInMetadataSize > bendpointsInPartSize) {
        for (int i = bendpointsInMetadataSize - 1; i >= bendpointsInPartSize; i--) {
            bendpointsInMetadataList.remove(i);
        }
    }
    if ((connPart.getLabelPosition() != null) && !connPart.getLabelPosition().equals(DEFAULT_POINT)) {
        transitionMetadata.getLabelLocation().setX(connPart.getLabelPosition().getX());
        transitionMetadata.getLabelLocation().setY(connPart.getLabelPosition().getY());
    }
}
Also used : ConnectionBendpoint(com.liferay.ide.kaleo.core.model.ConnectionBendpoint) TransitionMetadata(com.liferay.ide.kaleo.core.model.TransitionMetadata) WorkflowNodeMetadata(com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata) Point(org.eclipse.sapphire.ui.Point) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) ConnectionBendpoint(com.liferay.ide.kaleo.core.model.ConnectionBendpoint) Point(org.eclipse.sapphire.ui.Point)

Example 3 with TransitionMetadata

use of com.liferay.ide.kaleo.core.model.TransitionMetadata in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _getTransitionMetadata.

private TransitionMetadata _getTransitionMetadata(Transition transition, WorkflowNodeMetadata nodeMetadata, boolean createIfNecessary) {
    TransitionMetadata retval = null;
    ElementList<TransitionMetadata> transitionsData = nodeMetadata.getTransitionsMetadata();
    for (TransitionMetadata transitionData : transitionsData) {
        if (transition.getName().content() != null) {
            String transitionName = transition.getName().content();
            if (transitionName.equals(transitionData.getName().content())) {
            }
            retval = transitionData;
            break;
        }
    }
    if ((retval == null) && createIfNecessary) {
        retval = nodeMetadata.getTransitionsMetadata().insert();
    }
    return retval;
}
Also used : TransitionMetadata(com.liferay.ide.kaleo.core.model.TransitionMetadata)

Example 4 with TransitionMetadata

use of com.liferay.ide.kaleo.core.model.TransitionMetadata in project liferay-ide by liferay.

the class WorkflowDefinitionLayoutPersistenceService method _load.

private void _load() {
    SapphireDiagramEditorPagePart part = _part();
    part.setGridVisible(part.adapt(WorkflowDefinitionEditor.class).isGridVisible());
    part.setShowGuides(part.adapt(WorkflowDefinitionEditor.class).isShowGuides());
    ConnectionService connService = part.service(ConnectionService.class);
    for (WorkflowNode workflowNode : _definition().getDiagramNodes()) {
        DiagramNodePart nodePart = part.getDiagramNodePart(workflowNode);
        if (nodePart != null) {
            WorkflowNodeMetadata metadata = workflowNode.getMetadata().content(false);
            Position position = metadata.getPosition();
            Value<Integer> valueX = position.getX();
            Value<Integer> valueY = position.getY();
            DiagramNodeBounds bounds = new DiagramNodeBounds(valueX.content(), valueY.content(), -1, -1, false, false);
            nodePart.setNodeBounds(bounds);
            ListFactory<Transition> transitionsList = ListFactory.start();
            for (Transition transition : workflowNode.nearest(CanTransition.class).getTransitions()) {
                transitionsList.add(transition);
            }
            List<Transition> transitions = transitionsList.result();
            for (Transition transition : transitions) {
                DiagramConnectionPart connPart = _getConnectionPart(connService, transition);
                if (connPart != null) {
                    TransitionMetadata transitionMetadata = _getTransitionMetadata(transition, metadata);
                    if (transitionMetadata == null) {
                        continue;
                    }
                    List<ConnectionBendpoint> bendpoints = transitionMetadata.getBendpoints();
                    if (ListUtil.isNotEmpty(bendpoints)) {
                        int index = 0;
                        for (ConnectionBendpoint bendpoint : bendpoints) {
                            connPart.addBendpoint(index++, bendpoint.getX().content(), bendpoint.getY().content());
                        }
                    }
                    Position labelPosition = transitionMetadata.getLabelLocation();
                    if (labelPosition != null) {
                        connPart.setLabelPosition(new Point(labelPosition.getX().content(), labelPosition.getY().content()));
                    }
                }
            }
        }
    }
    for (DiagramConnectionPart connPart : connService.list()) {
        connPart.attach(_connectionPartListener);
    }
}
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) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) WorkflowNodeMetadata(com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata) Point(org.eclipse.sapphire.ui.Point) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) ConnectionBendpoint(com.liferay.ide.kaleo.core.model.ConnectionBendpoint) Point(org.eclipse.sapphire.ui.Point) DiagramNodeBounds(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds) SapphireDiagramEditorPagePart(org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart) 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)

Example 5 with TransitionMetadata

use of com.liferay.ide.kaleo.core.model.TransitionMetadata 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

TransitionMetadata (com.liferay.ide.kaleo.core.model.TransitionMetadata)6 ConnectionBendpoint (com.liferay.ide.kaleo.core.model.ConnectionBendpoint)4 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)4 WorkflowNodeMetadata (com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata)4 Point (org.eclipse.sapphire.ui.Point)4 Position (com.liferay.ide.kaleo.core.model.Position)3 Transition (com.liferay.ide.kaleo.core.model.Transition)3 ConnectionService (org.eclipse.sapphire.ui.diagram.ConnectionService)3 DiagramConnectionPart (org.eclipse.sapphire.ui.diagram.DiagramConnectionPart)3 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)2 ArrayList (java.util.ArrayList)2 DiagramNodeBounds (org.eclipse.sapphire.ui.diagram.editor.DiagramNodeBounds)2 DiagramNodePart (org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)2 Action (com.liferay.ide.kaleo.core.model.Action)1 ScriptLanguageType (com.liferay.ide.kaleo.core.model.ScriptLanguageType)1 State (com.liferay.ide.kaleo.core.model.State)1 Task (com.liferay.ide.kaleo.core.model.Task)1 TemplateLanguageType (com.liferay.ide.kaleo.core.model.TemplateLanguageType)1 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1