summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/activitydiagram/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/activitydiagram/command')
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java65
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java60
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java62
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java121
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java60
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java258
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java203
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity2.java220
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java69
9 files changed, 1118 insertions, 0 deletions
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java
new file mode 100644
index 0000000..031a2a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class CommandElse extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandElse() {
+ super("(?i)^else$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram system, List<String> arg) {
+ if (system.getLastEntityConsulted() == null) {
+ return CommandExecutionResult.error("No if for this else");
+ }
+ if (system.getCurrentContext() == null) {
+ return CommandExecutionResult.error("No if for this else");
+ }
+ final IEntity branch = system.getCurrentContext().getBranch();
+
+ system.setLastEntityConsulted(branch);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java
new file mode 100644
index 0000000..a9ce25c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class CommandEndPartition extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandEndPartition() {
+ super("(?i)^(end[%s]?partition|\\})$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
+ final IEntity currentPackage = diagram.getCurrentGroup();
+ if (currentPackage == null) {
+ return CommandExecutionResult.error("No partition defined");
+ }
+ diagram.endGroup();
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java
new file mode 100644
index 0000000..ed0ca2c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+
+public class CommandEndif extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandEndif() {
+ super("(?i)^end[%s]?if$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
+ if (diagram.getLastEntityConsulted() == null) {
+ return CommandExecutionResult.error("No if for this endif");
+ }
+ if (diagram.getCurrentContext() == null) {
+ return CommandExecutionResult.error("No if for this endif");
+ }
+ diagram.endif();
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java
new file mode 100644
index 0000000..8fd2456
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+
+public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
+
+ public CommandIf() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOptional(//
+ new RegexOr("FIRST", //
+ new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ARROW", "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexLeaf("IF1", "if[%s]*[%g]([^%g]*)[%g][%s]*(?:as[%s]+([\\p{L}0-9_.]+)[%s]+)?"), //
+ new RegexLeaf("IF2", "if[%s]+(.+?)[%s]*")), //
+ new RegexLeaf("(?:then)?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram system, RegexResult arg) {
+ final IEntity entity1 = CommandLinkActivity.getEntity(system, arg, true);
+ if (entity1 == null) {
+ return CommandExecutionResult.error("No if possible at this point");
+ }
+
+ final String ifCode;
+ final String ifLabel;
+ if (arg.get("IF2", 0) == null) {
+ ifCode = arg.get("IF1", 1);
+ ifLabel = arg.get("IF1", 0);
+ } else {
+ ifCode = null;
+ ifLabel = arg.get("IF2", 0);
+ }
+ system.startIf(Code.of(ifCode));
+
+ int lenght = 2;
+
+ if (arg.get("ARROW", 0) != null) {
+ final String arrow = StringUtils.manageArrowForCuca(arg.get("ARROW", 0));
+ lenght = arrow.length() - 1;
+ }
+
+ final IEntity branch = system.getCurrentContext().getBranch();
+
+ Link link = new Link(entity1, branch, new LinkType(LinkDecor.ARROW, LinkDecor.NONE),
+ Display.getWithNewlines(arg.get("BRACKET", 0)), lenght, null, ifLabel, system.getLabeldistance(),
+ system.getLabelangle());
+ if (arg.get("ARROW", 0) != null) {
+ final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0));
+ if (direction == Direction.LEFT || direction == Direction.UP) {
+ link = link.getInv();
+ }
+ }
+
+ system.addLink(link);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java
new file mode 100644
index 0000000..517e94b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+
+public class CommandInnerConcurrent extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandInnerConcurrent() {
+ super("(?i)^--\\s*(.*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
+ if (EntityUtils.groupRoot(diagram.getCurrentGroup())) {
+ return CommandExecutionResult.error("No inner activity");
+ }
+ diagram.concurrentActivity(arg.get(0));
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java
new file mode 100644
index 0000000..c76aa00
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java
@@ -0,0 +1,258 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+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.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
+
+ public CommandLinkActivity() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOptional(//
+ new RegexOr("FIRST", //
+ new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
+ new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BACKCOLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+
+ new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
+ new RegexLeaf("ARROW_STYLE1",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), //
+ new RegexLeaf("ARROW_STYLE2",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), //
+
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr("FIRST2", //
+ new RegexLeaf("STAR2", "(\\(\\*(top|\\d+)?\\))"), //
+ new RegexLeaf("OPENBRACKET2", "(\\{)"), //
+ new RegexLeaf("CODE2", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
+ new RegexLeaf("BAR2", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED2", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?"), //
+ new RegexLeaf("QUOTED_INVISIBLE2", "(\\w.*?)")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("PARTITION2", "(?:in[%s]+([%g][^%g]+[%g]|\\S+))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BACKCOLOR2", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, RegexResult arg) {
+ final IEntity entity1 = getEntity(diagram, arg, true);
+ if (entity1 == null) {
+ return CommandExecutionResult.error("No such activity");
+ }
+ if (arg.get("STEREOTYPE", 0) != null) {
+ entity1.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0)));
+ }
+ if (arg.get("BACKCOLOR", 0) != null) {
+ entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("BACKCOLOR", 0)));
+ }
+
+ final IEntity entity2 = getEntity(diagram, arg, false);
+ if (entity2 == null) {
+ return CommandExecutionResult.error("No such activity");
+ }
+ if (arg.get("BACKCOLOR2", 0) != null) {
+ entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("BACKCOLOR2", 0)));
+ }
+ if (arg.get("STEREOTYPE2", 0) != null) {
+ entity2.setStereotype(new Stereotype(arg.get("STEREOTYPE2", 0)));
+ }
+
+ final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0));
+
+ final String arrowBody1 = CommandLinkClass.notNull(arg.get("ARROW_BODY1", 0));
+ final String arrowBody2 = CommandLinkClass.notNull(arg.get("ARROW_BODY2", 0));
+ final String arrowDirection = CommandLinkClass.notNull(arg.get("ARROW_DIRECTION", 0));
+
+ final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">");
+ int lenght = arrow.length() - 1;
+ if (arrowDirection.contains("*")) {
+ lenght = 2;
+ }
+
+ LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
+ if ((arrowBody1 + arrowBody2).contains(".")) {
+ type = type.getDotted();
+ }
+
+ Link link = new Link(entity1, entity2, type, linkLabel, lenght);
+ if (arrowDirection.contains("*")) {
+ link.setConstraint(false);
+ }
+ final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
+ if (direction == Direction.LEFT || direction == Direction.UP) {
+ link = link.getInv();
+ }
+ if (arg.get("URL", 0) != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0));
+ link.setUrl(urlLink);
+ }
+
+ CommandLinkClass.applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
+ diagram.addLink(link);
+
+ return CommandExecutionResult.ok();
+
+ }
+
+ static IEntity getEntity(ActivityDiagram system, RegexResult arg, final boolean start) {
+ final String suf = start ? "" : "2";
+
+ final String openBracket2 = arg.get("OPENBRACKET" + suf, 0);
+ if (openBracket2 != null) {
+ return system.createInnerActivity();
+ }
+ if (arg.get("STAR" + suf, 0) != null) {
+ final String suppId = arg.get("STAR" + suf, 1);
+ if (start) {
+ if (suppId != null) {
+ system.getStart().setTop(true);
+ }
+ return system.getStart();
+ }
+ return system.getEnd(suppId);
+ }
+ String partition = arg.get("PARTITION" + suf, 0);
+ if (partition != null) {
+ partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
+ }
+ final Code code = Code.of(arg.get("CODE" + suf, 0));
+ if (code != null) {
+ if (partition != null) {
+ system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ system.getRootGroup());
+ }
+ final IEntity result = system.getOrCreate(code, Display.getWithNewlines(code),
+ CommandLinkActivity.getTypeIfExisting(system, code));
+ if (partition != null) {
+ system.endGroup();
+ }
+ return result;
+ }
+ final String bar = arg.get("BAR" + suf, 0);
+ if (bar != null) {
+ return system.getOrCreate(Code.of(bar), Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR);
+ }
+ final RegexPartialMatch quoted = arg.get("QUOTED" + suf);
+ if (quoted.get(0) != null) {
+ final Code quotedCode = Code.of(quoted.get(1) == null ? quoted.get(0) : quoted.get(1));
+ if (partition != null) {
+ system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ system.getRootGroup());
+ }
+ final IEntity result = system.getOrCreate(quotedCode, Display.getWithNewlines(quoted.get(0)),
+ CommandLinkActivity.getTypeIfExisting(system, quotedCode));
+ if (partition != null) {
+ system.endGroup();
+ }
+ return result;
+ }
+ final Code quotedInvisible = Code.of(arg.get("QUOTED_INVISIBLE" + suf, 0));
+ if (quotedInvisible != null) {
+ if (partition != null) {
+ system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ system.getRootGroup());
+ }
+ final IEntity result = system.getOrCreate(quotedInvisible, Display.getWithNewlines(quotedInvisible),
+ LeafType.ACTIVITY);
+ if (partition != null) {
+ system.endGroup();
+ }
+ return result;
+ }
+ final String first = arg.get("FIRST" + suf, 0);
+ if (first == null) {
+ return system.getLastEntityConsulted();
+ }
+
+ return null;
+ }
+
+ static LeafType getTypeIfExisting(ActivityDiagram system, Code code) {
+ if (system.leafExist(code)) {
+ final IEntity ent = system.getLeafsget(code);
+ if (ent.getEntityType() == LeafType.BRANCH) {
+ return LeafType.BRANCH;
+ }
+ }
+ return LeafType.ACTIVITY;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java
new file mode 100644
index 0000000..7e2c6a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java
@@ -0,0 +1,203 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+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.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram> {
+
+ public CommandLinkLongActivity() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*([^%g]*)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?[%s]*(\\<\\<.*\\>\\>)?[%s]*(?:in[%s]+([%g][^%g]+[%g]|\\S+))?[%s]*(#\\w+)?$";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOptional(//
+ new RegexOr("FIRST", //
+ new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
+ new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("ARROW", "([-=.]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[-=.]*\\>)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("DESC", "[%g]([^%g]*?)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("$"));
+ }
+
+ public CommandExecutionResult executeNow(final ActivityDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+
+ final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
+
+ if (line0.get("STEREOTYPE", 0) != null) {
+ entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
+ }
+ if (line0.get("BACKCOLOR", 0) != null) {
+ entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(line0.get("BACKCOLOR", 0)));
+ }
+ final StringBuilder sb = new StringBuilder();
+
+ final String desc0 = line0.get("DESC", 0);
+ Url urlActivity = null;
+ if (StringUtils.isNotEmpty(desc0)) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ urlActivity = urlBuilder.getUrl(desc0);
+ if (urlActivity == null) {
+ sb.append(desc0);
+ sb.append("\\n");
+ }
+ }
+ for (int i = 1; i < lines.size() - 1; i++) {
+ if (i == 1 && urlActivity == null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ urlActivity = urlBuilder.getUrl(lines.get(i));
+ if (urlActivity != null) {
+ continue;
+ }
+ }
+ sb.append(lines.get(i));
+ if (i < lines.size() - 2) {
+ sb.append("\\n");
+ }
+ }
+
+ final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
+ lines.get(lines.size() - 1));
+ if (StringUtils.isNotEmpty(lineLast.get(0))) {
+ if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
+ sb.append("\\n");
+ }
+ sb.append(lineLast.get(0));
+ }
+
+ final String display = sb.toString();
+ final Code code = Code.of(lineLast.get(1) == null ? display : lineLast.get(1));
+
+ String partition = null;
+ if (lineLast.get(3) != null) {
+ partition = lineLast.get(3);
+ partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
+ }
+ if (partition != null) {
+ diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ null);
+ }
+ final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
+ if (partition != null) {
+ diagram.endGroup();
+ }
+ if (urlActivity != null) {
+ entity2.addUrl(urlActivity);
+ }
+
+ if (lineLast.get(2) != null) {
+ entity2.setStereotype(new Stereotype(lineLast.get(2)));
+ }
+ if (lineLast.get(4) != null) {
+ entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(lineLast.get(4)));
+ }
+
+ if (entity1 == null || entity2 == null) {
+ return CommandExecutionResult.error("No such entity");
+ }
+
+ final String arrow = StringUtils.manageArrowForCuca(line0.get("ARROW", 0));
+ final int lenght = arrow.length() - 1;
+
+ final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0));
+
+ LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
+ if (line0.get("ARROW", 0).contains(".")) {
+ type = type.getDotted();
+ }
+ Link link = new Link(entity1, entity2, type, linkLabel, lenght);
+ final Direction direction = StringUtils.getArrowDirection(line0.get("ARROW", 0));
+ if (direction == Direction.LEFT || direction == Direction.UP) {
+ link = link.getInv();
+ }
+
+ if (line0.get("URL", 0) != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
+ link.setUrl(urlLink);
+ }
+
+ diagram.addLink(link);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity2.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity2.java
new file mode 100644
index 0000000..7c57629
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity2.java
@@ -0,0 +1,220 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+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.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram> {
+
+ public CommandLinkLongActivity2() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*([^%g]*)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?[%s]*(\\<\\<.*\\>\\>)?[%s]*(?:in[%s]+([%g][^%g]+[%g]|\\S+))?[%s]*(#\\w+)?$";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOptional(//
+ new RegexOr("FIRST", //
+ new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
+ new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+
+ new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
+ new RegexLeaf("ARROW_STYLE1",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), //
+ new RegexLeaf("ARROW_STYLE2",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), //
+
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("DESC", "[%g]([^%g]*?)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("$"));
+ }
+
+ public CommandExecutionResult executeNow(final ActivityDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+
+ final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
+
+ if (line0.get("STEREOTYPE", 0) != null) {
+ entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
+ }
+ if (line0.get("BACKCOLOR", 0) != null) {
+ entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(line0.get("BACKCOLOR", 0)));
+ }
+ final StringBuilder sb = new StringBuilder();
+
+ final String desc0 = line0.get("DESC", 0);
+ Url urlActivity = null;
+ if (StringUtils.isNotEmpty(desc0)) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ urlActivity = urlBuilder.getUrl(desc0);
+ if (urlActivity == null) {
+ sb.append(desc0);
+ sb.append("\\n");
+ }
+ }
+ for (int i = 1; i < lines.size() - 1; i++) {
+ if (i == 1 && urlActivity == null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ urlActivity = urlBuilder.getUrl(lines.get(i));
+ if (urlActivity != null) {
+ continue;
+ }
+ }
+ sb.append(lines.get(i));
+ if (i < lines.size() - 2) {
+ sb.append("\\n");
+ }
+ }
+
+ final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
+ lines.get(lines.size() - 1));
+ if (StringUtils.isNotEmpty(lineLast.get(0))) {
+ if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
+ sb.append("\\n");
+ }
+ sb.append(lineLast.get(0));
+ }
+
+ final String display = sb.toString();
+ final Code code = Code.of(lineLast.get(1) == null ? display : lineLast.get(1));
+
+ String partition = null;
+ if (lineLast.get(3) != null) {
+ partition = lineLast.get(3);
+ partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
+ }
+ if (partition != null) {
+ diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ null);
+ }
+ final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
+ if (partition != null) {
+ diagram.endGroup();
+ }
+ if (urlActivity != null) {
+ entity2.addUrl(urlActivity);
+ }
+
+ if (lineLast.get(2) != null) {
+ entity2.setStereotype(new Stereotype(lineLast.get(2)));
+ }
+ if (lineLast.get(4) != null) {
+ entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(lineLast.get(4)));
+ }
+
+ if (entity1 == null || entity2 == null) {
+ return CommandExecutionResult.error("No such entity");
+ }
+
+ final String arrowBody1 = CommandLinkClass.notNull(line0.get("ARROW_BODY1", 0));
+ final String arrowBody2 = CommandLinkClass.notNull(line0.get("ARROW_BODY2", 0));
+ final String arrowDirection = CommandLinkClass.notNull(line0.get("ARROW_DIRECTION", 0));
+
+ final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">");
+
+ final int lenght = arrow.length() - 1;
+
+ final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0));
+
+ LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
+ if (arrow.contains(".")) {
+ type = type.getDotted();
+ }
+ Link link = new Link(entity1, entity2, type, linkLabel, lenght);
+ final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
+ if (direction == Direction.LEFT || direction == Direction.UP) {
+ link = link.getInv();
+ }
+
+ if (line0.get("URL", 0) != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
+ link.setUrl(urlLink);
+ }
+
+ CommandLinkClass.applyStyle(line0.getLazzy("ARROW_STYLE", 0), link);
+ diagram.addLink(link);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java
new file mode 100644
index 0000000..c4e3cee
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandPartition extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandPartition() {
+ super("(?i)^partition[%s]+([%g][^%g]+[%g]|\\S+)[%s]*(#[0-9a-fA-F]{6}|#?\\w+)?[%s]*\\{?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
+ final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)));
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(code), GroupType.PACKAGE,
+ currentPackage);
+ final String color = arg.get(1);
+ if (color != null) {
+ p.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}