From be3a3cd88364d02ef7fbc62f2c3c2e459ce00b1e Mon Sep 17 00:00:00 2001 From: alfonsodelavega Date: Tue, 10 Jan 2023 12:15:52 +0100 Subject: [PATCH 1/7] Add modern PlantUML visualisation to picto xtext example --- .../xtend-gen/.gitignore | 3 + .../dmodel.egx | 12 ---- .../picto/dmodel.egx | 36 ++++++++++ .../{ => picto}/entity2graphviz.egl | 5 +- .../picto/entity2plantuml.egl | 68 ++++++++++++++++++ .../{ => picto}/icons/attribute.gif | Bin .../{ => picto}/icons/entity.gif | Bin .../picto/typeStats.pinset | 7 ++ .../domainmodel/picto/DmodelPictoSource.java | 5 +- ...odel.picto => standaloneTest.dmodel.picto} | 4 +- .../xtend-gen/.gitignore | 4 ++ .../PlantUmlContentTransformer.java | 1 + 12 files changed, 128 insertions(+), 17 deletions(-) create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.ide/xtend-gen/.gitignore delete mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/dmodel.egx create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx rename examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/{ => picto}/entity2graphviz.egl (96%) create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl rename examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/{ => picto}/icons/attribute.gif (100%) rename examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/{ => picto}/icons/entity.gif (100%) create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/typeStats.pinset rename examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/{test.dmodel.picto => standaloneTest.dmodel.picto} (63%) create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.ui/xtend-gen/.gitignore diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.ide/xtend-gen/.gitignore b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.ide/xtend-gen/.gitignore new file mode 100644 index 0000000000..070c2141ef --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.ide/xtend-gen/.gitignore @@ -0,0 +1,3 @@ +src +src-gen +plugin.xml \ No newline at end of file diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/dmodel.egx b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/dmodel.egx deleted file mode 100644 index 0d95cede99..0000000000 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/dmodel.egx +++ /dev/null @@ -1,12 +0,0 @@ -rule Entity2Graphviz - transform e : Entity { - - template : "entity2graphviz.egl" - - parameters : Map{ - "path" = Sequence{"Model", e.name}, - "icon" = "diagram-ffffff", - "format" = "graphviz-dot" - } - -} \ No newline at end of file diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx new file mode 100644 index 0000000000..983b1acbac --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx @@ -0,0 +1,36 @@ +rule Entity2Graphviz + transform e : Entity { + + template : "entity2graphviz.egl" + + parameters : Map{ + "path" = Sequence{"Graphviz", e.name}, + "icon" = "diagram-ffffff", + "format" = "graphviz-dot" + } + +} + +rule Entity2PlantUML + transform e : Entity { + + template : "entity2plantuml.egl" + + parameters : Map{ + "path" = Sequence{"Entities", e.name}, + "icon" = "diagram-ffffff", + "format" = "plantuml" + } + +} + +rule TypeStats { + template : "typeStats.pinset" + + parameters : Map { + "path" = Sequence{"Type stats"}, + "icon" = "table", + "format" = "csv", + "position" = "0" + } +} \ No newline at end of file diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/entity2graphviz.egl b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2graphviz.egl similarity index 96% rename from examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/entity2graphviz.egl rename to examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2graphviz.egl index 7e81ff9535..edeede79cf 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/entity2graphviz.egl +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2graphviz.egl @@ -26,7 +26,7 @@ digraph G { [% operation Entity getLabel() { - var onClick = "top.showView(['Model','" + self.name + "'])"; + var onClick = "top.showView(['Graphviz','" + self.name + "'])"; if (self == e) { onClick = "top.showElement('" + self.id + "', '" + self.eResource.uri + "')"; @@ -54,6 +54,9 @@ operation Entity getLabel() { } label += ""; + + label.println(); + return label; } diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl new file mode 100644 index 0000000000..2106b7b9a8 --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl @@ -0,0 +1,68 @@ +@startuml +hide empty methods +hide circle +skinparam classBorderThickness 1 +!pragma layout smetana +skinparam classFontName system-ui + +[%var entities = getVisibleEntities();%] + +[%for (ent in entities){%] + class [%=ent.name%] [[javascript:top.[%=ent.getLink()%]]] [%=ent.getColour()%] { + [%for (f in ent.features){%] + [%=f.name%] : [%=f.type.name%][%=(f.many ? " ["+"*"+"]" : "")%] + [%}%] + } +[%}%] + +[%for (f in e.features.select(f|f.type.isTypeOf(Entity) and f.type <> e)){%] + [%=e.name%]-->[%=f.type.name%] : [%=f.name%][%=(f.many ? " ["+"*"+"]" : "")%] +[%}%] + +[%if (e.superType.isDefined()){%] + [%=e.superType.Name%]<|--[%=e.name%] +[%}%] + +[%for (subclass in Entity.all.select(ent | ent.superType = e)){%] + [%=e.name%]<|--[%=subclass.name%] +[%}%] + +@enduml +[%out.toString().println();%] +[% + +operation getVisibleEntities() { + var visibleEntities : Set; + visibleEntities.add(e); + + // entity features + visibleEntities.addAll( + e.features.select(f|f.type.isTypeOf(Entity)).collect(f|f.type)); + + // supertype + if (e.superType.isDefined()) visibleEntities.add(e.superType); + + // subtypes + visibleEntities.addAll(Entity.all.select(en|en.superType = e)); + + return visibleEntities; +} + +operation Entity getColour() { + if (self == e) return "#DDFADC"; + else return "#lemonchiffon"; +} + +// cannot use brackets (even encoded ones) in plantuml links, swapped with a string split +operation getPath(path : Sequence) { + var separator = "@@"; + return "'" + path.concat(separator) + "'" + ".split('" + separator + "')"; +} + +operation Entity getLink() { + if (self == e) { + return "showElement('" + self.id + "','" + self.eResource.uri + "')"; + } + return "showView(" + getPath(Sequence{"Entities", self.name})% + ")"; +} +%] diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/icons/attribute.gif b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/icons/attribute.gif similarity index 100% rename from examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/icons/attribute.gif rename to examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/icons/attribute.gif diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/icons/entity.gif b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/icons/entity.gif similarity index 100% rename from examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/icons/entity.gif rename to examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/icons/entity.gif diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/typeStats.pinset b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/typeStats.pinset new file mode 100644 index 0000000000..c3cc0dcab8 --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/typeStats.pinset @@ -0,0 +1,7 @@ +dataset typeStats over t : Type { + properties[name as Name] + + column Type : t.isTypeOf(Entity) ? "Entity" : "DataType" + + column Usages : Feature.all.select(f | f.type == t).size() +} diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/src/org/eclipse/epsilon/examples/picto/xtext/domainmodel/picto/DmodelPictoSource.java b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/src/org/eclipse/epsilon/examples/picto/xtext/domainmodel/picto/DmodelPictoSource.java index 396ab08574..dcfe5e0b07 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/src/org/eclipse/epsilon/examples/picto/xtext/domainmodel/picto/DmodelPictoSource.java +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/src/org/eclipse/epsilon/examples/picto/xtext/domainmodel/picto/DmodelPictoSource.java @@ -17,12 +17,13 @@ import org.eclipse.xtext.ui.workspace.WorkspaceLockAccess.Result; import org.eclipse.xtext.util.concurrent.IUnitOfWork; +@SuppressWarnings("restriction") public class DmodelPictoSource extends EglPictoSource { @Override protected Picto getRenderingMetadata(IEditorPart editorPart) { Picto metadata = PictoFactory.eINSTANCE.createPicto(); - metadata.setTransformation("platform:/plugin/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/dmodel.egx"); + metadata.setTransformation("platform:/plugin/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx"); return metadata; } @@ -34,7 +35,7 @@ protected Resource getResource(IEditorPart editorPart) { public Result exec(XtextResource state) throws Exception { holder.setResource(state); return null; - }; + } }); return holder.getResource(); diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/test.dmodel.picto b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/standaloneTest.dmodel.picto similarity index 63% rename from examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/test.dmodel.picto rename to examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/standaloneTest.dmodel.picto index 895297b291..7d0b12e8ac 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/test.dmodel.picto +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/standaloneTest.dmodel.picto @@ -1,8 +1,8 @@ - + - + diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.ui/xtend-gen/.gitignore b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.ui/xtend-gen/.gitignore new file mode 100644 index 0000000000..e407b8bf08 --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.ui/xtend-gen/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything +* +# But this .gitignore file +!.gitignore \ No newline at end of file diff --git a/plugins/org.eclipse.epsilon.picto/src/org/eclipse/epsilon/picto/transformers/PlantUmlContentTransformer.java b/plugins/org.eclipse.epsilon.picto/src/org/eclipse/epsilon/picto/transformers/PlantUmlContentTransformer.java index eea99686e8..b89bb56bf0 100644 --- a/plugins/org.eclipse.epsilon.picto/src/org/eclipse/epsilon/picto/transformers/PlantUmlContentTransformer.java +++ b/plugins/org.eclipse.epsilon.picto/src/org/eclipse/epsilon/picto/transformers/PlantUmlContentTransformer.java @@ -46,6 +46,7 @@ public ViewContent transform(ViewContent content, PictoView pictoView) throws Ex * @throws IOException If writing to file fails. */ public static String plantumlToRawSvg(String plant) throws IOException { + System.setProperty("PLANTUML_ALLOW_JAVASCRIPT_IN_LINK", "true"); SourceStringReader reader = new SourceStringReader(plant); try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { reader.outputImage(os, new FileFormatOption(FileFormat.SVG)); From 30563d8884832219e842ff9287b6b160a630fb64 Mon Sep 17 00:00:00 2001 From: alfonsodelavega Date: Wed, 11 Jan 2023 09:33:26 +0100 Subject: [PATCH 2/7] Enable plantuml javascript links in concrete picto transformation Instead of doing it globally in Epsilon's PlantUML transformer --- .../picto/dmodel.egx | 2 +- .../picto/entity2plantuml.egl | 7 ++++++- .../picto/transformers/PlantUmlContentTransformer.java | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx index 983b1acbac..c450d207fa 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx @@ -17,7 +17,7 @@ rule Entity2PlantUML template : "entity2plantuml.egl" parameters : Map{ - "path" = Sequence{"Entities", e.name}, + "path" = Sequence{"PlantUML", e.name}, "icon" = "diagram-ffffff", "format" = "plantuml" } diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl index 2106b7b9a8..6c918c9487 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl @@ -1,3 +1,8 @@ +[% +// Enable javascript links (disabled by default for security reasons) +Native("java.lang.System").setProperty("PLANTUML_ALLOW_JAVASCRIPT_IN_LINK", "true"); +%] + @startuml hide empty methods hide circle @@ -63,6 +68,6 @@ operation Entity getLink() { if (self == e) { return "showElement('" + self.id + "','" + self.eResource.uri + "')"; } - return "showView(" + getPath(Sequence{"Entities", self.name})% + ")"; + return "showView(" + getPath(Sequence{"PlantUML", self.name})% + ")"; } %] diff --git a/plugins/org.eclipse.epsilon.picto/src/org/eclipse/epsilon/picto/transformers/PlantUmlContentTransformer.java b/plugins/org.eclipse.epsilon.picto/src/org/eclipse/epsilon/picto/transformers/PlantUmlContentTransformer.java index b89bb56bf0..eea99686e8 100644 --- a/plugins/org.eclipse.epsilon.picto/src/org/eclipse/epsilon/picto/transformers/PlantUmlContentTransformer.java +++ b/plugins/org.eclipse.epsilon.picto/src/org/eclipse/epsilon/picto/transformers/PlantUmlContentTransformer.java @@ -46,7 +46,6 @@ public ViewContent transform(ViewContent content, PictoView pictoView) throws Ex * @throws IOException If writing to file fails. */ public static String plantumlToRawSvg(String plant) throws IOException { - System.setProperty("PLANTUML_ALLOW_JAVASCRIPT_IN_LINK", "true"); SourceStringReader reader = new SourceStringReader(plant); try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { reader.outputImage(os, new FileFormatOption(FileFormat.SVG)); From addb55e74dc8947f3570f4dec679cb02961da3b2 Mon Sep 17 00:00:00 2001 From: alfonsodelavega Date: Tue, 7 Feb 2023 10:41:16 +0100 Subject: [PATCH 3/7] Xtext Picto: add doc comments and improve visualisation --- .../.project | 17 ++++ .../blog.dmodel | 27 +++++++ .../readme.md | 13 ++++ .../standaloneVisualisation.dmodel.picto | 16 ++++ .../blog.dmodel | 6 ++ .../picto/barchart.egl | 77 +++++++++++++++++++ .../picto/dmodel.egx | 49 +++++++----- .../picto/entity2plantuml.egl | 65 ++++++++++------ .../picto/xtext/domainmodel/Domainmodel.xtext | 1 + 9 files changed, 227 insertions(+), 44 deletions(-) create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/.project create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/blog.dmodel create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/readme.md create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/standaloneVisualisation.dmodel.picto create mode 100644 examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/barchart.egl diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/.project b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/.project new file mode 100644 index 0000000000..83e20eface --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/.project @@ -0,0 +1,17 @@ + + + org.eclipse.epsilon.examples.picto.xtext.domainmodel.example + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/blog.dmodel b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/blog.dmodel new file mode 100644 index 0000000000..8b25061cb2 --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/blog.dmodel @@ -0,0 +1,27 @@ +datatype String + +entity Blog { + "Main entity. A blog is composed of posts" + + title: String + many posts: Post +} + +entity HasAuthor { + author: String +} + +entity Post extends HasAuthor { + "Starting message of each blog entry" + + title: String + content: String + many comments: Comment +} + +entity Comment extends HasAuthor { + "Messages that capture the discussion around a post" + + content: String + many responses: Comment +} diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/readme.md b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/readme.md new file mode 100644 index 0000000000..8e037f537e --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/readme.md @@ -0,0 +1,13 @@ +# Blog domain model report + +## Element stats + + + +## Types usage + + + +## Core Entities + + \ No newline at end of file diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/standaloneVisualisation.dmodel.picto b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/standaloneVisualisation.dmodel.picto new file mode 100644 index 0000000000..b191f2ccb6 --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.example/standaloneVisualisation.dmodel.picto @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/blog.dmodel b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/blog.dmodel index 37b5eef6a7..8b25061cb2 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/blog.dmodel +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/blog.dmodel @@ -1,6 +1,8 @@ datatype String entity Blog { + "Main entity. A blog is composed of posts" + title: String many posts: Post } @@ -10,12 +12,16 @@ entity HasAuthor { } entity Post extends HasAuthor { + "Starting message of each blog entry" + title: String content: String many comments: Comment } entity Comment extends HasAuthor { + "Messages that capture the discussion around a post" + content: String many responses: Comment } diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/barchart.egl b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/barchart.egl new file mode 100644 index 0000000000..a5baf840b6 --- /dev/null +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/barchart.egl @@ -0,0 +1,77 @@ +[% +// TODO: make a list of colours big enough to reuse this barchart with ease +var labels = Sequence{"Data types", + "Entities", + "Features"}; + +var values = Sequence{DataType.all.size(), + Entity.all.size(), + Feature.all.size()}; +%] + + + + + + +
+ +
+ + + + +[% +operation Sequence quote() { + return self.collect(elem | '"' + elem + '"') + .concat(", "); +} +%] diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx index c450d207fa..f223246673 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/dmodel.egx @@ -1,36 +1,45 @@ -rule Entity2Graphviz +rule StatsChart { + template : "barchart.egl" + + parameters : Map { + "position" = "1", + "path" = List{"Stats"}, + "icon" = "barchart", + "format" = "html" + } +} + +rule TypesTable { + template : "typeStats.pinset" + + parameters : Map { + "position" = "2", + "path" = Sequence{"Types"}, + "icon" = "table", + "format" = "csv" + } +} + +rule Entity2PlantUML transform e : Entity { - template : "entity2graphviz.egl" + template : "entity2plantuml.egl" parameters : Map{ - "path" = Sequence{"Graphviz", e.name}, + "position" = "3", + "path" = Sequence{"Entities", e.name}, "icon" = "diagram-ffffff", - "format" = "graphviz-dot" + "format" = "plantuml" } - } -rule Entity2PlantUML +@lazy +rule Entities2PlantUML transform e : Entity { template : "entity2plantuml.egl" parameters : Map{ - "path" = Sequence{"PlantUML", e.name}, - "icon" = "diagram-ffffff", "format" = "plantuml" } - } - -rule TypeStats { - template : "typeStats.pinset" - - parameters : Map { - "path" = Sequence{"Type stats"}, - "icon" = "table", - "format" = "csv", - "position" = "0" - } -} \ No newline at end of file diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl index 6c918c9487..18147d72f2 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/entity2plantuml.egl @@ -10,45 +10,62 @@ skinparam classBorderThickness 1 !pragma layout smetana skinparam classFontName system-ui -[%var entities = getVisibleEntities();%] +[% + +var entities = getVisibleEntities(); -[%for (ent in entities){%] + for (ent in entities){%] + [% if (ent.doc != null) {%] + note "[%=ent.doc%]" as nn_[%=ent.name%] #f0ffff + nn_[%=ent.name%] .. [%=ent.name%] + [%}%] class [%=ent.name%] [[javascript:top.[%=ent.getLink()%]]] [%=ent.getColour()%] { + [%for (f in ent.features){%] [%=f.name%] : [%=f.type.name%][%=(f.many ? " ["+"*"+"]" : "")%] [%}%] } [%}%] -[%for (f in e.features.select(f|f.type.isTypeOf(Entity) and f.type <> e)){%] - [%=e.name%]-->[%=f.type.name%] : [%=f.name%][%=(f.many ? " ["+"*"+"]" : "")%] -[%}%] - -[%if (e.superType.isDefined()){%] - [%=e.superType.Name%]<|--[%=e.name%] -[%}%] - -[%for (subclass in Entity.all.select(ent | ent.superType = e)){%] - [%=e.name%]<|--[%=subclass.name%] +[%if (e.isDefined()) {%] + [%for (f in e.features.select(f|f.type.isTypeOf(Entity) and f.type <> e)){%] + [%=e.name%]-->[%=f.type.name%] : [%=f.name%][%=(f.many ? " ["+"*"+"]" : "")%] + [%}%] + + [%if (e.superType.isDefined()){%] + [%=e.superType.Name%]<|--[%=e.name%] + [%}%] + + [%for (subclass in Entity.all.select(ent | ent.superType = e)){%] + [%=e.name%]<|--[%=subclass.name%] + [%}%] [%}%] @enduml -[%out.toString().println();%] +[% +//out.toString().println(); +%] [% operation getVisibleEntities() { var visibleEntities : Set; - visibleEntities.add(e); - // entity features - visibleEntities.addAll( - e.features.select(f|f.type.isTypeOf(Entity)).collect(f|f.type)); - - // supertype - if (e.superType.isDefined()) visibleEntities.add(e.superType); - - // subtypes - visibleEntities.addAll(Entity.all.select(en|en.superType = e)); + if (e.isDefined()) { + visibleEntities.add(e); + + // entity features + visibleEntities.addAll( + e.features.select(f|f.type.isTypeOf(Entity)).collect(f|f.type)); + + // supertype + if (e.superType.isDefined()) visibleEntities.add(e.superType); + + // subtypes + visibleEntities.addAll(Entity.all.select(en|en.superType = e)); + } + else if (inputEntities.isDefined()) { + visibleEntities.addAll(Entity.all.select(en | inputEntities.includes(en.name))); + } return visibleEntities; } @@ -68,6 +85,6 @@ operation Entity getLink() { if (self == e) { return "showElement('" + self.id + "','" + self.eResource.uri + "')"; } - return "showView(" + getPath(Sequence{"PlantUML", self.name})% + ")"; + return "showView(" + getPath(Sequence{"Entities", self.name})% + ")"; } %] diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel/src/org/eclipse/epsilon/examples/picto/xtext/domainmodel/Domainmodel.xtext b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel/src/org/eclipse/epsilon/examples/picto/xtext/domainmodel/Domainmodel.xtext index 95027483b9..c947f2c599 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel/src/org/eclipse/epsilon/examples/picto/xtext/domainmodel/Domainmodel.xtext +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel/src/org/eclipse/epsilon/examples/picto/xtext/domainmodel/Domainmodel.xtext @@ -29,6 +29,7 @@ DataType: Entity: 'entity' name=ID ('extends' superType=[Entity|QualifiedName])? '{' + (doc=STRING)? (features+=Feature)* '}'; From 9ae2f23b7e14e17c556e3b5b64ffa1f572e9f9ba Mon Sep 17 00:00:00 2001 From: alfonsodelavega Date: Tue, 7 Feb 2023 18:15:35 +0100 Subject: [PATCH 4/7] Xtext Picto: Add layers --- .../picto/barchart.egl | 2 +- .../picto/dmodel.egx | 60 ++++++++++--- .../picto/entity2plantuml.egl | 86 +++++++++++++++---- 3 files changed, 114 insertions(+), 34 deletions(-) diff --git a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/barchart.egl b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/barchart.egl index a5baf840b6..d585d328a7 100644 --- a/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/barchart.egl +++ b/examples/org.eclipse.epsilon.examples.picto.xtext.domainmodel.picto/picto/barchart.egl @@ -19,7 +19,7 @@ var values = Sequence{DataType.all.size(),
- +