mirror of
https://github.com/octoleo/plantuml.git
synced 2024-06-07 02:40:52 +00:00
Tweak Chen EER syntax to be more consistent with existing diagram types
This commit is contained in:
parent
c91b5e2015
commit
e26ccf756a
|
@ -59,8 +59,8 @@ public class ChenEerDiagramFactory extends PSystemCommandFactory {
|
||||||
@Override
|
@Override
|
||||||
protected void initCommandsList(List<Command> cmds) {
|
protected void initCommandsList(List<Command> cmds) {
|
||||||
cmds.add(new CommandCreateEntity());
|
cmds.add(new CommandCreateEntity());
|
||||||
cmds.add(new CommandCreateAttribute());
|
|
||||||
cmds.add(new CommandCreateRelationship());
|
cmds.add(new CommandCreateRelationship());
|
||||||
|
cmds.add(new CommandCreateAttribute());
|
||||||
cmds.add(new CommandAssociateRelationship());
|
cmds.add(new CommandAssociateRelationship());
|
||||||
cmds.add(new CommandEndGroup());
|
cmds.add(new CommandEndGroup());
|
||||||
|
|
||||||
|
|
|
@ -61,37 +61,41 @@ public class CommandAssociateRelationship extends SingleLineCommand2<ChenEerDiag
|
||||||
|
|
||||||
private static IRegex getRegexConcat() {
|
private static IRegex getRegexConcat() {
|
||||||
return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), //
|
return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), //
|
||||||
|
new RegexLeaf("NAME1", "([\\w-]+)"), //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexLeaf("PARTICIPATION", "([-=])"), //
|
new RegexLeaf("PARTICIPATION", "([-=])"), //
|
||||||
new RegexOptional( //
|
new RegexOptional( //
|
||||||
new RegexLeaf("CARDINALITY", "(\\w+|\\(\\w+,[%s]*\\w+\\))")), //
|
new RegexLeaf("CARDINALITY", "(\\w+|\\(\\w+,[%s]*\\w+\\))")), //
|
||||||
RegexLeaf.spaceOneOrMore(), //
|
new RegexLeaf("PARTICIPATION2", "([-=])"), //
|
||||||
new RegexLeaf("NAME", "([\\w-]+)"), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
|
new RegexLeaf("NAME2", "([\\w-]+)"), //
|
||||||
RegexLeaf.end());
|
RegexLeaf.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CommandExecutionResult executeArg(ChenEerDiagram diagram, LineLocation location, RegexResult arg)
|
protected CommandExecutionResult executeArg(ChenEerDiagram diagram, LineLocation location, RegexResult arg)
|
||||||
throws NoSuchColorException {
|
throws NoSuchColorException {
|
||||||
final Entity relationship = diagram.peekOwner();
|
final String name1 = diagram.cleanId(arg.get("NAME1", 0));
|
||||||
if (relationship == null) {
|
final String name2 = diagram.cleanId(arg.get("NAME2", 0));
|
||||||
return CommandExecutionResult.error("Can only associate from a relationship");
|
|
||||||
|
final Quark<Entity> quark1 = diagram.quarkInContext(true, name1);
|
||||||
|
final Entity entity1 = quark1.getData();
|
||||||
|
if (entity1 == null) {
|
||||||
|
return CommandExecutionResult.error("No such entity: " + name1);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String entityName = diagram.cleanId(arg.get("NAME", 0));
|
final Quark<Entity> quark2 = diagram.quarkInContext(true, name2);
|
||||||
|
final Entity entity2 = quark2.getData();
|
||||||
final Quark<Entity> entityQuark = diagram.quarkInContext(true, entityName);
|
if (entity2 == null) {
|
||||||
final Entity entity = entityQuark.getData();
|
return CommandExecutionResult.error("No such entity: " + name2);
|
||||||
if (entity == null) {
|
|
||||||
return CommandExecutionResult.error("No such entity: " + entityName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final LinkType linkType = new LinkType(LinkDecor.NONE, LinkDecor.NONE);
|
final LinkType linkType = new LinkType(LinkDecor.NONE, LinkDecor.NONE);
|
||||||
final Link link = new Link(diagram.getEntityFactory(), diagram.getCurrentStyleBuilder(), relationship, entity,
|
final Link link = new Link(diagram.getEntityFactory(), diagram.getCurrentStyleBuilder(), entity1, entity2,
|
||||||
linkType,
|
linkType,
|
||||||
// TODO: Cardinality
|
// TODO: Cardinality
|
||||||
LinkArg.build(Display.NULL, 3));
|
LinkArg.build(Display.NULL, 3));
|
||||||
link.setPortMembers(diagram.getPortId(relationship.getName()), diagram.getPortId(entity.getName()));
|
link.setPortMembers(diagram.getPortId(entity1.getName()), diagram.getPortId(entity2.getName()));
|
||||||
diagram.addLink(link);
|
diagram.addLink(link);
|
||||||
|
|
||||||
return CommandExecutionResult.ok();
|
return CommandExecutionResult.ok();
|
||||||
|
|
|
@ -63,27 +63,11 @@ 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 RegexOptional( //
|
new RegexLeaf("NAME", "([^<>{}-]+)"), //
|
||||||
new RegexConcat( //
|
new RegexOptional(//
|
||||||
new RegexLeaf("MULTI", "multi"), //
|
new RegexConcat(
|
||||||
RegexLeaf.spaceOneOrMore())), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
new RegexOptional( //
|
new RegexLeaf("STEREOTYPE", "(<<.+>>)"))), //
|
||||||
new RegexConcat( //
|
|
||||||
new RegexLeaf("DERIVED", "derived"), //
|
|
||||||
RegexLeaf.spaceOneOrMore())), //
|
|
||||||
new RegexOptional( //
|
|
||||||
new RegexConcat( //
|
|
||||||
new RegexOptional( //
|
|
||||||
new RegexConcat( //
|
|
||||||
new RegexLeaf("PARTIAL", "partial"), //
|
|
||||||
RegexLeaf.spaceOneOrMore())),
|
|
||||||
new RegexLeaf("KEY", "key"), //
|
|
||||||
RegexLeaf.spaceOneOrMore())), //
|
|
||||||
new RegexOptional( //
|
|
||||||
new RegexConcat( //
|
|
||||||
new RegexLeaf("attr(:?ibute)?"), //
|
|
||||||
RegexLeaf.spaceOneOrMore())), //
|
|
||||||
new RegexLeaf("NAME", "(\\w+)"), //
|
|
||||||
new RegexOptional(//
|
new RegexOptional(//
|
||||||
new RegexConcat( //
|
new RegexConcat( //
|
||||||
RegexLeaf.spaceZeroOrMore(), //
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
|
@ -104,6 +88,8 @@ public class CommandCreateAttribute extends SingleLineCommand2<ChenEerDiagram> {
|
||||||
final String id = owner.getName() + "/" + name;
|
final String id = owner.getName() + "/" + name;
|
||||||
final boolean composite = arg.get("COMPOSITE", 0) != null;
|
final boolean composite = arg.get("COMPOSITE", 0) != null;
|
||||||
|
|
||||||
|
// TODO: stereotypes: multi, derived, key, partial key
|
||||||
|
|
||||||
final Quark<Entity> quark = diagram.quarkInContext(true, id);
|
final Quark<Entity> quark = diagram.quarkInContext(true, id);
|
||||||
|
|
||||||
Entity entity = quark.getData();
|
Entity entity = quark.getData();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user