From d8fef4b3135dc5964cbce22a76aef435a8ea5a0c Mon Sep 17 00:00:00 2001 From: Handreyrc <47090342+handreyrc@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:12:03 -0500 Subject: [PATCH] KOGITO-9952: SWF Editor - Add Icon to show there are subflows defined in States (#2063) --- .../sw/client/shapes/CallbackStateShape.java | 24 ++++++---- .../sw/client/shapes/ForEachStateShape.java | 7 +++ .../stunner/sw/client/shapes/HasActions.java | 21 +++++++-- .../stunner/sw/client/shapes/HasBranches.java | 19 ++++++-- .../sw/client/shapes/OperationStateShape.java | 11 ++++- .../sw/client/shapes/ParallelStateShape.java | 14 ++++-- .../sw/client/shapes/icons/DataDepiction.java | 44 +++++++++++++++++++ .../sw/client/shapes/icons/IconPath.java | 8 ++-- .../sw/client/shapes/icons/IconPosition.java | 8 ++-- .../sw/client/shapes/HasActionsTest.java | 40 +++++++++++++++-- .../sw/client/shapes/HasBranchesTest.java | 42 ++++++++++++++++++ 11 files changed, 210 insertions(+), 28 deletions(-) create mode 100644 packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/DataDepiction.java diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java index cc80172da46..3aca20882ad 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java @@ -26,6 +26,8 @@ import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; +import org.kie.workbench.common.stunner.sw.client.shapes.icons.DataDepiction; +import org.kie.workbench.common.stunner.sw.definition.ActionNode; import org.kie.workbench.common.stunner.sw.definition.CallbackState; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -34,9 +36,11 @@ import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.EVENT; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.FILTER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SERVICE; +import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SUBFLOW; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.BOTTOM_FROM_RIGHT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.CENTER_TOP; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.LEFT_FROM_RIGHT_TOP_CORNER; +import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.LEFT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.RIGHT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.resources.i18n.SWConstants.EVENT_REFERENCE; import static org.kie.workbench.common.stunner.sw.resources.i18n.SWConstants.TIMEOUT_ACTION; @@ -44,7 +48,7 @@ import static org.kie.workbench.common.stunner.sw.resources.i18n.SWConstants.TIMEOUT_STATE; public class CallbackStateShape extends StateShape implements HasActions, - HasEventAndDataFilter { + HasEventAndDataFilter { public static final String ICON_COLOR = "#EC7A08"; public static final String ICON_SVG = "M63.97,36.13c0-2.13-1.64-3.95-3.76-4.07-2.31-.13-4.23,1.7-4.23,3.99,0,6.61-5.37,11.98-11.98,11.98H24.03v-4.99c0-1.18-.7-2.25-1.78-2.74-1.08-.47-2.34-.28-3.23,.52l-9.98,8.98c-.63,.56-.99,1.37-.99,2.22s.36,1.66,.99,2.23l9.98,8.98c.56,.51,1.28,.77,2,.77,.41,0,.83-.09,1.22-.26,1.08-.48,1.78-1.55,1.78-2.74v-4.99h19.97c10.98,0,19.92-8.91,19.97-19.89ZM20,16.08h19.85l.11,4.99c0,1.18,.7,2.25,1.78,2.74,.4,.17,.81,.26,1.11,.26,.73,0,1.44-.27,2.01-.77l9.98-8.98c.74-.57,1.1-1.38,1.1-2.34s-.36-1.66-.99-2.23L44.97,.76c-.88-.79-2.15-.98-3.22-.51-1.08,.6-1.89,1.67-1.89,2.85l.11,4.99H20C8.99,8.09,.03,17.05,.03,28.06c0,2.21,1.79,3.99,3.99,3.99s3.99-1.79,3.99-3.99c0-6.6,5.38-11.98,11.98-11.98Z"; @@ -60,9 +64,9 @@ public void applyProperties(Node, Edge> element, MutationContext mut if (state.getTimeouts() != null && state.getTimeouts() instanceof WorkflowTimeouts) { getView().addChild(new CornerIcon(CLOCK, CENTER_TOP, - getTranslation(TIMEOUT_EVENT) + ": " + ((WorkflowTimeouts)state.getTimeouts()).getEventTimeout() + "\r\n" - + getTranslation(TIMEOUT_STATE) + ": " + ((WorkflowTimeouts)state.getTimeouts()).getStateExecTimeout() + "\r\n" - + getTranslation(TIMEOUT_ACTION) + ": " + ((WorkflowTimeouts)state.getTimeouts()).getActionExecTimeout())); + getTranslation(TIMEOUT_EVENT) + ": " + ((WorkflowTimeouts) state.getTimeouts()).getEventTimeout() + "\r\n" + + getTranslation(TIMEOUT_STATE) + ": " + ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() + "\r\n" + + getTranslation(TIMEOUT_ACTION) + ": " + ((WorkflowTimeouts) state.getTimeouts()).getActionExecTimeout())); } getView().addChild(new CornerIcon(EVENT, @@ -75,10 +79,14 @@ public void applyProperties(Node, Edge> element, MutationContext mut if (state.getStateDataFilter() != null || state.getEventDataFilter() != null) { getView().addChild(new CornerIcon(FILTER, - BOTTOM_FROM_RIGHT_TOP_CORNER, - getStateDataFilter(state.getStateDataFilter()) - + "\r\n\r\n" - + getEventFilter(state.getEventDataFilter()))); + BOTTOM_FROM_RIGHT_TOP_CORNER, + getStateDataFilter(state.getStateDataFilter()) + + "\r\n\r\n" + + getEventFilter(state.getEventDataFilter()))); + } + + if (null != state.getAction() && hasSubflows(new ActionNode[]{state.getAction()})) { + getView().addChild(new DataDepiction(SUBFLOW, LEFT_TOP_CORNER)); } } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java index dae19a91d7e..c47f7c89c2f 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java @@ -27,6 +27,7 @@ import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.BottomDepiction; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; +import org.kie.workbench.common.stunner.sw.client.shapes.icons.DataDepiction; import org.kie.workbench.common.stunner.sw.definition.ForEachState; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -37,8 +38,10 @@ import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.PARALLEL; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SEQUENTIAL; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SERVICE; +import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SUBFLOW; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.BOTTOM_FROM_RIGHT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.LEFT_FROM_RIGHT_TOP_CORNER; +import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.LEFT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.RIGHT_BOTTOM; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.RIGHT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.resources.i18n.SWConstants.TIMEOUT_ACTION; @@ -80,6 +83,10 @@ public void applyProperties(Node, Edge> element, MutationContext mut } getView().addChild(new BottomDepiction(isDefaultMode(state.getMode()) ? PARALLEL : SEQUENTIAL)); + + if (hasSubflows(state.getActions())) { + getView().addChild(new DataDepiction(SUBFLOW, LEFT_TOP_CORNER)); + } } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/HasActions.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/HasActions.java index ddc6911f6f5..fe36700218a 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/HasActions.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/HasActions.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.kie.workbench.common.stunner.sw.client.shapes; @@ -80,4 +80,19 @@ default String getActionString(ActionNode action) { return getTranslation(ACTION_IS_NULL); } + + default boolean hasSubflows(ActionNode[] actions) { + if (actions == null || actions.length == 0) { + return false; + } + + for (ActionNode action : actions) { + if (action.getSubFlowRef() != null) { + return true; + } + } + + return false; + } + } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/HasBranches.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/HasBranches.java index ac0069a0cec..b602de4eaaf 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/HasBranches.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/HasBranches.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.kie.workbench.common.stunner.sw.client.shapes; @@ -44,4 +44,17 @@ default String getBranchesString(ParallelStateBranch[] branches) { return result.toString(); } + + default boolean hasSubflows(ParallelStateBranch[] branches) { + if (branches == null || branches.length == 0) { + return false; + } + + for (ParallelStateBranch branch : branches) { + return hasSubflows(branch.getActions()); + } + + return false; + } + } \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java index 9f1bc31e318..ce9d69ccc66 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java @@ -27,6 +27,7 @@ import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.BottomDepiction; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; +import org.kie.workbench.common.stunner.sw.client.shapes.icons.DataDepiction; import org.kie.workbench.common.stunner.sw.definition.OperationState; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -36,8 +37,10 @@ import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.PARALLEL; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SEQUENTIAL; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SERVICE; +import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SUBFLOW; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.BOTTOM_FROM_RIGHT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.LEFT_FROM_RIGHT_TOP_CORNER; +import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.LEFT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.RIGHT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.resources.i18n.SWConstants.TIMEOUT_ACTION; import static org.kie.workbench.common.stunner.sw.resources.i18n.SWConstants.TIMEOUT_STATE; @@ -59,8 +62,8 @@ public void applyProperties(Node, Edge> element, MutationContext mut if (state.getTimeouts() != null && state.getTimeouts() instanceof WorkflowTimeouts) { getView().addChild(new CornerIcon(CLOCK, LEFT_FROM_RIGHT_TOP_CORNER, - getTranslation(TIMEOUT_STATE) + ": " + ((WorkflowTimeouts)state.getTimeouts()).getStateExecTimeout() + "\r\n" - + getTranslation(TIMEOUT_ACTION) + ": " + ((WorkflowTimeouts)state.getTimeouts()).getActionExecTimeout())); + getTranslation(TIMEOUT_STATE) + ": " + ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout() + "\r\n" + + getTranslation(TIMEOUT_ACTION) + ": " + ((WorkflowTimeouts) state.getTimeouts()).getActionExecTimeout())); } getView().addChild(new CornerIcon(SERVICE, @@ -74,6 +77,10 @@ public void applyProperties(Node, Edge> element, MutationContext mut boolean isDefault = state.getActionMode() == null || !(state.getActionMode().equals("parallel")); getView().addChild(new BottomDepiction(isDefault ? SEQUENTIAL : PARALLEL)); + + if (hasSubflows(state.getActions())) { + getView().addChild(new DataDepiction(SUBFLOW, LEFT_TOP_CORNER)); + } } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java index c117e5eb004..0e1fe459667 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java @@ -27,6 +27,7 @@ import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.BottomText; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; +import org.kie.workbench.common.stunner.sw.client.shapes.icons.DataDepiction; import org.kie.workbench.common.stunner.sw.definition.ParallelState; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -34,13 +35,16 @@ import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.BRANCH; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.CLOCK; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.FILTER; +import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPath.SUBFLOW; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.BOTTOM_FROM_RIGHT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.LEFT_FROM_RIGHT_TOP_CORNER; +import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.LEFT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.client.shapes.icons.IconPosition.RIGHT_TOP_CORNER; import static org.kie.workbench.common.stunner.sw.resources.i18n.SWConstants.TIMEOUT_BRANCH; import static org.kie.workbench.common.stunner.sw.resources.i18n.SWConstants.TIMEOUT_STATE; -public class ParallelStateShape extends StateShape implements HasDataFilter, HasBranches { +public class ParallelStateShape extends StateShape implements HasDataFilter, + HasBranches { public static final String ICON_COLOR = "#4CB140"; public static final String ICON_SVG = "M50.54,.01c2.34,.16,4.24,2.31,4.24,4.65V59.43c0,2.64-2.23,4.75-4.91,4.56-2.33-.17-4.23-2.31-4.23-4.65V4.57c0-2.63,2.22-4.75,4.9-4.56M13.46,63.99c-2.34-.16-4.24-2.31-4.24-4.65V4.57c0-2.52,2.04-4.57,4.57-4.57s4.57,2.05,4.57,4.57V59.43c0,2.64-2.22,4.75-4.9,4.56Z"; @@ -56,8 +60,8 @@ public void applyProperties(Node, Edge> element, MutationContext mut if (state.getTimeouts() != null && state.getTimeouts() instanceof WorkflowTimeouts) { getView().addChild(new CornerIcon(CLOCK, LEFT_FROM_RIGHT_TOP_CORNER, - getTranslation(TIMEOUT_BRANCH) + ": " + ((WorkflowTimeouts)state.getTimeouts()).getBranchExecTimeout() + "\r\n" - + getTranslation(TIMEOUT_STATE) + ": " + ((WorkflowTimeouts)state.getTimeouts()).getStateExecTimeout())); + getTranslation(TIMEOUT_BRANCH) + ": " + ((WorkflowTimeouts) state.getTimeouts()).getBranchExecTimeout() + "\r\n" + + getTranslation(TIMEOUT_STATE) + ": " + ((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout())); } getView().addChild(new CornerIcon(BRANCH, @@ -74,6 +78,10 @@ public void applyProperties(Node, Edge> element, MutationContext mut ? getTranslation("Enum.atleast") + ": " + state.getNumCompleted() : getTranslation("Enum.allof"); getView().addChild(new BottomText(completionType)); + + if (hasSubflows(state.getBranches())) { + getView().addChild(new DataDepiction(SUBFLOW, LEFT_TOP_CORNER)); + } } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/DataDepiction.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/DataDepiction.java new file mode 100644 index 00000000000..764da6e9cb0 --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/DataDepiction.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package org.kie.workbench.common.stunner.sw.client.shapes.icons; + +import com.ait.lienzo.client.core.shape.Group; +import com.ait.lienzo.client.core.shape.MultiPath; +import com.ait.lienzo.client.core.types.Point2D; + +public class DataDepiction extends Group { + + public DataDepiction(final String icon, final Point2D location) { + setLocation(location); + setListening(true); + + MultiPath multiPath = new MultiPath(icon) + .setStrokeWidth(0) + .setFillColor("#4F5255") + .setListening(false); + add(multiPath); + } + + @Override + public void destroy() { + super.destroy(); + } +} diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/IconPath.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/IconPath.java index 63945eb4819..b606ac4f598 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/IconPath.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/IconPath.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.kie.workbench.common.stunner.sw.client.shapes.icons; @@ -30,4 +30,6 @@ public interface IconPath { String EVENT = "M 6.755 6.788 L 5.504 6.788 L 6.335 4.933 C 6.39 4.82 6.348 4.679 6.249 4.595 C 6.15 4.51 5.997 4.523 5.898 4.609 L 3.198 6.858 C 3.114 6.93 3.072 7.056 3.114 7.168 C 3.157 7.281 3.254 7.35 3.382 7.35 L 4.634 7.35 L 3.802 9.207 C 3.747 9.319 3.788 9.459 3.887 9.544 C 3.944 9.6 3.986 9.614 4.057 9.614 C 4.125 9.614 4.184 9.585 4.239 9.544 L 6.938 7.294 C 7.023 7.223 7.065 7.097 7.023 6.985 C 6.98 6.872 6.868 6.788 6.755 6.788 Z M 7.88 2.865 C 7.866 2.865 7.866 2.865 7.852 2.865 C 7.866 2.767 7.88 2.683 7.88 2.584 C 7.88 1.81 7.248 1.178 6.474 1.178 C 6.038 1.178 5.66 1.374 5.407 1.684 C 5.069 1.052 4.422 0.615 3.662 0.615 C 2.579 0.615 1.694 1.5 1.694 2.584 C 1.694 2.71 1.708 2.836 1.737 2.963 C 1.048 3.188 0.554 3.835 0.569 4.595 C 0.598 5.522 1.357 6.239 2.271 6.239 L 3.072 6.239 L 5.533 4.186 C 5.687 4.06 5.87 3.99 6.066 3.99 C 6.249 3.99 6.433 4.046 6.573 4.159 C 6.883 4.397 6.995 4.82 6.825 5.171 L 6.375 6.239 L 7.866 6.239 C 8.78 6.239 9.539 5.522 9.568 4.609 C 9.596 3.653 8.837 2.865 7.88 2.865 Z"; String CONDITION = "M 7.382 2.142 L 9.781 4.542 C 9.921 4.683 10 4.876 10 5.076 C 10 5.274 9.921 5.467 9.781 5.608 L 7.382 8.008 C 7.256 8.132 7.088 8.2 6.912 8.2 C 6.547 8.2 6.25 7.903 6.25 7.538 L 6.25 6.326 L 3.75 6.326 C 3.405 6.326 3.126 6.046 3.126 5.7 L 3.126 4.45 C 3.126 4.105 3.405 3.826 3.75 3.826 L 6.25 3.826 L 6.25 2.612 C 6.25 2.247 6.547 1.95 6.912 1.95 C 7.088 1.95 7.256 2.02 7.382 2.142 Z M 3.126 1.95 L 1.876 1.95 C 1.53 1.95 1.25 2.23 1.25 2.576 L 1.25 7.576 C 1.25 7.92 1.53 8.2 1.876 8.2 L 3.126 8.2 C 3.47 8.2 3.75 8.48 3.75 8.826 C 3.75 9.17 3.47 9.45 3.126 9.45 L 1.876 9.45 C 0.84 9.45 0 8.61 0 7.576 L 0 2.576 C 0 1.54 0.84 0.7 1.876 0.7 L 3.126 0.7 C 3.47 0.7 3.75 0.98 3.75 1.326 C 3.75 1.67 3.47 1.95 3.126 1.95 Z"; String COLLECTION = "M 4.541 0.126 C 4.832 -0.008 5.168 -0.008 5.459 0.126 L 9.728 2.098 C 9.894 2.175 10 2.341 10 2.524 C 10 2.708 9.894 2.874 9.728 2.95 L 5.459 4.923 C 5.168 5.058 4.832 5.058 4.541 4.923 L 0.272 2.95 C 0.106 2.873 0 2.706 0 2.524 C 0 2.343 0.106 2.175 0.272 2.098 L 4.541 0.126 Z M 8.689 4.118 L 9.728 4.598 C 9.894 4.675 10 4.841 10 5.024 C 10 5.208 9.894 5.374 9.728 5.45 L 5.459 7.423 C 5.168 7.558 4.832 7.558 4.541 7.423 L 0.272 5.45 C 0.106 5.373 0 5.206 0 5.024 C 0 4.843 0.106 4.675 0.272 4.598 L 1.311 4.118 L 4.279 5.489 C 4.737 5.7 5.263 5.7 5.721 5.489 L 8.689 4.118 Z M 5.721 7.989 L 8.689 6.618 L 9.728 7.098 C 9.894 7.175 10 7.341 10 7.524 C 10 7.708 9.894 7.874 9.728 7.95 L 5.459 9.923 C 5.168 10.058 4.832 10.058 4.541 9.923 L 0.272 7.95 C 0.106 7.873 0 7.706 0 7.524 C 0 7.343 0.106 7.175 0.272 7.098 L 1.311 6.618 L 4.279 7.989 C 4.737 8.2 5.263 8.2 5.721 7.989 Z"; + String SUBFLOW = "m 14.865771,6.45624 c 0,1.6043697 -1.300599,2.904968 -2.904969,2.904968 -1.604369,0 -2.9049675,-1.3005983 -2.9049675,-2.904968 0,-1.6043693 1.3005985,-2.9049678 2.9049675,-2.9049678 1.60437,0 2.904969,1.3005985 2.904969,2.9049678 z M 14.575367,0.08598491 3.2529671,0.05163006 C 1.795948,0.12024785 0.21598954,1.4570527 0.18247097,3.106344 l -0.0209989,0.9842624 c 0.005208,1.3753457 1.10407263,2.7819001 3.04565883,2.8329148 l 2.0074903,0.05782 -1.7104976,1.692038 c -0.094274,0.109237 -0.095652,0.312136 -0.00444,0.4120606 l 0.5276074,0.504892 c 0.1953126,0.1243077 0.2807647,0.1323338 0.4711929,0.016504 L 7.4686544,6.6323244 c 0.1748068,-0.2414272 0.1843842,-0.4052967 0,-0.6260715 L 4.4726975,3.0520716 C 4.2337712,2.884969 4.1066352,2.9703275 3.9704641,3.0355604 L 3.5044236,3.5111921 c -0.076092,0.1369446 -0.1254119,0.2881364 0.06174,0.5372573 L 5.2575516,5.6441853 3.259302,5.6131542 C 2.1194839,5.5562381 1.5036329,4.7312947 1.4866684,4.0267858 L 1.5021692,3.1470583 C 1.5354362,2.3861895 2.4629481,1.39435 3.2090135,1.4270875 H 14.56406 c 0.216094,-0.052643 0.277884,-0.1586756 0.305264,-0.3019919 l -0.006,-0.74932917 C 14.827288,0.23222046 14.745214,0.12492551 14.575241,0.08657612 Z"; + } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/IconPosition.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/IconPosition.java index 5a8ca140f26..6cfba4f8e6b 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/IconPosition.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/IconPosition.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.kie.workbench.common.stunner.sw.client.shapes.icons; @@ -28,4 +28,6 @@ public interface IconPosition { Point2D CENTER_TOP = new Point2D(180, 6); Point2D RIGHT_BOTTOM = new Point2D(224, 50); Point2D BOTTOM_FROM_RIGHT_TOP_CORNER = new Point2D(224, 28); + Point2D LEFT_TOP_CORNER = new Point2D(8, 6); + } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/HasActionsTest.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/HasActionsTest.java index a65772337e1..2b69f0f69c4 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/HasActionsTest.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/HasActionsTest.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.kie.workbench.common.stunner.sw.client.shapes; @@ -25,6 +25,9 @@ import org.kie.workbench.common.stunner.sw.definition.FunctionRef; import org.kie.workbench.common.stunner.sw.definition.SubFlowRef; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class HasActionsTest extends HasTranslationGeneralTest { private final HasActions hasAction = HasActionsTest.super::getTranslation; @@ -183,4 +186,35 @@ public void actionsArrayTest() { "Action.subflow", "Action.function"); } + + @Test + public void hasSubflowsTrueTest() { + ActionNode[] actions = new ActionNode[2]; + + ActionNode action1 = new ActionNode(); + SubFlowRef subFlowRef = new SubFlowRef(); + String workflowId = "PROPER WORKFLOW ID"; + subFlowRef.setWorkflowId(workflowId); + action1.setSubFlowRef(subFlowRef); + actions[0] = action1; + + ActionNode action2 = new ActionNode(); + String funcRef = "FUNC REF NAME"; + action2.setFunctionRef(funcRef); + actions[1] = action2; + + assertTrue(hasAction.hasSubflows(actions)); + } + + @Test + public void hasSubflowsFalseTest() { + ActionNode[] actions = new ActionNode[1]; + ActionNode action = new ActionNode(); + String funcRef = "FUNC REF NAME"; + action.setFunctionRef(funcRef); + actions[0] = action; + + assertFalse(hasAction.hasSubflows(actions)); + } + } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/HasBranchesTest.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/HasBranchesTest.java index 636025d79e1..4353a822376 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/HasBranchesTest.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/HasBranchesTest.java @@ -22,8 +22,11 @@ import org.junit.Test; import org.kie.workbench.common.stunner.sw.definition.ActionNode; import org.kie.workbench.common.stunner.sw.definition.ParallelStateBranch; +import org.kie.workbench.common.stunner.sw.definition.SubFlowRef; import static org.assertj.core.util.Arrays.array; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class HasBranchesTest extends HasTranslationGeneralTest { @@ -82,4 +85,43 @@ public void twoBranchesWithNameNoActionTest() { hasBranches.getBranchesString(array(branch, branch)), "Branch.title", "Actions.null", "Branch.title", "Actions.null"); } + + @Test + public void hasSubflowsTrueTest() { + ActionNode[] actions = new ActionNode[2]; + + ActionNode action1 = new ActionNode(); + SubFlowRef subFlowRef = new SubFlowRef(); + String workflowId = "PROPER WORKFLOW ID"; + subFlowRef.setWorkflowId(workflowId); + action1.setSubFlowRef(subFlowRef); + actions[0] = action1; + + ActionNode action2 = new ActionNode(); + String funcRef = "FUNC REF NAME"; + action2.setFunctionRef(funcRef); + actions[1] = action2; + + ParallelStateBranch branch = new ParallelStateBranch(); + branch.setName(NAME); + branch.setActions(actions); + + assertTrue(hasBranches.hasSubflows(array(branch))); + } + + @Test + public void hasSubflowsFalseTest() { + ActionNode[] actions = new ActionNode[1]; + ActionNode action = new ActionNode(); + String funcRef = "FUNC REF NAME"; + action.setFunctionRef(funcRef); + actions[0] = action; + + ParallelStateBranch branch = new ParallelStateBranch(); + branch.setName(NAME); + branch.setActions(actions); + + assertFalse(hasBranches.hasSubflows(array(branch))); + } + }