From 71b2144c04bd762a8c69fa056af9213a91ea8bdb Mon Sep 17 00:00:00 2001
From: Laurent Fainsin
Date: Sat, 4 Dec 2021 15:59:35 +0100
Subject: [PATCH] feat: avancement prototype
---
enigme.java/Condition.java | 3 +-
enigme.java/Personne.java | 8 +-
.../src-gen/Prototype.java | 43 +
.../fr.n7.game.toPrototype.ui/.classpath | 7 +
workspace/fr.n7.game.toPrototype.ui/.project | 28 +
.../.settings/org.eclipse.jdt.core.prefs | 6 +
.../META-INF/MANIFEST.MF | 20 +
.../build.properties | 7 +
.../icons/default.gif | Bin 0 -> 534 bytes
.../fr.n7.game.toPrototype.ui/plugin.xml | 22 +
.../fr/n7/game/toPrototype/ui/Activator.java | 66 +
.../toPrototype/ui/common/GenerateAll.java | 86 +
.../AcceleoGenerateToPrototypeAction.java | 116 ++
.../n7/game/toPrototype/main/toPrototype.emtl | 1711 +++++++++++++++--
.../n7/game/toPrototype/main/toPrototype.mtl | 134 +-
.../n7/game/toPrototype/main/toPrototype.mtl | 134 +-
workspace/fr.n7.game2petrinet/.project | 17 -
17 files changed, 2246 insertions(+), 162 deletions(-)
create mode 100644 runtime-workspace/fr.n7.game.examples/src-gen/Prototype.java
create mode 100644 workspace/fr.n7.game.toPrototype.ui/.classpath
create mode 100644 workspace/fr.n7.game.toPrototype.ui/.project
create mode 100644 workspace/fr.n7.game.toPrototype.ui/.settings/org.eclipse.jdt.core.prefs
create mode 100644 workspace/fr.n7.game.toPrototype.ui/META-INF/MANIFEST.MF
create mode 100644 workspace/fr.n7.game.toPrototype.ui/build.properties
create mode 100644 workspace/fr.n7.game.toPrototype.ui/icons/default.gif
create mode 100644 workspace/fr.n7.game.toPrototype.ui/plugin.xml
create mode 100644 workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/Activator.java
create mode 100644 workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/common/GenerateAll.java
create mode 100644 workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/popupMenus/AcceleoGenerateToPrototypeAction.java
delete mode 100644 workspace/fr.n7.game2petrinet/.project
diff --git a/enigme.java/Condition.java b/enigme.java/Condition.java
index 455e090..b960bfd 100644
--- a/enigme.java/Condition.java
+++ b/enigme.java/Condition.java
@@ -5,8 +5,7 @@ public class Condition {
List conditionEts;
- public Condition(
- ConditionEt... conditionEts) {
+ public Condition(ConditionEt... conditionEts) {
this.conditionEts = new ArrayList<>();
for (ConditionEt c : conditionEts) {
this.conditionEts.add(c);
diff --git a/enigme.java/Personne.java b/enigme.java/Personne.java
index f773195..3687b6e 100644
--- a/enigme.java/Personne.java
+++ b/enigme.java/Personne.java
@@ -6,21 +6,21 @@ public class Personne {
String nom;
Condition visible;
Condition obligatoire;
- List interractions;
+ List interactions;
public Personne(
String nom,
Condition visible,
Condition obligatoire,
- List interractions) {
+ List interactions) {
this.nom = nom;
this.visible = visible;
this.obligatoire = obligatoire;
- this.interractions = interractions;
+ this.interactions = interactions;
}
void interragir(BufferedReader reader, Lieu lieu) {
- for (Interaction i : this.interractions) {
+ for (Interaction i : this.interactions) {
if (i.visible.evaluer()) {
i.interragir(reader, lieu);
}
diff --git a/runtime-workspace/fr.n7.game.examples/src-gen/Prototype.java b/runtime-workspace/fr.n7.game.examples/src-gen/Prototype.java
new file mode 100644
index 0000000..963b18c
--- /dev/null
+++ b/runtime-workspace/fr.n7.game.examples/src-gen/Prototype.java
@@ -0,0 +1,43 @@
+public static void main(String[] args) {
+
+Condition vraie = new Condition(new ConditionEt(new ConditionBoolean(true)));
+
+// "Objets"
+List jeu_objets = new ArrayList<>();
+ List objet_tentative_descriptions = new new ArrayList<>();
+
+ objet_tentative_descriptions.add(
+ new Description(
+ "permet répondre une question du sphinx",
+ vraie
+ )
+ );
+
+ Objet objet_tentative = new Objet(
+ "tentative",
+ 1,
+ vraie,
+ objet_tentative_descriptions
+ );
+
+ jeu_objets.add(tentative_objet);
+
+// "Connaissances"
+List jeu_connaissances = new ArrayList<>();
+ List connaissance_Réussite_descriptions = new new ArrayList<>();
+
+ objet_Réussite_descriptions.add(
+ new Description(
+ "Permet de se casser de là",
+ vraie
+ )
+ );
+
+ Connaissance connaissance_Réussite = new Connaissance(
+ "Réussite",
+ vraie,
+ connaissance_Réussite_descriptions
+ );
+
+ jeu_connaissances.add(reussite_connaissance);
+}
diff --git a/workspace/fr.n7.game.toPrototype.ui/.classpath b/workspace/fr.n7.game.toPrototype.ui/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/workspace/fr.n7.game.toPrototype.ui/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/workspace/fr.n7.game.toPrototype.ui/.project b/workspace/fr.n7.game.toPrototype.ui/.project
new file mode 100644
index 0000000..b4df055
--- /dev/null
+++ b/workspace/fr.n7.game.toPrototype.ui/.project
@@ -0,0 +1,28 @@
+
+
+ fr.n7.game.toPrototype.ui
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/workspace/fr.n7.game.toPrototype.ui/.settings/org.eclipse.jdt.core.prefs b/workspace/fr.n7.game.toPrototype.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d1c0bf9
--- /dev/null
+++ b/workspace/fr.n7.game.toPrototype.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/workspace/fr.n7.game.toPrototype.ui/META-INF/MANIFEST.MF b/workspace/fr.n7.game.toPrototype.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..3eb1bcb
--- /dev/null
+++ b/workspace/fr.n7.game.toPrototype.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Acceleo ToPrototype Module IDE Plug-in
+Bundle-SymbolicName: fr.n7.game.toPrototype.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: fr.n7.game.toPrototype.ui.Activator
+Bundle-Vendor: Eclipse Modeling Project
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ fr.n7.game.toPrototype,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.ocl,
+ org.eclipse.ocl.ecore,
+ org.eclipse.acceleo.model,
+ org.eclipse.acceleo.engine
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Eclipse-LazyStart: true
diff --git a/workspace/fr.n7.game.toPrototype.ui/build.properties b/workspace/fr.n7.game.toPrototype.ui/build.properties
new file mode 100644
index 0000000..d0a0e71
--- /dev/null
+++ b/workspace/fr.n7.game.toPrototype.ui/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/
+
diff --git a/workspace/fr.n7.game.toPrototype.ui/icons/default.gif b/workspace/fr.n7.game.toPrototype.ui/icons/default.gif
new file mode 100644
index 0000000000000000000000000000000000000000..6a04c491b290f805a98268a5aa363be0fccf128f
GIT binary patch
literal 534
zcmZ?wbhEHb6krfwI2OaeTA#w%m?qeoBi~)3+Fz+Yp~`Mnm+QPf-^G*tmP~4$vaxIW
zx`-7s`(~_)S~a_S=C;_?^QO#R)<1XWgt*sjqB#@TGzg3UCW+ztxdak>|Niq
zdwoaKp6%N<%sjZEZpMzy2RAm(+_9~7-}c>`rXJf=HE-vZ&i#9*96mPX$k7wKCLGy4
zXWG%@NB7J=zGueqJu^@4opEH}%DE>_%{zH!{>ii34qe-M`0Ab`m-ijJxcuzp1IN#w
zI&=KYnPX?p9^G=~_SP%6wqCit
+
+
+
+
+
+
diff --git a/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/Activator.java b/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/Activator.java
new file mode 100644
index 0000000..97248b7
--- /dev/null
+++ b/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/Activator.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package fr.n7.game.toPrototype.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+public class Activator extends AbstractUIPlugin {
+
+ /**
+ * The plug-in ID.
+ */
+ public static final String PLUGIN_ID = "fr.n7.game.toPrototype.ui";
+
+ /**
+ * The shared instance.
+ */
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+ * @generated
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ * @generated
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/common/GenerateAll.java b/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/common/GenerateAll.java
new file mode 100644
index 0000000..0761d7e
--- /dev/null
+++ b/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/common/GenerateAll.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package fr.n7.game.toPrototype.ui.common;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+
+
+/**
+ * Main entry point of the 'ToPrototype' generation module.
+ */
+public class GenerateAll {
+
+ /**
+ * The model URI.
+ */
+ private URI modelURI;
+
+ /**
+ * The output folder.
+ */
+ private IContainer targetFolder;
+
+ /**
+ * The other arguments.
+ */
+ List extends Object> arguments;
+
+ /**
+ * Constructor.
+ *
+ * @param modelURI
+ * is the URI of the model.
+ * @param targetFolder
+ * is the output folder
+ * @param arguments
+ * are the other arguments
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ * @generated
+ */
+ public GenerateAll(URI modelURI, IContainer targetFolder, List extends Object> arguments) {
+ this.modelURI = modelURI;
+ this.targetFolder = targetFolder;
+ this.arguments = arguments;
+ }
+
+ /**
+ * Launches the generation.
+ *
+ * @param monitor
+ * This will be used to display progress information to the user.
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ * @generated
+ */
+ public void doGenerate(IProgressMonitor monitor) throws IOException {
+ if (!targetFolder.getLocation().toFile().exists()) {
+ targetFolder.getLocation().toFile().mkdirs();
+ }
+
+ monitor.subTask("Loading...");
+ fr.n7.game.toPrototype.main.ToPrototype gen0 = new fr.n7.game.toPrototype.main.ToPrototype(modelURI, targetFolder.getLocation().toFile(), arguments);
+ monitor.worked(1);
+ String generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID("fr.n7.game.toPrototype", "fr.n7.game.toPrototype.main.ToPrototype", modelURI.toString(), targetFolder.getFullPath().toString(), new ArrayList());
+ gen0.setGenerationID(generationID);
+ gen0.doGenerate(BasicMonitor.toMonitor(monitor));
+
+
+ }
+
+}
diff --git a/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/popupMenus/AcceleoGenerateToPrototypeAction.java b/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/popupMenus/AcceleoGenerateToPrototypeAction.java
new file mode 100644
index 0000000..80efd9c
--- /dev/null
+++ b/workspace/fr.n7.game.toPrototype.ui/src/fr/n7/game/toPrototype/ui/popupMenus/AcceleoGenerateToPrototypeAction.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package fr.n7.game.toPrototype.ui.popupMenus;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import fr.n7.game.toPrototype.ui.Activator;
+import fr.n7.game.toPrototype.ui.common.GenerateAll;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * ToPrototype code generation.
+ */
+public class AcceleoGenerateToPrototypeAction extends ActionDelegate implements IActionDelegate {
+
+ /**
+ * Selected model files.
+ */
+ protected List files;
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ files = ((IStructuredSelection) selection).toList();
+ }
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction)
+ * @generated
+ */
+ public void run(IAction action) {
+ if (files != null) {
+ IRunnableWithProgress operation = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ try {
+ Iterator filesIt = files.iterator();
+ while (filesIt.hasNext()) {
+ IFile model = (IFile)filesIt.next();
+ URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true);
+ IContainer targetFolder = null;
+ try {
+ IContainer target = model.getProject().getFolder("src-gen");
+ targetFolder = target;
+ GenerateAll generator = new GenerateAll(modelURI, targetFolder, getArguments());
+ generator.doGenerate(monitor);
+ } catch (IOException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ } finally {
+ if (targetFolder != null) {
+ targetFolder.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ }
+ }
+ };
+ try {
+ PlatformUI.getWorkbench().getProgressService().run(true, true, operation);
+ } catch (InvocationTargetException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ } catch (InterruptedException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ }
+ }
+ }
+
+ /**
+ * Computes the arguments of the generator.
+ *
+ * @return the arguments
+ * @generated
+ */
+ protected List extends Object> getArguments() {
+ return new ArrayList();
+ }
+
+}
\ No newline at end of file
diff --git a/workspace/fr.n7.game.toPrototype/bin/fr/n7/game/toPrototype/main/toPrototype.emtl b/workspace/fr.n7.game.toPrototype/bin/fr/n7/game/toPrototype/main/toPrototype.emtl
index a49f51c..2cce1de 100644
--- a/workspace/fr.n7.game.toPrototype/bin/fr/n7/game/toPrototype/main/toPrototype.emtl
+++ b/workspace/fr.n7.game.toPrototype/bin/fr/n7/game/toPrototype/main/toPrototype.emtl
@@ -13,7 +13,7 @@
-
+
@@ -27,7 +27,7 @@
-
+
@@ -41,7 +41,7 @@
-
+
-
+
@@ -72,7 +72,7 @@
-
+
-
+
-
-
+
@@ -111,7 +115,224 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+