summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmusset2009-03-05 11:44:51 (EST)
committer jmusset2009-03-05 11:44:51 (EST)
commit3187dff74d915a1e95a908da9d6e7a2209fd6d2c (patch)
tree0e063720ecc0bfcab4c1e09a6cbefd4b9078fd25
parentf46719bd4e96d735e3e263006e10da65b28d0a2d (diff)
downloadorg.eclipse.acceleo-3187dff74d915a1e95a908da9d6e7a2209fd6d2c.zip
org.eclipse.acceleo-3187dff74d915a1e95a908da9d6e7a2209fd6d2c.tar.gz
org.eclipse.acceleo-3187dff74d915a1e95a908da9d6e7a2209fd6d2c.tar.bz2
Project renaming from MTL to Acceleo
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/.checkstyle9
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/.classpath7
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/.cvsignore1
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/.project28
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/META-INF/MANIFEST.MF20
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/build.properties17
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/icons/default.gifbin0 -> 676 bytes
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/plugin.xml34
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/Activator.java68
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/common/GenerateAll.java139
-rw-r--r--examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/popupMenus/AcceleoGenerateUmlToJavaAction.java115
12 files changed, 444 insertions, 0 deletions
diff --git a/examples/org.eclipse.acceleo.module.example.uml2java.ui/.checkstyle b/examples/org.eclipse.acceleo.module.example.uml2java.ui/.checkstyle
new file mode 100644
index 0000000..60d2e33
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.ui/.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.module.example.uml2java.ui/.classpath b/examples/org.eclipse.acceleo.module.example.uml2java.ui/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.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.uml2java.ui/.cvsignore b/examples/org.eclipse.acceleo.module.example.uml2java.ui/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.ui/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/examples/org.eclipse.acceleo.module.example.uml2java.ui/.project b/examples/org.eclipse.acceleo.module.example.uml2java.ui/.project
new file mode 100644
index 0000000..a120b04
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.acceleo.module.example.uml2java.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.uml2java.ui/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.acceleo.module.example.uml2java.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d1c0bf9
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.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.uml2java.ui/META-INF/MANIFEST.MF b/examples/org.eclipse.acceleo.module.example.uml2java.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e1993b9
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Acceleo Uml To Java Module IDE Plug-in
+Bundle-SymbolicName: org.eclipse.acceleo.module.example.uml2java.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.acceleo.module.example.uml2java.ui.Activator
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.acceleo.module.example.uml2java,
+ 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.uml2java.ui/build.properties b/examples/org.eclipse.acceleo.module.example.uml2java.ui/build.properties
new file mode 100644
index 0000000..aa9a63c
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.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.uml2java.ui/icons/default.gif b/examples/org.eclipse.acceleo.module.example.uml2java.ui/icons/default.gif
new file mode 100644
index 0000000..d8a3137
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.ui/icons/default.gif
Binary files differ
diff --git a/examples/org.eclipse.acceleo.module.example.uml2java.ui/plugin.xml b/examples/org.eclipse.acceleo.module.example.uml2java.ui/plugin.xml
new file mode 100644
index 0000000..ece2837
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.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="*.uml"
+ id="org.eclipse.acceleo.module.example.uml2java.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.uml2java.ui.popupMenus.AcceleoGenerateUmlToJavaAction"
+ enablesFor="+"
+ id="org.eclipse.acceleo.module.example.uml2java.ui.popupMenus.acceleoGenerateUmlToJavaAction"
+ icon="icons/default.gif"
+ label="Generate Uml To Java"
+ menubarPath="org.eclipse.acceleo.module.menu/acceleo"/>
+ </objectContribution>
+ </extension>
+</plugin>
diff --git a/examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/Activator.java b/examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/Activator.java
new file mode 100644
index 0000000..af7b5ae
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/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.uml2java.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.uml2java.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.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/common/GenerateAll.java b/examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/common/GenerateAll.java
new file mode 100644
index 0000000..d9b6eda
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/common/GenerateAll.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * 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.uml2java.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.osgi.framework.Bundle;
+
+
+/**
+ * Main entry point of the 'Uml To Java' 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.uml2java", new Path("/org/eclipse/acceleo/module/example/uml2java/generateJava.emtl"));
+ org.eclipse.acceleo.module.example.uml2java.GenerateJava gen0 = new org.eclipse.acceleo.module.example.uml2java.GenerateJava(modelURI, targetFolder, arguments) {
+ protected URI createTemplateURI(String entry) {
+ return template0;
+ }
+ };
+ gen0.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.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/popupMenus/AcceleoGenerateUmlToJavaAction.java b/examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/popupMenus/AcceleoGenerateUmlToJavaAction.java
new file mode 100644
index 0000000..3fdabbb
--- /dev/null
+++ b/examples/org.eclipse.acceleo.module.example.uml2java.ui/src/org/eclipse/acceleo/module/example/uml2java/ui/popupMenus/AcceleoGenerateUmlToJavaAction.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.uml2java.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.uml2java.ui.Activator;
+import org.eclipse.acceleo.module.example.uml2java.ui.common.GenerateAll;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * Uml To Java code generation.
+ *
+ * @author <a href="mailto:jonathan.musset@obeo.fr">Jonathan Musset</a>
+ *
+ */
+public class AcceleoGenerateUmlToJavaAction 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