mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-21 20:45:10 +00:00
Support long name and alias in Chen-EER
This commit is contained in:
parent
8312e8c22f
commit
90a88ce4ee
@ -50,6 +50,7 @@ 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.stereo.Stereotype;
|
||||
import net.sourceforge.plantuml.utils.LineLocation;
|
||||
@ -63,7 +64,14 @@ public class CommandCreateAttribute extends SingleLineCommand2<ChenEerDiagram> {
|
||||
private static IRegex getRegexConcat() {
|
||||
return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), //
|
||||
RegexLeaf.spaceZeroOrMore(),
|
||||
new RegexLeaf("NAME", "([^<>{}=-]+)"), //
|
||||
new RegexOptional( // Copied from CommandCreatePackageBlock
|
||||
new RegexConcat( //
|
||||
new RegexLeaf("DISPLAY", "[%g]([^%g]+)[%g]"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("as"), //
|
||||
RegexLeaf.spaceOneOrMore() //
|
||||
)), //
|
||||
new RegexLeaf("CODE", "([%pLN%s_.:<>]+)"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("STEREO", "(<<.*>>)?"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
@ -80,16 +88,19 @@ public class CommandCreateAttribute extends SingleLineCommand2<ChenEerDiagram> {
|
||||
}
|
||||
|
||||
final LeafType type = LeafType.CHEN_ATTRIBUTE;
|
||||
final String name = diagram.cleanId(arg.get("NAME", 0).trim());
|
||||
final String id = owner.getName() + "/" + name;
|
||||
final String idShort = diagram.cleanId(arg.get("CODE", 0).trim());
|
||||
final String id = owner.getName() + "/" + idShort;
|
||||
final Quark<Entity> quark = diagram.quarkInContext(true, id);
|
||||
String displayText = arg.get("DISPLAY", 0);
|
||||
if (displayText == null)
|
||||
displayText = quark.getName();
|
||||
|
||||
final String stereo = arg.get("STEREO", 0);
|
||||
final boolean composite = arg.get("COMPOSITE", 0) != null;
|
||||
|
||||
final Quark<Entity> quark = diagram.quarkInContext(true, id);
|
||||
|
||||
Entity entity = quark.getData();
|
||||
if (entity == null) {
|
||||
final Display display = Display.getWithNewlines(name);
|
||||
final Display display = Display.getWithNewlines(displayText);
|
||||
entity = diagram.reallyCreateLeaf(quark, display, type, null);
|
||||
} else {
|
||||
return CommandExecutionResult.error("Attribute already exists");
|
||||
|
@ -46,6 +46,8 @@ 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.RegexOr;
|
||||
import net.sourceforge.plantuml.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.stereo.Stereotype;
|
||||
import net.sourceforge.plantuml.utils.LineLocation;
|
||||
@ -60,7 +62,14 @@ public class CommandCreateEntity extends SingleLineCommand2<ChenEerDiagram> {
|
||||
return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), //
|
||||
new RegexLeaf("TYPE", "(entity|relationship)"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("NAME", "([^<>{}]+)"), //
|
||||
new RegexOptional( // Copied from CommandCreatePackageBlock
|
||||
new RegexConcat( //
|
||||
new RegexLeaf("DISPLAY", "[%g]([^%g]+)[%g]"), //
|
||||
RegexLeaf.spaceOneOrMore(), //
|
||||
new RegexLeaf("as"), //
|
||||
RegexLeaf.spaceOneOrMore() //
|
||||
)), //
|
||||
new RegexLeaf("CODE", "([%pLN_.]+)"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("STEREO", "(<<.+>>)?"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
@ -83,14 +92,18 @@ public class CommandCreateEntity extends SingleLineCommand2<ChenEerDiagram> {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
final String name = diagram.cleanId(arg.get("NAME", 0).trim());
|
||||
final String idShort = arg.get("CODE", 0);
|
||||
final Quark<Entity> quark = diagram.quarkInContext(true, diagram.cleanId(idShort));
|
||||
String displayText = arg.get("DISPLAY", 0);
|
||||
if (displayText == null)
|
||||
displayText = quark.getName();
|
||||
|
||||
final String stereo = arg.get("STEREO", 0);
|
||||
|
||||
final Quark<Entity> quark = diagram.quarkInContext(true, name);
|
||||
Entity entity = quark.getData();
|
||||
|
||||
if (entity == null) {
|
||||
Display display = Display.getWithNewlines(name);
|
||||
Display display = Display.getWithNewlines(displayText);
|
||||
entity = diagram.reallyCreateLeaf(quark, display, type, null);
|
||||
} else {
|
||||
if (entity.muteToType(type, null) == false)
|
||||
|
Loading…
Reference in New Issue
Block a user