summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java')
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
index 890249b..40e012b 100644
--- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.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,26 +35,38 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+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.RegexResult;
import net.sourceforge.plantuml.sequencediagram.LifeEventType;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
-public class CommandActivate2 extends SingleLineCommand<SequenceDiagram> {
+public class CommandActivate2 extends SingleLineCommand2<SequenceDiagram> {
public CommandActivate2() {
- super("(?i)^([\\p{L}0-9_.@]+)[%s]*(\\+\\+|--)[%s]*(#\\w+)?$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandActivate2.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_.@]+)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("TYPE", "(\\+\\+|--)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("COLOR", "(#\\w+)?"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
- final LifeEventType type = arg.get(1).equals("++") ? LifeEventType.ACTIVATE : LifeEventType.DEACTIVATE;
- final Participant p = diagram.getOrCreateParticipant(arg.get(0));
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
+ final LifeEventType type = arg.get("TYPE", 0).equals("++") ? LifeEventType.ACTIVATE : LifeEventType.DEACTIVATE;
+ final Participant p = diagram.getOrCreateParticipant(arg.get("NAME", 0));
final String error = diagram.activate(p, type,
- diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(2)));
+ diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
if (error == null) {
return CommandExecutionResult.ok();
}