summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmusset2009-03-05 11:41:26 (EST)
committerjmusset2009-03-05 11:41:26 (EST)
commitc9410078f5edeac48bd8490ef79c977ea6214fc7 (patch)
tree570f69c38200a666bbea993a7a089a813fbf968b
parent104c5c25c9c1d29743a455a1e50079398cdd31b3 (diff)
downloadorg.eclipse.acceleo-c9410078f5edeac48bd8490ef79c977ea6214fc7.zip
org.eclipse.acceleo-c9410078f5edeac48bd8490ef79c977ea6214fc7.tar.gz
org.eclipse.acceleo-c9410078f5edeac48bd8490ef79c977ea6214fc7.tar.bz2
Project renaming from MTL to Acceleo
-rw-r--r--examples/org.eclipse.acceleo.examples/.checkstyle9
-rw-r--r--examples/org.eclipse.acceleo.examples/.classpath7
-rw-r--r--examples/org.eclipse.acceleo.examples/.project28
-rw-r--r--examples/org.eclipse.acceleo.examples/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--examples/org.eclipse.acceleo.examples/META-INF/MANIFEST.MF15
-rw-r--r--examples/org.eclipse.acceleo.examples/about.html28
-rw-r--r--examples/org.eclipse.acceleo.examples/build.properties20
-rw-r--r--examples/org.eclipse.acceleo.examples/build.xml49
-rw-r--r--examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.ecore2python.ui.zipbin0 -> 21512 bytes
-rw-r--r--examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.ecore2python.zipbin0 -> 47368 bytes
-rw-r--r--examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.uml2java.ui.zipbin0 -> 17445 bytes
-rw-r--r--examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.uml2java.zipbin0 -> 27648 bytes
-rw-r--r--examples/org.eclipse.acceleo.examples/icons/default.gifbin0 -> 676 bytes
-rw-r--r--examples/org.eclipse.acceleo.examples/plugin.properties30
-rw-r--r--examples/org.eclipse.acceleo.examples/plugin.xml58
-rw-r--r--examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/AcceleoExamplesMessages.java81
-rw-r--r--examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/AcceleoExamplesPlugin.java65
-rw-r--r--examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/acceleoexamplesmessages.properties13
-rw-r--r--examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/AbstractExampleWizard.java287
-rw-r--r--examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/Ecore2PythonExampleWizard.java59
-rw-r--r--examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/Uml2JavaExampleWizard.java59
21 files changed, 815 insertions, 0 deletions
diff --git a/examples/org.eclipse.acceleo.examples/.checkstyle b/examples/org.eclipse.acceleo.examples/.checkstyle
new file mode 100644
index 0000000..60d2e33
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/.checkstyle
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <local-check-config name="Acceleo" location="/org.eclipse.acceleo-feature/codestyle/AcceleoCheckstyleConfiguration.xml" type="project" description="">
+ <additional-data name="protect-config-file" value="false"/>
+ </local-check-config>
+ <fileset name="tous" enabled="true" check-config-name="Acceleo" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/examples/org.eclipse.acceleo.examples/.classpath b/examples/org.eclipse.acceleo.examples/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/.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.examples/.project b/examples/org.eclipse.acceleo.examples/.project
new file mode 100644
index 0000000..5294ca6
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.acceleo.examples</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.examples/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.acceleo.examples/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..c85cafb
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Fri Sep 12 10:14:34 CEST 2008
+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.examples/META-INF/MANIFEST.MF b/examples/org.eclipse.acceleo.examples/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..b999569
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.acceleo.examples;singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Bundle-Activator: org.eclipse.acceleo.examples.internal.AcceleoExamplesPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide
+Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
diff --git a/examples/org.eclipse.acceleo.examples/about.html b/examples/org.eclipse.acceleo.examples/about.html
new file mode 100644
index 0000000..598b368
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/about.html
@@ -0,0 +1,28 @@
+<!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>
+
+<p>May 12, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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>
+
+</body>
+</html> \ No newline at end of file
diff --git a/examples/org.eclipse.acceleo.examples/build.properties b/examples/org.eclipse.acceleo.examples/build.properties
new file mode 100644
index 0000000..4d78030
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/build.properties
@@ -0,0 +1,20 @@
+################################################################################
+# 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/,\
+ .,\
+ about.html,\
+ build.properties,\
+ plugin.xml,\
+ examples/,\
+ plugin.properties,\
+ icons/
diff --git a/examples/org.eclipse.acceleo.examples/build.xml b/examples/org.eclipse.acceleo.examples/build.xml
new file mode 100644
index 0000000..8e3bc46
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/build.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ <copyright>
+ 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
+ </copyright>
+-->
+
+<project name="Acceleo Examples" basedir="." default="buildZips">
+ <!-- Project properties -->
+ <property name="dest.dir" value="examples" />
+ <property name="plugins.base.dir" value=".." />
+
+ <property name="ecore2python.plugin" value="org.eclipse.acceleo.module.example.ecore2python" />
+ <property name="ecore2python.ui.plugin" value="org.eclipse.acceleo.module.example.ecore2python.ui" />
+ <property name="uml2java.plugin" value="org.eclipse.acceleo.module.example.uml2java" />
+ <property name="uml2java.ui.plugin" value="org.eclipse.acceleo.module.example.uml2java.ui" />
+
+ <!-- Clean -->
+ <target name="clean">
+ <mkdir dir="${dest.dir}" />
+ <delete>
+ <fileset dir="${dest.dir}" includes="*.zip" />
+ </delete>
+ </target>
+
+ <!-- Build zip files -->
+ <target name="buildZips" depends="clean">
+ <zip destfile="${dest.dir}/${ecore2python.plugin}.zip">
+ <zipfileset dir="${plugins.base.dir}/${ecore2python.plugin}" />
+ </zip>
+ <zip destfile="${dest.dir}/${ecore2python.ui.plugin}.zip">
+ <zipfileset dir="${plugins.base.dir}/${ecore2python.ui.plugin}" />
+ </zip>
+ <zip destfile="${dest.dir}/${uml2java.plugin}.zip">
+ <zipfileset dir="${plugins.base.dir}/${uml2java.plugin}" />
+ </zip>
+ <zip destfile="${dest.dir}/${uml2java.ui.plugin}.zip">
+ <zipfileset dir="${plugins.base.dir}/${uml2java.ui.plugin}" />
+ </zip>
+ </target>
+</project> \ No newline at end of file
diff --git a/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.ecore2python.ui.zip b/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.ecore2python.ui.zip
new file mode 100644
index 0000000..652b47f
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.ecore2python.ui.zip
Binary files differ
diff --git a/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.ecore2python.zip b/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.ecore2python.zip
new file mode 100644
index 0000000..d6b1f91
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.ecore2python.zip
Binary files differ
diff --git a/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.uml2java.ui.zip b/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.uml2java.ui.zip
new file mode 100644
index 0000000..8c810e8
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.uml2java.ui.zip
Binary files differ
diff --git a/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.uml2java.zip b/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.uml2java.zip
new file mode 100644
index 0000000..ab4a1dc
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/examples/org.eclipse.acceleo.module.example.uml2java.zip
Binary files differ
diff --git a/examples/org.eclipse.acceleo.examples/icons/default.gif b/examples/org.eclipse.acceleo.examples/icons/default.gif
new file mode 100644
index 0000000..d8a3137
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/icons/default.gif
Binary files differ
diff --git a/examples/org.eclipse.acceleo.examples/plugin.properties b/examples/org.eclipse.acceleo.examples/plugin.properties
new file mode 100644
index 0000000..74e2358
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/plugin.properties
@@ -0,0 +1,30 @@
+# Copyright (c) 2007-2008 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
+
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# ====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# ====================================================================
+
+pluginName = Acceleo Examples
+providerName = Eclipse.org
+
+AcceleoCategory = Acceleo Plug-ins
+ecore2pythonName = Ecore to Python
+ecore2pythonDescription = Creates plug-in projects defining Acceleo templates to generate Python code from an ecore model.
+uml2javaName = UML to Java
+uml2javaDescription = Creates plug-in projects defining Acceleo templates to generate Java code from an UML model.
diff --git a/examples/org.eclipse.acceleo.examples/plugin.xml b/examples/org.eclipse.acceleo.examples/plugin.xml
new file mode 100644
index 0000000..80c3677
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/plugin.xml
@@ -0,0 +1,58 @@
+<?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.newWizards">
+ <category
+ id="org.eclipse.acceleo.examples.category"
+ name="%AcceleoCategory"
+ parentCategory="org.eclipse.ui.Examples">
+ </category>
+ <wizard
+ canFinishEarly="true"
+ category="org.eclipse.ui.Examples/org.eclipse.acceleo.examples.category"
+ class="org.eclipse.acceleo.examples.internal.wizard.Ecore2PythonExampleWizard"
+ hasPages="false"
+ id="org.eclipse.acceleo.examples.ecore2python"
+ name="%ecore2pythonName"
+ icon="/icons/default.gif"
+ project="true">
+ <description>
+ %ecore2pythonDescription
+ </description>
+ </wizard>
+ </extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ id="org.eclipse.acceleo.examples.category"
+ name="%AcceleoCategory"
+ parentCategory="org.eclipse.ui.Examples">
+ </category>
+ <wizard
+ canFinishEarly="true"
+ category="org.eclipse.ui.Examples/org.eclipse.acceleo.examples.category"
+ class="org.eclipse.acceleo.examples.internal.wizard.Uml2JavaExampleWizard"
+ hasPages="false"
+ id="org.eclipse.acceleo.examples.uml2java"
+ name="%uml2javaName"
+ icon="/icons/default.gif"
+ project="true">
+ <description>
+ %uml2javaDescription
+ </description>
+ </wizard>
+ </extension>
+</plugin>
diff --git a/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/AcceleoExamplesMessages.java b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/AcceleoExamplesMessages.java
new file mode 100644
index 0000000..a91fe86
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/AcceleoExamplesMessages.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007, 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.examples.internal;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Utility class to access externalized Strings used by the examples.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public final class AcceleoExamplesMessages {
+ /** Qualified path to the properties file in which to seek the keys. */
+ private static final String BUNDLE_NAME = "org.eclipse.acceleo.examples.internal.acceleoexamplesmessages"; //$NON-NLS-1$
+
+ /** Contains the locale specific {@link String}s needed by this plug-in. */
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ /**
+ * Utility classes don't need to (and shouldn't) be instantiated.
+ */
+ private AcceleoExamplesMessages() {
+ // prevents instantiation
+ }
+
+ /**
+ * This will return an unformatted String from the resource bundle.
+ *
+ * @param key
+ * Key of the String we seek.
+ * @return An unformatted String from the bundle.
+ */
+ private static String internalGetString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+
+ /**
+ * Returns the specified {@link String} from the resource bundle.
+ *
+ * @param key
+ * Key of the String we seek.
+ * @return The String from the resource bundle associated with <code>key</code>.
+ * <code>'!' + key + '!'</code> will be returned in case we didn't find it in the bundle.
+ */
+ public static String getString(String key) {
+ // Pass through MessageFormat so that we're consistent in the handling of special chars such as the
+ // apostrophe
+ return MessageFormat.format(internalGetString(key), new Object[] {});
+ }
+
+ /**
+ * Returns a String from the resource bundle bound with the given arguments.
+ *
+ * @param key
+ * Key of the String we seek.
+ * @param arguments
+ * Arguments for the String formatting.
+ * @return formatted {@link String}.
+ * @see MessageFormat#format(String, Object[])
+ */
+ public static String getString(String key, Object... arguments) {
+ if (arguments == null) {
+ return getString(key);
+ }
+ return MessageFormat.format(internalGetString(key), arguments);
+ }
+}
diff --git a/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/AcceleoExamplesPlugin.java b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/AcceleoExamplesPlugin.java
new file mode 100644
index 0000000..be02405
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/AcceleoExamplesPlugin.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.examples.internal;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class AcceleoExamplesPlugin extends AbstractUIPlugin {
+ /** The plug-in ID. */
+ public static final String PLUGIN_ID = "org.eclipse.acceleo.examples"; //$NON-NLS-1$
+
+ /** The plug-in's shared instance. */
+ private static AcceleoExamplesPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public AcceleoExamplesPlugin() {
+ // Nothing to do here
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance.
+ */
+ public static AcceleoExamplesPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+}
diff --git a/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/acceleoexamplesmessages.properties b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/acceleoexamplesmessages.properties
new file mode 100644
index 0000000..d7f5d6a
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/acceleoexamplesmessages.properties
@@ -0,0 +1,13 @@
+################################################################################
+# 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
+################################################################################
+## note : apostrophes need to be doubled in these messages or they'll be ignored
+# org.eclipse.acceleo.examples.internal.wizard
+AbstractExampleWizard.Task.Unzip = Unzipping projects...
diff --git a/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/AbstractExampleWizard.java b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/AbstractExampleWizard.java
new file mode 100644
index 0000000..b8b4570
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/AbstractExampleWizard.java
@@ -0,0 +1,287 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006, 2007, 2008 IBM Corporation and others.
+ * 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:
+ * IBM - Initial API and implementation
+ * Obeo - code cleanup and tweaking for use within Acceleo
+ *
+ * </copyright>
+ *
+ * $Id: AbstractExampleWizard.java,v 1.1 2009/03/05 16:41:27 jmusset Exp $
+ */
+
+package org.eclipse.acceleo.examples.internal.wizard;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.acceleo.examples.internal.AcceleoExamplesMessages;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+/**
+ * <p>
+ * This abstract example wizard simply unzips a number of zips into the workspace as projects. It does not
+ * offer any pages but can be added as a new wizard to the new wizards dialog through the
+ * org.eclipse.ui.newWizards extension point.
+ * </p>
+ * <p>
+ * Clients should subclass this class and override the <code>getProjectDescriptor()</code> method to provide
+ * the location of the project zips that should be unzipped into the workspace. Note that any projects that
+ * are already in the workspace will <i>not</i> be overwritten because the user could have made changes to
+ * them that would be lost.
+ * </p>
+ * <p>
+ * It is highly recommended when registering subclasses to the new wizards extension point that the wizard
+ * declaration should have canFinishEarly = true and hasPages = false. Any label and icon can be freely given
+ * to the wizard to suit the needs of the client.
+ * </p>
+ * <p>
+ * This class originally came from plugin <code>org.eclipse.emf.ocl.examples</code>.
+ * </p>
+ */
+public abstract class AbstractExampleWizard extends Wizard implements INewWizard {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // No code is necessary.
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();
+
+ try {
+ getContainer().run(true, false, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+
+ final WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(IProgressMonitor m)
+
+ throws CoreException, InvocationTargetException, InterruptedException {
+ m
+ .beginTask(
+ AcceleoExamplesMessages.getString("AbstractExampleWizard.Task.Unzip"), projectDescriptors.size()); //$NON-NLS-1$
+
+ for (final ProjectDescriptor project : projectDescriptors) {
+ unzipProject(project, m);
+ m.worked(1);
+ }
+ }
+ };
+ op.run(monitor);
+ }
+ });
+ } catch (final InvocationTargetException e) {
+ log(e);
+ } catch (final InterruptedException e) {
+ // We cannot be interrupted, just proceed as normal.
+ }
+
+ return true;
+ }
+
+ /**
+ * The subclass provides the specific project descriptors for the projects that should be unzipped into
+ * the workspace. Note that any projects that already exist in the workspace will not be overwritten as
+ * they may contain changes made by the user.
+ *
+ * @return The collection of project descriptors that should be unzipped into the workspace.
+ */
+ protected abstract Collection<ProjectDescriptor> getProjectDescriptors();
+
+ /**
+ * Any exception occuring during the example initialization (projects unzipping, workspace refreshing,
+ * ...) will be handed over to this method. Subclasses should override this in order to properly log them.
+ *
+ * @param e
+ * Exception that should be logged.
+ */
+ protected abstract void log(Exception e);
+
+ /**
+ * This will unzip the project described by <code>descriptor</code>, open it and refresh the workspace.
+ *
+ * @param descriptor
+ * Description of the project as it should be unzipped.
+ * @param monitor
+ * {@link IProgressMonitor} that will be used to monitor the operation.
+ */
+ protected void unzipProject(ProjectDescriptor descriptor, IProgressMonitor monitor) {
+ final String bundleName = descriptor.getBundleName();
+ final String zipLocation = descriptor.getZipLocation();
+ final String projectName = descriptor.getProjectName();
+
+ final URL interpreterZipUrl = FileLocator.find(Platform.getBundle(bundleName), new Path(zipLocation),
+ null);
+
+ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ if (project.exists()) {
+ return;
+ }
+
+ try {
+ // We make sure that the project is created from this point forward.
+ project.create(monitor);
+
+ final ZipInputStream zipFileStream = new ZipInputStream(interpreterZipUrl.openStream());
+ ZipEntry zipEntry = zipFileStream.getNextEntry();
+
+ // We derive a regexedProjectName so that the dots don't end up being
+ // interpreted as the dot operator in the regular expression language.
+ final String regexedProjectName = projectName.replaceAll("\\.", "\\."); //$NON-NLS-1$ //$NON-NLS-2$
+
+ while (zipEntry != null) {
+ // We will construct the new file but we will strip off the project
+ // directory from the beginning of the path because we have already
+ // created the destination project for this zip.
+ final File file = new File(project.getLocation().toString(), zipEntry.getName().replaceFirst(
+ "^" + regexedProjectName + "/", "")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+
+ if (!zipEntry.isDirectory()) {
+
+ /*
+ * Copy files (and make sure parent directory exist)
+ */
+ final File parentFile = file.getParentFile();
+ if (null != parentFile && !parentFile.exists()) {
+ parentFile.mkdirs();
+ }
+
+ OutputStream os = null;
+
+ try {
+ os = new FileOutputStream(file);
+
+ final int bufferSize = 102400;
+ final byte[] buffer = new byte[bufferSize];
+ while (true) {
+ final int len = zipFileStream.read(buffer);
+ if (zipFileStream.available() == 0) {
+ break;
+ }
+ os.write(buffer, 0, len);
+ }
+ } finally {
+ if (null != os) {
+ os.close();
+ }
+ }
+ }
+
+ zipFileStream.closeEntry();
+ zipEntry = zipFileStream.getNextEntry();
+ }
+
+ project.open(monitor);
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+
+ // Close and re-open the project to force eclipse to re-evaluate
+ // any natures that this project may have.
+ project.close(monitor);
+ project.open(monitor);
+ } catch (final IOException e) {
+ log(e);
+ } catch (final CoreException e) {
+ log(e);
+ }
+ }
+
+ /**
+ * A descriptor class that describes where to find the zipped contents of a project and what that project
+ * should be named when unzipped into the workspace.
+ */
+ public static class ProjectDescriptor {
+ /** Name of the plugin where the zip file is located. */
+ private final String bundleName;
+
+ /** Name of the project that should be created when unzipping. */
+ private final String projectName;
+
+ /** Location (relative to the bundle root) of the file to unzip. */
+ private final String zipLocation;
+
+ /**
+ * Construct a descriptor that points to a zip file located in a particular bundle at the given
+ * location within that bundle. Also provided is the project name for which the zip is the contents.
+ * Note that this project name should be the same as is in the contents not some alternative name.
+ *
+ * @param bundleName
+ * The bundle in the runtime that contains the zipped up project contents.
+ * @param zipLocation
+ * The location within the bundle where the zip file is located.
+ * @param projectName
+ * The project name in the workspace that will be created to house the project contents.
+ */
+ public ProjectDescriptor(String bundleName, String zipLocation, String projectName) {
+ super();
+ this.bundleName = bundleName;
+ this.zipLocation = zipLocation;
+ this.projectName = projectName;
+ }
+
+ /**
+ * Returns the bundle name.
+ *
+ * @return The bundle name.
+ */
+ public String getBundleName() {
+ return bundleName;
+ }
+
+ /**
+ * Returns the project name.
+ *
+ * @return The project name.
+ */
+ public String getProjectName() {
+ return projectName;
+ }
+
+ /**
+ * Returns the zip file location.
+ *
+ * @return The zip file location.
+ */
+ public String getZipLocation() {
+ return zipLocation;
+ }
+ }
+}
diff --git a/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/Ecore2PythonExampleWizard.java b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/Ecore2PythonExampleWizard.java
new file mode 100644
index 0000000..9bdc207
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/Ecore2PythonExampleWizard.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.examples.internal.wizard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.acceleo.examples.internal.AcceleoExamplesPlugin;
+
+/**
+ * This will allow the user to unzip the ecore2python example module.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class Ecore2PythonExampleWizard extends AbstractExampleWizard {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.examples.internal.wizard.AbstractExampleWizard#getProjectDescriptors()
+ */
+ @Override
+ protected Collection<ProjectDescriptor> getProjectDescriptors() {
+ final List<ProjectDescriptor> projects = new ArrayList<ProjectDescriptor>(2);
+ projects
+ .add(new ProjectDescriptor(
+ "org.eclipse.acceleo.examples", "examples/org.eclipse.acceleo.module.example.ecore2python.zip", "org.eclipse.acceleo.module.example.ecore2python")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ projects
+ .add(new ProjectDescriptor(
+ "org.eclipse.acceleo.examples", "examples/org.eclipse.acceleo.module.example.ecore2python.ui.zip", "org.eclipse.acceleo.module.example.ecore2python.ui")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ return projects;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.examples.internal.wizard.AbstractExampleWizard#log(java.lang.Exception)
+ */
+ @Override
+ protected void log(Exception e) {
+ if (e instanceof CoreException) {
+ AcceleoExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
+ } else {
+ AcceleoExamplesPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, AcceleoExamplesPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
+ }
+ }
+}
diff --git a/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/Uml2JavaExampleWizard.java b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/Uml2JavaExampleWizard.java
new file mode 100644
index 0000000..b912311
--- /dev/null
+++ b/examples/org.eclipse.acceleo.examples/src/org/eclipse/acceleo/examples/internal/wizard/Uml2JavaExampleWizard.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.examples.internal.wizard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.acceleo.examples.internal.AcceleoExamplesPlugin;
+
+/**
+ * This will allow the user to unzip the uml2java example module.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public class Uml2JavaExampleWizard extends AbstractExampleWizard {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.examples.internal.wizard.AbstractExampleWizard#getProjectDescriptors()
+ */
+ @Override
+ protected Collection<ProjectDescriptor> getProjectDescriptors() {
+ final List<ProjectDescriptor> projects = new ArrayList<ProjectDescriptor>(2);
+ projects
+ .add(new ProjectDescriptor(
+ "org.eclipse.acceleo.examples", "examples/org.eclipse.acceleo.module.example.uml2java.zip", "org.eclipse.acceleo.module.example.uml2java")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ projects
+ .add(new ProjectDescriptor(
+ "org.eclipse.acceleo.examples", "examples/org.eclipse.acceleo.module.example.uml2java.ui.zip", "org.eclipse.acceleo.module.example.uml2java.ui")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ return projects;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.acceleo.examples.internal.wizard.AbstractExampleWizard#log(java.lang.Exception)
+ */
+ @Override
+ protected void log(Exception e) {
+ if (e instanceof CoreException) {
+ AcceleoExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
+ } else {
+ AcceleoExamplesPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, AcceleoExamplesPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
+ }
+ }
+}