net.sourceforge.plantuml.command.CommandPackageEmpty Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.abel.Entity;
import net.sourceforge.plantuml.abel.GroupType;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.klimt.color.ColorType;
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
import net.sourceforge.plantuml.klimt.creole.Display;
import net.sourceforge.plantuml.plasma.Quark;
import net.sourceforge.plantuml.regex.IRegex;
import net.sourceforge.plantuml.regex.RegexConcat;
import net.sourceforge.plantuml.regex.RegexLeaf;
import net.sourceforge.plantuml.regex.RegexOptional;
import net.sourceforge.plantuml.regex.RegexResult;
import net.sourceforge.plantuml.utils.LineLocation;
public class CommandPackageEmpty extends SingleLineCommand2 {
public CommandPackageEmpty() {
super(getRegexConcat());
}
static IRegex getRegexConcat() {
return RegexConcat.build(CommandPackageEmpty.class.getName(), RegexLeaf.start(), //
new RegexLeaf("package"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("DISPLAY", "([%g][^%g]+[%g]|[^#%s{}]*)"), //
new RegexOptional( //
new RegexConcat( //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("as"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("CODE", "([%pLN_.]+)") //
)), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("COLOR", "(#[0-9a-fA-F]{6}|#?\\w+)?"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("\\{"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("\\}"), //
RegexLeaf.end()); //
}
@Override
protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException {
final String idShort;
final String display;
if (arg.get("CODE", 0) == null) {
if (StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0)).length() == 0) {
idShort = "##" + diagram.getUniqueSequence();
display = null;
} else {
idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0));
display = idShort;
}
} else {
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("DISPLAY", 0));
idShort = arg.get("CODE", 0);
}
final Quark quark = diagram.quarkInContext(false, diagram.cleanId(idShort));
final CommandExecutionResult status = diagram.gotoGroup(quark, Display.getWithNewlines(display),
GroupType.PACKAGE);
if (status.isOk() == false)
return status;
final Entity p = diagram.getCurrentGroup();
final String color = arg.get("COLOR", 0);
if (color != null)
p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(color));
diagram.endGroup();
return CommandExecutionResult.ok();
}
}