Search in sources :

Example 1 with BaseSubprocess

use of org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess in project kie-wb-common by kiegroup.

the class SubProcessConverter method convertSubProcess.

public PropertyWriter convertSubProcess(Node<View<BaseSubprocess>, ?> node) {
    SubProcessPropertyWriter processRoot = NodeMatch.fromNode(BaseSubprocess.class, SubProcessPropertyWriter.class).when(EmbeddedSubprocess.class, this::convertEmbeddedSubprocessNode).when(EventSubprocess.class, this::convertEventSubprocessNode).when(AdHocSubprocess.class, this::convertAdHocSubprocessNode).apply(node).value();
    DefinitionsBuildingContext subContext = context.withRootNode(node);
    super.convertChildNodes(processRoot, subContext.nodes(), subContext.lanes());
    super.convertEdges(processRoot, subContext);
    return processRoot;
}
Also used : BaseSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter)

Example 2 with BaseSubprocess

use of org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess in project kie-wb-common by kiegroup.

the class ProcessPostConverter method resizeSubProcess.

private void resizeSubProcess(BpmnNode subProcess) {
    if (subProcess.hasChildren()) {
        ViewPort viewPort = ViewPort.of(subProcess, true);
        double leftPadding = viewPort.getUpperLeftX();
        double topPadding = viewPort.getUpperLeftY();
        double width = viewPort.getLowerRightX() + leftPadding;
        double height = viewPort.getLowerRightY() + topPadding;
        Bounds subProcessBounds = subProcess.value().getContent().getBounds();
        Bound subProcessUl = subProcessBounds.getUpperLeft();
        Bound subProcessLr = subProcessBounds.getLowerRight();
        Bounds subProcessOriginalBounds = Bounds.create(subProcessUl.getX(), subProcessUl.getY(), subProcessLr.getX(), subProcessLr.getY());
        double originalWidth = subProcessBounds.getWidth();
        double originalHeight = subProcessBounds.getHeight();
        subProcessLr.setX(subProcessUl.getX() + width);
        subProcessLr.setY(subProcessUl.getY() + height);
        RectangleDimensionsSet subProcessRectangle = ((BaseSubprocess) subProcess.value().getContent().getDefinition()).getDimensionsSet();
        subProcessRectangle.setWidth(new Width(width));
        subProcessRectangle.setHeight(new Height(height));
        context.setResized(subProcess, true);
        double widthFactor = width / originalWidth;
        double heightFactor = height / originalHeight;
        // incoming connections has the target point relative to subProcess so they needs to be scaled.
        inEdges(subProcess.getParent(), subProcess).forEach(edge -> scale(edge.getTargetConnection().getLocation(), widthFactor, heightFactor));
        // outgoing connections has source point relative to the subProcess so they needs to be scaled.
        outEdges(subProcess.getParent(), subProcess).forEach(edge -> scale(edge.getSourceConnection().getLocation(), widthFactor, heightFactor));
        // boundary elements are relative to the target subProcess so they needs to be scaled.
        dockedNodes(subProcess.getParent(), subProcess).forEach(node -> scaleBoundaryEventPosition(node, subProcessOriginalBounds, subProcessBounds, widthFactor, heightFactor));
    }
}
Also used : BaseSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) Height(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Height) RectangleDimensionsSet(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet) Width(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Width)

Example 3 with BaseSubprocess

use of org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess in project kie-wb-common by kiegroup.

the class DefaultRouteFormProvider method findElements.

@Override
protected Collection<Pair<Object, String>> findElements(Predicate<Node> filter, Function<Node, Pair<Object, String>> mapper) {
    Node selectedNode = getSelectedElement();
    Collection<Pair<Object, String>> result = new ArrayList<>();
    if (selectedNode != null) {
        List<Edge> outEdges = selectedNode.getOutEdges();
        if (outEdges != null) {
            result = outEdges.stream().map(outEdge -> {
                String routeIdentifier = outEdge.getUUID();
                // UI value for the route is the target node name or target node type
                String targetName = null;
                String targetNodeType = null;
                BPMNDefinition bpmnDefinition = getEdgeTarget(outEdge);
                if (bpmnDefinition != null) {
                    targetNodeType = definitionManager.adapters().forDefinition().getTitle(bpmnDefinition);
                    if (bpmnDefinition instanceof BaseStartEvent || bpmnDefinition instanceof BaseCatchingIntermediateEvent || bpmnDefinition instanceof BaseThrowingIntermediateEvent || bpmnDefinition instanceof BaseEndEvent || bpmnDefinition instanceof BaseTask || bpmnDefinition instanceof BaseGateway || bpmnDefinition instanceof BaseSubprocess) {
                        targetName = bpmnDefinition.getGeneral().getName().getValue();
                    }
                }
                if (targetName != null && !targetName.isEmpty()) {
                    return new Pair<Object, String>(routeIdentifier, targetName);
                } else if (targetNodeType != null && !targetNodeType.isEmpty()) {
                    return new Pair<Object, String>(routeIdentifier, targetNodeType);
                } else {
                    return new Pair<Object, String>(routeIdentifier, routeIdentifier);
                }
            }).collect(Collectors.toList());
        }
    }
    return result;
}
Also used : BaseGateway(org.kie.workbench.common.stunner.bpmn.definition.BaseGateway) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) BaseEndEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseEndEvent) BaseTask(org.kie.workbench.common.stunner.bpmn.definition.BaseTask) BaseSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess) BaseStartEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseStartEvent) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) BaseCatchingIntermediateEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseCatchingIntermediateEvent) Edge(org.kie.workbench.common.stunner.core.graph.Edge) BaseThrowingIntermediateEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseThrowingIntermediateEvent) Pair(org.uberfire.commons.data.Pair)

Aggregations

BaseSubprocess (org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess)3 ArrayList (java.util.ArrayList)1 DefinitionsBuildingContext (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext)1 AdHocSubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter)1 SubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter)1 BPMNDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition)1 BaseCatchingIntermediateEvent (org.kie.workbench.common.stunner.bpmn.definition.BaseCatchingIntermediateEvent)1 BaseEndEvent (org.kie.workbench.common.stunner.bpmn.definition.BaseEndEvent)1 BaseGateway (org.kie.workbench.common.stunner.bpmn.definition.BaseGateway)1 BaseStartEvent (org.kie.workbench.common.stunner.bpmn.definition.BaseStartEvent)1 BaseTask (org.kie.workbench.common.stunner.bpmn.definition.BaseTask)1 BaseThrowingIntermediateEvent (org.kie.workbench.common.stunner.bpmn.definition.BaseThrowingIntermediateEvent)1 EventSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess)1 Height (org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Height)1 RectangleDimensionsSet (org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet)1 Width (org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Width)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 Bound (org.kie.workbench.common.stunner.core.graph.content.Bound)1 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)1