mirror of
https://github.com/octoleo/plantuml.git
synced 2025-04-11 04:21:51 +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.IRegex;
|
||||||
import net.sourceforge.plantuml.regex.RegexConcat;
|
import net.sourceforge.plantuml.regex.RegexConcat;
|
||||||
import net.sourceforge.plantuml.regex.RegexLeaf;
|
import net.sourceforge.plantuml.regex.RegexLeaf;
|
||||||
|
import net.sourceforge.plantuml.regex.RegexOptional;
|
||||||
import net.sourceforge.plantuml.regex.RegexResult;
|
import net.sourceforge.plantuml.regex.RegexResult;
|
||||||
import net.sourceforge.plantuml.stereo.Stereotype;
|
import net.sourceforge.plantuml.stereo.Stereotype;
|
||||||
import net.sourceforge.plantuml.utils.LineLocation;
|
import net.sourceforge.plantuml.utils.LineLocation;
|
||||||
@ -63,7 +64,14 @@ public class CommandCreateAttribute extends SingleLineCommand2<ChenEerDiagram> {
|
|||||||
private static IRegex getRegexConcat() {
|
private static IRegex getRegexConcat() {
|
||||||
return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), //
|
return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), //
|
||||||
RegexLeaf.spaceZeroOrMore(),
|
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(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexLeaf("STEREO", "(<<.*>>)?"), //
|
new RegexLeaf("STEREO", "(<<.*>>)?"), //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
@ -80,16 +88,19 @@ public class CommandCreateAttribute extends SingleLineCommand2<ChenEerDiagram> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final LeafType type = LeafType.CHEN_ATTRIBUTE;
|
final LeafType type = LeafType.CHEN_ATTRIBUTE;
|
||||||
final String name = diagram.cleanId(arg.get("NAME", 0).trim());
|
final String idShort = diagram.cleanId(arg.get("CODE", 0).trim());
|
||||||
final String id = owner.getName() + "/" + name;
|
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 String stereo = arg.get("STEREO", 0);
|
||||||
final boolean composite = arg.get("COMPOSITE", 0) != null;
|
final boolean composite = arg.get("COMPOSITE", 0) != null;
|
||||||
|
|
||||||
final Quark<Entity> quark = diagram.quarkInContext(true, id);
|
|
||||||
|
|
||||||
Entity entity = quark.getData();
|
Entity entity = quark.getData();
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
final Display display = Display.getWithNewlines(name);
|
final Display display = Display.getWithNewlines(displayText);
|
||||||
entity = diagram.reallyCreateLeaf(quark, display, type, null);
|
entity = diagram.reallyCreateLeaf(quark, display, type, null);
|
||||||
} else {
|
} else {
|
||||||
return CommandExecutionResult.error("Attribute already exists");
|
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.IRegex;
|
||||||
import net.sourceforge.plantuml.regex.RegexConcat;
|
import net.sourceforge.plantuml.regex.RegexConcat;
|
||||||
import net.sourceforge.plantuml.regex.RegexLeaf;
|
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.regex.RegexResult;
|
||||||
import net.sourceforge.plantuml.stereo.Stereotype;
|
import net.sourceforge.plantuml.stereo.Stereotype;
|
||||||
import net.sourceforge.plantuml.utils.LineLocation;
|
import net.sourceforge.plantuml.utils.LineLocation;
|
||||||
@ -60,7 +62,14 @@ public class CommandCreateEntity extends SingleLineCommand2<ChenEerDiagram> {
|
|||||||
return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), //
|
return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), //
|
||||||
new RegexLeaf("TYPE", "(entity|relationship)"), //
|
new RegexLeaf("TYPE", "(entity|relationship)"), //
|
||||||
RegexLeaf.spaceOneOrMore(), //
|
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(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexLeaf("STEREO", "(<<.+>>)?"), //
|
new RegexLeaf("STEREO", "(<<.+>>)?"), //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
@ -83,14 +92,18 @@ public class CommandCreateEntity extends SingleLineCommand2<ChenEerDiagram> {
|
|||||||
throw new IllegalStateException();
|
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 String stereo = arg.get("STEREO", 0);
|
||||||
|
|
||||||
final Quark<Entity> quark = diagram.quarkInContext(true, name);
|
|
||||||
Entity entity = quark.getData();
|
Entity entity = quark.getData();
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
Display display = Display.getWithNewlines(name);
|
Display display = Display.getWithNewlines(displayText);
|
||||||
entity = diagram.reallyCreateLeaf(quark, display, type, null);
|
entity = diagram.reallyCreateLeaf(quark, display, type, null);
|
||||||
} else {
|
} else {
|
||||||
if (entity.muteToType(type, null) == false)
|
if (entity.muteToType(type, null) == false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user