summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmusset2009-03-05 11:43:22 (EST)
committer jmusset2009-03-05 11:43:22 (EST)
commit43c7c6dfb2816450345fdf1be5a4b6a27f43e4c3 (patch)
treee4a9f7c7365be80b53512f4e404751d79b224c63
parenta285c0f4b430d5632449ba84ecc132b16e777f96 (diff)
downloadorg.eclipse.acceleo-43c7c6dfb2816450345fdf1be5a4b6a27f43e4c3.zip
org.eclipse.acceleo-43c7c6dfb2816450345fdf1be5a4b6a27f43e4c3.tar.gz
org.eclipse.acceleo-43c7c6dfb2816450345fdf1be5a4b6a27f43e4c3.tar.bz2
Project renaming from MTL to Acceleo
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/.classpath7
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/.cvsignore1
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/.project28
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/META-INF/MANIFEST.MF20
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/about.html57
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/build.properties17
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/icons/default.gifbin0 -> 676 bytes
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/plugin.xml34
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/Activator.java68
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/common/GenerateAll.java166
-rw-r--r--examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/popupMenus/AcceleoGenerateEcoreToPythonAction.java115
12 files changed, 519 insertions, 0 deletions
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.classpath b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.cvsignore b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.project b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.project
new file mode 100644
index 0000000..1bb1979
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.acceleo.module.example.ecore2python.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d1c0bf9
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.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/examples/org.eclipse.acceleo.module.example.ecore2python.ui/META-INF/MANIFEST.MF b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..7b301eb
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Acceleo Ecore To Python Module IDE Plug-in
+Bundle-SymbolicName: org.eclipse.acceleo.module.example.ecore2python.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.acceleo.module.example.ecore2python.ui.Activator
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.acceleo.module.example.ecore2python,
+ 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
+Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/about.html b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/about.html
new file mode 100644
index 0000000..7e1117e
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/about.html
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<em>July 25, 2008</em></p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+
+ <h3>Third Party Content</h3>
+ <p>The Content includes items that have been sourced from third parties as set out below. If you
+ did not receive this Content directly from the Eclipse Foundation, the following is provided
+ for informational purposes only, and you should look to the Redistributor's license for
+ terms and conditions of use.</p>
+ <p><em>
+ <br><br>
+ <strong>OMG MOF 2.0 Specification (06-01-01)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/technology/documents/formal/mof.htm">MOF 2.0 main page</a></li>
+ <li><a href="http://www.omg.org/docs/formal/06-01-01.pdf">MOF 2.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ <strong>OMG OCL 2.0 specification (06-05-01)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/technology/documents/formal/ocl.htm">OCL 2.0 main page</a></li>
+ <li><a href="http://www.omg.org/docs/formal/06-05-01.pdf">OCL 2.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ <strong>OMG MTL 1.0 specification (08-01-16)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/spec/MOFM2T/1.0/">MTL 1.0 main page</a></li>
+ <li><a href="http://www.omg.org/spec/MOFM2T/1.0/PDF">MTL 1.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ </em></p>
+ <p>A detailed list of fixes and clarifications with respect to those specifications may be found in the plug-in directly realizing them.</p>
+</body></html> \ No newline at end of file
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/build.properties b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/build.properties
new file mode 100644
index 0000000..aa9a63c
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/build.properties
@@ -0,0 +1,17 @@
+################################################################################
+# Copyright (c) 2008, 2009 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
+################################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/
+
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/icons/default.gif b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/icons/default.gif
new file mode 100644
index 0000000..d8a3137
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/icons/default.gif
Binary files differ
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/plugin.xml b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/plugin.xml
new file mode 100644
index 0000000..3ab4c01
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/plugin.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+
+<!--
+Copyright (c) 2008, 2009 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
+-->
+
+<plugin>
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.ecore"
+ id="org.eclipse.acceleo.module.example.ecore2python.ui.popupMenus.contribution.IFile">
+ <menu id="org.eclipse.acceleo.module.menu" label="Model to Text Transformation" path="additionsAcceleo">
+ <groupMarker name="acceleo"/>
+ </menu>
+ <action
+ class="org.eclipse.acceleo.module.example.ecore2python.ui.popupMenus.AcceleoGenerateEcoreToPythonAction"
+ enablesFor="+"
+ id="org.eclipse.acceleo.module.example.ecore2python.ui.popupMenus.acceleoGenerateEcoreToPythonAction"
+ icon="icons/default.gif"
+ label="Generate Ecore To Python"
+ menubarPath="org.eclipse.acceleo.module.menu/acceleo"/>
+ </objectContribution>
+ </extension>
+</plugin>
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/Activator.java b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/Activator.java
new file mode 100644
index 0000000..94bd1ee
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/Activator.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 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 org.eclipse.acceleo.module.example.ecore2python.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ *
+ * @author <a href="mailto:jonathan.musset@obeo.fr">Jonathan Musset</a>
+ */
+public class Activator extends AbstractUIPlugin {
+
+ /**
+ * The plug-in ID.
+ */
+ public static final String PLUGIN_ID = "org.eclipse.acceleo.module.example.ecore2python.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/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/common/GenerateAll.java b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/common/GenerateAll.java
new file mode 100644
index 0000000..da175e1
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/common/GenerateAll.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 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 org.eclipse.acceleo.module.example.ecore2python.ui.common;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.osgi.framework.Bundle;
+
+
+/**
+ * Main entry point of the 'Ecore To Python' generation module.
+ *
+ * @author <a href="mailto:jonathan.musset@obeo.fr">Jonathan Musset</a>
+ */
+public class GenerateAll {
+
+ /**
+ * The model URI.
+ */
+ private URI modelURI;
+
+ /**
+ * The output folder.
+ */
+ private File 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, File targetFolder, List<? extends Object> arguments) {
+ this.modelURI = modelURI;
+ this.targetFolder = targetFolder;
+ this.arguments = arguments;
+ }
+
+ /**
+ * Launches the generation.
+ *
+ * @throws IOException
+ * Thrown when the output cannot be saved.
+ * @generated
+ */
+ public void doGenerate() throws IOException {
+ if (!targetFolder.exists()) {
+ targetFolder.mkdirs();
+ }
+
+ final URI template0 = getTemplateURI("org.eclipse.acceleo.module.example.ecore2python", new Path("/org/eclipse/acceleo/module/ecore2python/commonClass.emtl"));
+ org.eclipse.acceleo.module.ecore2python.CommonClass gen0 = new org.eclipse.acceleo.module.ecore2python.CommonClass(modelURI, targetFolder, arguments) {
+ protected URI createTemplateURI(String entry) {
+ return template0;
+ }
+ };
+ gen0.doGenerate();
+
+ EObject model = gen0.getModel();
+ if (model != null) {
+
+ final URI template1 = getTemplateURI("org.eclipse.acceleo.module.example.ecore2python", new Path("/org/eclipse/acceleo/module/ecore2python/factory.emtl"));
+ org.eclipse.acceleo.module.ecore2python.Factory gen1 = new org.eclipse.acceleo.module.ecore2python.Factory(model, targetFolder, arguments) {
+ protected URI createTemplateURI(String entry) {
+ return template1;
+ }
+ };
+ gen1.doGenerate();
+ final URI template2 = getTemplateURI("org.eclipse.acceleo.module.example.ecore2python", new Path("/org/eclipse/acceleo/module/ecore2python/init.emtl"));
+ org.eclipse.acceleo.module.ecore2python.Init gen2 = new org.eclipse.acceleo.module.ecore2python.Init(model, targetFolder, arguments) {
+ protected URI createTemplateURI(String entry) {
+ return template2;
+ }
+ };
+ gen2.doGenerate();
+ final URI template3 = getTemplateURI("org.eclipse.acceleo.module.example.ecore2python", new Path("/org/eclipse/acceleo/module/ecore2python/parser.emtl"));
+ org.eclipse.acceleo.module.ecore2python.Parser gen3 = new org.eclipse.acceleo.module.ecore2python.Parser(model, targetFolder, arguments) {
+ protected URI createTemplateURI(String entry) {
+ return template3;
+ }
+ };
+ gen3.doGenerate();
+ }
+
+
+ }
+
+ /**
+ * Finds the template in the plug-in. Returns the template plug-in URI.
+ *
+ * @param bundleID
+ * is the plug-in ID
+ * @param relativePath
+ * is the relative path of the template in the plug-in
+ * @return the template URI
+ * @throws IOException
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ private URI getTemplateURI(String bundleID, IPath relativePath) throws IOException {
+ Bundle bundle = Platform.getBundle(bundleID);
+ if (bundle == null) {
+ // no need to go any further
+ return URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
+ }
+ URL url = bundle.getEntry(relativePath.toString());
+ if (url == null && relativePath.segmentCount() > 1) {
+ Enumeration<URL> entries = bundle.findEntries("/", "*.emtl", true);
+ if (entries != null) {
+ String[] segmentsRelativePath = relativePath.segments();
+ while (url == null && entries.hasMoreElements()) {
+ URL entry = entries.nextElement();
+ IPath path = new Path(entry.getPath());
+ if (path.segmentCount() > relativePath.segmentCount()) {
+ path = path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
+ }
+ String[] segmentsPath = path.segments();
+ boolean equals = segmentsPath.length == segmentsRelativePath.length;
+ for (int i = 0; equals && i < segmentsPath.length; i++) {
+ equals = segmentsPath[i].equals(segmentsRelativePath[i]);
+ }
+ if (equals) {
+ url = bundle.getEntry(entry.getPath());
+ }
+ }
+ }
+ }
+ URI result;
+ if (url != null) {
+ result = URI.createPlatformPluginURI(new Path(bundleID).append(new Path(url.getPath())).toString(), false);
+ } else {
+ result = URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
+ }
+ return result;
+ }
+
+}
diff --git a/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/popupMenus/AcceleoGenerateEcoreToPythonAction.java b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/popupMenus/AcceleoGenerateEcoreToPythonAction.java
new file mode 100644
index 0000000..40def88
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.ecore2python.ui/src/org/eclipse/acceleo/module/example/ecore2python/ui/popupMenus/AcceleoGenerateEcoreToPythonAction.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 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 org.eclipse.acceleo.module.example.ecore2python.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 org.eclipse.acceleo.module.example.ecore2python.ui.Activator;
+import org.eclipse.acceleo.module.example.ecore2python.ui.common.GenerateAll;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * Ecore To Python code generation.
+ *
+ * @author <a href="mailto:jonathan.musset@obeo.fr">Jonathan Musset</a>
+ *
+ */
+public class AcceleoGenerateEcoreToPythonAction extends ActionDelegate implements IActionDelegate {
+
+ /**
+ * Selected model files.
+ */
+ protected List<IFile> 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<IFile> filesIt = files.iterator();
+ while (filesIt.hasNext()) {
+ IFile model = (IFile)filesIt.next();
+ URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true);
+ try {
+ IContainer target = model.getProject().getFolder("src-gen");
+ GenerateAll generator = new GenerateAll(modelURI, target.getLocation().toFile(), getArguments());
+ generator.doGenerate();
+ } catch (IOException e) {
+ IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ } finally {
+ model.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<String>();
+ }
+
+} \ No newline at end of file