Skip to content

Commit

Permalink
Merge pull request #421 from nipunayf/improve-diagram
Browse files Browse the repository at this point in the history
Improve the content of the node palette
  • Loading branch information
nipunayf authored Oct 2, 2024
2 parents ab6cf18 + bef2b23 commit 40defdc
Show file tree
Hide file tree
Showing 48 changed files with 1,080 additions and 1,915 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@ private void setAvailableNodesForIteratingBlock(NonTerminalNode node, SemanticMo
setDefaultNodes();
setStopNode(node);
this.rootBuilder.stepIn(Category.Name.CONTROL)
.stepIn(Category.Name.ITERATION)
.node(NodeKind.BREAK)
.node(NodeKind.CONTINUE)
.stepOut();
.node(NodeKind.BREAK)
.node(NodeKind.CONTINUE)
.stepOut();
}

private void setDefaultNodes() {
Expand All @@ -140,17 +139,11 @@ private void setDefaultNodes() {
.node(function)
.stepOut()
.stepIn(Category.Name.CONTROL)
.stepIn(Category.Name.BRANCH)
.node(NodeKind.IF)
.node(NodeKind.SWITCH)
.stepOut()
.stepIn(Category.Name.ITERATION)
.node(NodeKind.WHILE)
.node(NodeKind.FOREACH)
.stepOut()
.stepIn(Category.Name.TERMINATION)
.node(NodeKind.RETURN)
.stepOut()
.node(NodeKind.IF)
.node(NodeKind.MATCH)
.node(NodeKind.WHILE)
.node(NodeKind.FOREACH)
.node(NodeKind.RETURN)
.stepOut()
.stepIn(Category.Name.DATA)
.node(NodeKind.JSON_PAYLOAD)
Expand All @@ -160,6 +153,7 @@ private void setDefaultNodes() {
.stepOut()
.stepIn(Category.Name.ERROR_HANDLING)
.node(NodeKind.ERROR_HANDLER)
.node(NodeKind.FAIL)
.node(NodeKind.PANIC)
.stepOut()
.stepIn(Category.Name.CONCURRENCY)
Expand All @@ -174,9 +168,8 @@ private void setStopNode(NonTerminalNode node) {
while (parent != null) {
if (isStopNodeAvailable(parent)) {
this.rootBuilder.stepIn(Category.Name.CONTROL)
.stepIn(Category.Name.TERMINATION)
.node(NodeKind.STOP)
.stepOut();
.node(NodeKind.STOP)
.stepOut();
}
parent = parent.parent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ public void visit(RetryStatementNode retryStatementNode) {

@Override
public void visit(MatchStatementNode matchStatementNode) {
startNode(NodeKind.SWITCH)
startNode(NodeKind.MATCH)
.properties().condition(matchStatementNode.condition());

NodeList<MatchClauseNode> matchClauseNodes = matchStatementNode.matchClauses();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
import io.ballerina.flowmodelgenerator.core.model.node.If;
import io.ballerina.flowmodelgenerator.core.model.node.JsonPayload;
import io.ballerina.flowmodelgenerator.core.model.node.Lock;
import io.ballerina.flowmodelgenerator.core.model.node.Match;
import io.ballerina.flowmodelgenerator.core.model.node.NewConnection;
import io.ballerina.flowmodelgenerator.core.model.node.Panic;
import io.ballerina.flowmodelgenerator.core.model.node.Return;
import io.ballerina.flowmodelgenerator.core.model.node.Start;
import io.ballerina.flowmodelgenerator.core.model.node.Stop;
import io.ballerina.flowmodelgenerator.core.model.node.Switch;
import io.ballerina.flowmodelgenerator.core.model.node.Transaction;
import io.ballerina.flowmodelgenerator.core.model.node.While;
import io.ballerina.flowmodelgenerator.core.model.node.XmlPayload;
Expand Down Expand Up @@ -134,7 +134,7 @@ public abstract class NodeBuilder {
put(NodeKind.DATA_MAPPER, DataMapper::new);
put(NodeKind.ASSIGN, Assign::new);
put(NodeKind.COMMENT, Comment::new);
put(NodeKind.SWITCH, Switch::new);
put(NodeKind.MATCH, Match::new);
}};

public static NodeBuilder getNodeFromKind(NodeKind kind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum NodeKind {
FOREACH,
DATA_MAPPER,
COMMENT,
SWITCH,
MATCH,
FUNCTION,

// Branches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
*
* @since 1.4.0
*/
public class Switch extends NodeBuilder {
public class Match extends NodeBuilder {

public static final String LABEL = "Switch";
public static final String LABEL = "Match";
public static final String DESCRIPTION = "Switches the data flow based on the value of an expression.";

@Override
public void setConcreteConstData() {
metadata().label(LABEL).description(DESCRIPTION);
codedata().node(NodeKind.SWITCH);
codedata().node(NodeKind.MATCH);
}

@Override
Expand All @@ -67,7 +67,7 @@ public void setConcreteTemplateData(TemplateContext context) {
public Map<Path, List<TextEdit>> toSource(SourceBuilder sourceBuilder) {
Optional<Property> condition = sourceBuilder.flowNode.getProperty(Property.CONDITION_KEY);
if (condition.isEmpty()) {
throw new IllegalStateException("Switch node does not have a condition");
throw new IllegalStateException("Match node does not have a condition");
}

sourceBuilder.token()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"items": [
{
"metadata": {
"label": "Schema To JSON",
"label": "Type To JSON",
"description": "Converts a value of type `anydata` to `json`.\n\n",
"icon": ""
},
Expand All @@ -99,7 +99,7 @@
},
{
"metadata": {
"label": "Schema To XML",
"label": "Type To XML",
"description": "Converts a `Map` or `Record` representation to its XML representation.\nAdditionally, when converting from a record, the `xmldata:Namespace`, `xmldata:Name`, and `xmldata:Attribute`\nannotations can be used to add `namespaces`, `name of elements`, and `attributes` to XML representation.\n\n",
"icon": ""
},
Expand All @@ -116,7 +116,7 @@
},
{
"metadata": {
"label": "JSON To Schema",
"label": "JSON To Type",
"description": "Convert value of type `json` to subtype of `anydata`.\n\n",
"icon": ""
},
Expand All @@ -133,7 +133,7 @@
},
{
"metadata": {
"label": "XML To Schema",
"label": "XML To Type",
"description": "Converts XML to record type with projection.\n\n",
"icon": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,86 +282,62 @@
"items": [
{
"metadata": {
"label": "Branch",
"description": "Branching nodes"
"label": "If",
"description": "Add conditional branch to the integration flow."
},
"items": [
{
"metadata": {
"label": "If",
"description": "Add conditional branch to the integration flow."
},
"codedata": {
"node": "IF"
},
"enabled": true
},
{
"metadata": {
"label": "Switch",
"description": "Switches the data flow based on the value of an expression."
},
"codedata": {
"node": "SWITCH"
},
"enabled": true
}
]
"codedata": {
"node": "IF"
},
"enabled": true
},
{
"metadata": {
"label": "Iteration",
"description": "Iteration nodes"
"label": "Match",
"description": "Switches the data flow based on the value of an expression."
},
"items": [
{
"metadata": {
"label": "While",
"description": "Loop over a block of code."
},
"codedata": {
"node": "WHILE"
},
"enabled": true
},
{
"metadata": {
"label": "Foreach",
"description": "Iterate over a block of code."
},
"codedata": {
"node": "FOREACH"
},
"enabled": true
}
]
"codedata": {
"node": "MATCH"
},
"enabled": true
},
{
"metadata": {
"label": "Termination",
"description": "Termination nodes"
"label": "While",
"description": "Loop over a block of code."
},
"items": [
{
"metadata": {
"label": "Return"
},
"codedata": {
"node": "RETURN"
},
"enabled": true
},
{
"metadata": {
"label": "Stop",
"description": "Stop the flow"
},
"codedata": {
"node": "STOP"
},
"enabled": true
}
]
"codedata": {
"node": "WHILE"
},
"enabled": true
},
{
"metadata": {
"label": "Foreach",
"description": "Iterate over a block of code."
},
"codedata": {
"node": "FOREACH"
},
"enabled": true
},
{
"metadata": {
"label": "Return"
},
"codedata": {
"node": "RETURN"
},
"enabled": true
},
{
"metadata": {
"label": "Stop",
"description": "Stop the flow"
},
"codedata": {
"node": "STOP"
},
"enabled": true
}
]
},
Expand Down Expand Up @@ -427,6 +403,16 @@
},
"enabled": true
},
{
"metadata": {
"label": "Fail",
"description": "Fail the execution"
},
"codedata": {
"node": "FAIL"
},
"enabled": true
},
{
"metadata": {
"label": "Panic",
Expand Down Expand Up @@ -551,7 +537,7 @@
"items": [
{
"metadata": {
"label": "Schema To JSON",
"label": "Type To JSON",
"description": "Converts a value of type `anydata` to `json`.\n\n",
"icon": ""
},
Expand All @@ -566,7 +552,7 @@
},
{
"metadata": {
"label": "Schema To XML",
"label": "Type To XML",
"description": "Converts a `Map` or `Record` representation to its XML representation.\nAdditionally, when converting from a record, the `xmldata:Namespace`, `xmldata:Name`, and `xmldata:Attribute`\nannotations can be used to add `namespaces`, `name of elements`, and `attributes` to XML representation.\n\n",
"icon": ""
},
Expand All @@ -581,7 +567,7 @@
},
{
"metadata": {
"label": "JSON To Schema",
"label": "JSON To Type",
"description": "Convert value of type `json` to subtype of `anydata`.\n\n",
"icon": ""
},
Expand All @@ -596,7 +582,7 @@
},
{
"metadata": {
"label": "XML To Schema",
"label": "XML To Type",
"description": "Converts XML to record type with projection.\n\n",
"icon": ""
},
Expand Down
Loading

0 comments on commit 40defdc

Please sign in to comment.