summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java')
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java
index e2984af..933e562 100644
--- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,11 +35,17 @@
*/
package net.sourceforge.plantuml.activitydiagram3.command;
+import net.sourceforge.plantuml.LineLocation;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
@@ -51,19 +57,28 @@ public class CommandIf2 extends SingleLineCommand2<ActivityDiagram3> {
super(getRegexConcat());
}
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandIf2.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
ColorParser.exp4(), //
new RegexLeaf("if"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("TEST", "\\((.*?)\\)"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("WHEN", "(?:then[%s]*(?:\\((.+?)\\))?)?"), //
- new RegexLeaf(";?$"));
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("\\("), //
+ new RegexLeaf("TEST", "(.*?)"), //
+ new RegexLeaf("\\)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOptional( //
+ new RegexConcat( //
+ new RegexLeaf("then"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexOptional(new RegexLeaf("WHEN", "\\((.+?)\\)")) //
+ )), //
+ new RegexLeaf(";?"), //
+ RegexLeaf.end());
}
@Override
- protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) {
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
String test = arg.get("TEST", 0);
@@ -71,7 +86,15 @@ public class CommandIf2 extends SingleLineCommand2<ActivityDiagram3> {
test = null;
}
- diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color);
+ final Url url;
+ if (arg.get("URL", 0) == null) {
+ url = null;
+ } else {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ url = urlBuilder.getUrl(arg.get("URL", 0));
+ }
+
+ diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color, url);
return CommandExecutionResult.ok();
}