From 9c656f54024fed28b1b8c28cd6a90520808a9d65 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 2 Aug 2023 08:23:44 -0400 Subject: [PATCH] Diagram generation WIP --- generator/actions.yml | 2 +- generator/pom.xml | 5 ++++ .../ecore/tests/TestNatureModelDocGen.java | 8 ++++-- .../processors/AnimalProcessorsFactory.java | 5 +++- .../processors/ColorProcessorsFactory.java | 6 ++++- .../EcoreGenTestProcessorsFactory.java | 26 ++++++++++++------- .../test/processors/FoxProcessorsFactory.java | 6 ++++- 7 files changed, 42 insertions(+), 16 deletions(-) diff --git a/generator/actions.yml b/generator/actions.yml index 3a8c9f0..3cdbc77 100644 --- a/generator/actions.yml +++ b/generator/actions.yml @@ -10,7 +10,7 @@ app-action: content: content-text: TODO children: - - app-action-reference: "target/action-models/test.gz#/" + - app-action-reference: "target/action-models/test.xmi#/" - app-action: location: ${base-uri}search.html icon: fas fa-search diff --git a/generator/pom.xml b/generator/pom.xml index 9ebd912..1eb5db5 100644 --- a/generator/pom.xml +++ b/generator/pom.xml @@ -16,6 +16,11 @@ processors ${project.version} + + org.nasdanika + plantuml-diagram-generator + 2023.4.1 + diff --git a/generator/src/test/java/org/nasdanika/models/ecore/tests/TestNatureModelDocGen.java b/generator/src/test/java/org/nasdanika/models/ecore/tests/TestNatureModelDocGen.java index c7c0744..a5dce68 100644 --- a/generator/src/test/java/org/nasdanika/models/ecore/tests/TestNatureModelDocGen.java +++ b/generator/src/test/java/org/nasdanika/models/ecore/tests/TestNatureModelDocGen.java @@ -33,12 +33,15 @@ import org.junit.jupiter.api.Test; import org.nasdanika.common.Context; import org.nasdanika.common.Diagnostic; +import org.nasdanika.common.DiagramGenerator; import org.nasdanika.common.ExecutionException; +import org.nasdanika.common.MutableContext; import org.nasdanika.common.NasdanikaException; import org.nasdanika.common.NullProgressMonitor; import org.nasdanika.common.PrintStreamProgressMonitor; import org.nasdanika.common.ProgressMonitor; import org.nasdanika.common.Transformer; +import org.nasdanika.diagramgenerator.plantuml.PlantUMLDiagramGenerator; import org.nasdanika.exec.ExecPackage; import org.nasdanika.exec.content.ContentPackage; import org.nasdanika.exec.resources.ResourcesPackage; @@ -215,10 +218,11 @@ protected boolean isPassThrough(Connection connection) { Transformer processorConfigTransformer = new Transformer<>(configFactory); Map configs = processorConfigTransformer.transform(graph.values(), false, progressMonitor); - Context context = Context.EMPTY_CONTEXT; + MutableContext context = Context.EMPTY_CONTEXT.fork(); + context.register(DiagramGenerator.class, new PlantUMLDiagramGenerator()); Consumer diagnosticConsumer = d -> d.dump(System.out, 0); List> actionProviders = new ArrayList<>(); - EcoreGenTestProcessorsFactory ecoreGenTestProcessorFactory = new EcoreGenTestProcessorsFactory(); + EcoreGenTestProcessorsFactory ecoreGenTestProcessorFactory = new EcoreGenTestProcessorsFactory(context); EcoreNodeProcessorFactory ecoreNodeProcessorFactory = new EcoreNodeProcessorFactory( context, (uri, pm) -> { diff --git a/processors/src/main/java/org/nasdanika/models/ecore/test/processors/AnimalProcessorsFactory.java b/processors/src/main/java/org/nasdanika/models/ecore/test/processors/AnimalProcessorsFactory.java index c2a3b5e..0067c88 100644 --- a/processors/src/main/java/org/nasdanika/models/ecore/test/processors/AnimalProcessorsFactory.java +++ b/processors/src/main/java/org/nasdanika/models/ecore/test/processors/AnimalProcessorsFactory.java @@ -27,8 +27,11 @@ @EClassifierNodeProcessorFactory(classifierID = TestPackage.ANIMAL) public class AnimalProcessorsFactory { + private Context context; - private Context context = Context.EMPTY_CONTEXT; // TODO - from constructor + public AnimalProcessorsFactory(Context context) { + this.context = context; + } /** * Test of different ways to configure action prototype. diff --git a/processors/src/main/java/org/nasdanika/models/ecore/test/processors/ColorProcessorsFactory.java b/processors/src/main/java/org/nasdanika/models/ecore/test/processors/ColorProcessorsFactory.java index e461635..2ff8269 100644 --- a/processors/src/main/java/org/nasdanika/models/ecore/test/processors/ColorProcessorsFactory.java +++ b/processors/src/main/java/org/nasdanika/models/ecore/test/processors/ColorProcessorsFactory.java @@ -18,7 +18,11 @@ @EClassifierNodeProcessorFactory(classifierID = TestPackage.COLOR) public class ColorProcessorsFactory { - private Context context = Context.EMPTY_CONTEXT; // TODO - from constructor + private Context context; + + public ColorProcessorsFactory(Context context) { + this.context = context; + } /** * Test of different ways to configure action prototype. diff --git a/processors/src/main/java/org/nasdanika/models/ecore/test/processors/EcoreGenTestProcessorsFactory.java b/processors/src/main/java/org/nasdanika/models/ecore/test/processors/EcoreGenTestProcessorsFactory.java index f739101..20bac44 100644 --- a/processors/src/main/java/org/nasdanika/models/ecore/test/processors/EcoreGenTestProcessorsFactory.java +++ b/processors/src/main/java/org/nasdanika/models/ecore/test/processors/EcoreGenTestProcessorsFactory.java @@ -16,8 +16,23 @@ @EPackageNodeProcessorFactory(nsURI = TestPackage.eNS_URI) public class EcoreGenTestProcessorsFactory { + + private Context context = Context.EMPTY_CONTEXT; // TODO - from constructor + + @Factory + public final AnimalProcessorsFactory animalProcessorsFactory; + + @Factory + public final ColorProcessorsFactory colorProcessorsFactory; + + @Factory + public final FoxProcessorsFactory foxProcessorsFactory; - private Context context = Context.EMPTY_CONTEXT; // TODO - from constructor + public EcoreGenTestProcessorsFactory(Context context) { + animalProcessorsFactory = new AnimalProcessorsFactory(context); + colorProcessorsFactory = new ColorProcessorsFactory(context); + foxProcessorsFactory = new FoxProcessorsFactory(context); + } /** * Test of different ways to configure action prototype. @@ -65,13 +80,4 @@ protected void configureLabel(EObject eObject, Label label, ProgressMonitor prog }; } - @Factory - public final AnimalProcessorsFactory animalProcessorsFactory = new AnimalProcessorsFactory(); // TODO - in constructor, context - - @Factory - public final ColorProcessorsFactory colorProcessorsFactory = new ColorProcessorsFactory(); // TODO - in constructor, context - - @Factory - public final FoxProcessorsFactory foxProcessorsFactory = new FoxProcessorsFactory(); // TODO - in constructor, context - } diff --git a/processors/src/main/java/org/nasdanika/models/ecore/test/processors/FoxProcessorsFactory.java b/processors/src/main/java/org/nasdanika/models/ecore/test/processors/FoxProcessorsFactory.java index f82ea3d..a850180 100644 --- a/processors/src/main/java/org/nasdanika/models/ecore/test/processors/FoxProcessorsFactory.java +++ b/processors/src/main/java/org/nasdanika/models/ecore/test/processors/FoxProcessorsFactory.java @@ -18,7 +18,11 @@ @EClassifierNodeProcessorFactory(classifierID = TestPackage.FOX) public class FoxProcessorsFactory { - private Context context = Context.EMPTY_CONTEXT; // TODO - from constructor + private Context context; + + public FoxProcessorsFactory(Context context) { + this.context = context; + } /** * Test of different ways to configure action prototype.