mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-25 22:37:33 +00:00
Merge pull request #979 from gwilherm/evol/link-in-ref
Evol/link in ref
This commit is contained in:
commit
c88448d3da
@ -45,6 +45,10 @@ import net.sourceforge.plantuml.UrlMode;
|
|||||||
import net.sourceforge.plantuml.command.BlocLines;
|
import net.sourceforge.plantuml.command.BlocLines;
|
||||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||||
import net.sourceforge.plantuml.command.CommandMultilines;
|
import net.sourceforge.plantuml.command.CommandMultilines;
|
||||||
|
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.cucadiagram.Display;
|
||||||
import net.sourceforge.plantuml.sequencediagram.Participant;
|
import net.sourceforge.plantuml.sequencediagram.Participant;
|
||||||
import net.sourceforge.plantuml.sequencediagram.Reference;
|
import net.sourceforge.plantuml.sequencediagram.Reference;
|
||||||
@ -55,24 +59,43 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
|
|||||||
public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<SequenceDiagram> {
|
public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<SequenceDiagram> {
|
||||||
|
|
||||||
public CommandReferenceMultilinesOverSeveral() {
|
public CommandReferenceMultilinesOverSeveral() {
|
||||||
super("^ref(#\\w+)?[%s]+over[%s]+((?:[%pLN_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[%pLN_.@]+|[%g][^%g]+[%g]))*)[%s]*(#\\w+)?$");
|
super(getConcat().getPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RegexConcat getConcat() {
|
||||||
|
return RegexConcat.build(CommandReferenceMultilinesOverSeveral.class.getName(),
|
||||||
|
RegexLeaf.start(), //
|
||||||
|
new RegexLeaf("ref"), //
|
||||||
|
new RegexLeaf("REF", "(#\\w+)?"), //
|
||||||
|
RegexLeaf.spaceOneOrMore(), //
|
||||||
|
new RegexLeaf("over"), //
|
||||||
|
RegexLeaf.spaceOneOrMore(), //
|
||||||
|
new RegexLeaf("PARTS", "((?:[%pLN_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[%pLN_.@]+|[%g][^%g]+[%g]))*)"), //
|
||||||
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
|
new RegexOptional(new RegexLeaf("URL", "(\\[\\[.*?\\]\\])")), //
|
||||||
|
RegexLeaf.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPatternEnd() {
|
public String getPatternEnd() {
|
||||||
return "^end[%s]?(ref)?$";
|
return "^end[%s]?(ref)?$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult execute(final SequenceDiagram diagram, BlocLines lines) throws NoSuchColorException {
|
public CommandExecutionResult execute(final SequenceDiagram diagram, BlocLines lines) throws NoSuchColorException {
|
||||||
final List<String> line0 = StringUtils.getSplit(getStartingPattern(),
|
String firstLine = lines.getFirst().getTrimmed().getString();
|
||||||
lines.getFirst().getTrimmed().getString());
|
RegexResult arg = getConcat().matcher(firstLine);
|
||||||
final String s1 = line0.get(0);
|
if (arg == null) {
|
||||||
|
return CommandExecutionResult.error("Cannot parse line " + firstLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
String s1 = arg.get("REF", 0);
|
||||||
final HColor backColorElement = s1 == null ? null
|
final HColor backColorElement = s1 == null ? null
|
||||||
: diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s1);
|
: diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s1);
|
||||||
// final HtmlColor backColorGeneral =
|
// final HtmlColor backColorGeneral =
|
||||||
// HtmlColorSetSimple.instance().getColorIfValid(line0.get(1));
|
// HtmlColorSetSimple.instance().getColorIfValid(line0.get(1));
|
||||||
|
|
||||||
final List<String> participants = StringUtils.splitComma(line0.get(1));
|
final List<String> participants = StringUtils.splitComma(arg.get("PARTS", 0));
|
||||||
final List<Participant> p = new ArrayList<>();
|
final List<Participant> p = new ArrayList<>();
|
||||||
for (String s : participants) {
|
for (String s : participants) {
|
||||||
p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
|
p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
|
||||||
@ -82,13 +105,11 @@ public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<Seq
|
|||||||
lines = lines.removeEmptyColumns();
|
lines = lines.removeEmptyColumns();
|
||||||
Display strings = lines.toDisplay();
|
Display strings = lines.toDisplay();
|
||||||
|
|
||||||
|
String url = arg.get("URL", 0);
|
||||||
|
final UrlBuilder b = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
|
||||||
Url u = null;
|
Url u = null;
|
||||||
if (strings.size() > 0) {
|
if (url != null) {
|
||||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
|
u = b.getUrl(url);
|
||||||
u = urlBuilder.getUrl(strings.get(0).toString());
|
|
||||||
}
|
|
||||||
if (u != null) {
|
|
||||||
strings = strings.subList(1, strings.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final HColor backColorGeneral = null;
|
final HColor backColorGeneral = null;
|
||||||
|
@ -72,9 +72,10 @@ public class CommandReferenceOverSeveral extends SingleLineCommand2<SequenceDiag
|
|||||||
new RegexLeaf("PARTS",
|
new RegexLeaf("PARTS",
|
||||||
"(([%pLN_.@]+|[%g][^%g]+[%g])([%s]*,[%s]*([%pLN_.@]+|[%g][^%g]+[%g]))*)"), //
|
"(([%pLN_.@]+|[%g][^%g]+[%g])([%s]*,[%s]*([%pLN_.@]+|[%g][^%g]+[%g]))*)"), //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
|
new RegexOptional(new RegexLeaf("URL", "(\\[\\[.*?\\]\\])")), //
|
||||||
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexLeaf(":"), //
|
new RegexLeaf(":"), //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexOptional(new RegexLeaf("URL", "(\\[\\[.*?\\]\\])")), //
|
|
||||||
new RegexLeaf("TEXT", "(.*)"), RegexLeaf.end());
|
new RegexLeaf("TEXT", "(.*)"), RegexLeaf.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ public class CommandReferenceOverSeveral extends SingleLineCommand2<SequenceDiag
|
|||||||
|
|
||||||
final Display strings = Display.getWithNewlines(text);
|
final Display strings = Display.getWithNewlines(text);
|
||||||
|
|
||||||
final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT);
|
final UrlBuilder b = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
|
||||||
Url u = null;
|
Url u = null;
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
u = b.getUrl(url);
|
u = b.getUrl(url);
|
||||||
|
Loading…
Reference in New Issue
Block a user