Merge "Bug 525378 - [PapyrusReq] Add migration of Requirements from SysML 1.4 model to PapyrusRE model"
diff --git a/features/org.eclipse.papyrus.requirements.core.feature/feature.xml b/features/org.eclipse.papyrus.requirements.core.feature/feature.xml
index f06a2b0..638739f 100755
--- a/features/org.eclipse.papyrus.requirements.core.feature/feature.xml
+++ b/features/org.eclipse.papyrus.requirements.core.feature/feature.xml
@@ -171,4 +171,18 @@
version="0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.papyrus.requirements.sysml14.migrationtoreq"
+ download-size="0"
+ install-size="0"
+ version="0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui"
+ download-size="0"
+ install-size="0"
+ version="0"
+ unpack="false"/>
+
</feature>
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/.classpath b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.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/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/.project b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/.project
new file mode 100644
index 0000000..05598cd
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.requirements.sysml14.migrationtoreq.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/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/META-INF/MANIFEST.MF b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..61be313
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-Vendor: %Bundle-Vendor
+Bundle-Localization: plugin
+Bundle-Version: 0.7.0.qualifier
+Bundle-SymbolicName: org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui;singleton:=true
+Bundle-Activator: org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui.Activator
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.ecore;bundle-version="2.13.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="3.0.0",
+ org.eclipse.uml2.uml;bundle-version="5.3.0",
+ org.eclipse.papyrus.requirements.sysml14.migrationtoreq;bundle-version="0.7.0",
+ org.eclipse.papyrus.requirements.sysml14.papyrusre,
+ org.eclipse.papyrus.uml.tools.utils
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/about.html b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/about.html
new file mode 100644
index 0000000..d35d5ae
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/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>June 5, 2007</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>
+
+</body>
+</html>
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/build.properties b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/build.properties
new file mode 100644
index 0000000..631c8df
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/build.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# Copyright (c) 2017 CEA LIST.
+# 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:
+# Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ about.html,\
+ plugin.xml
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/plugin.properties b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/plugin.properties
new file mode 100644
index 0000000..a984da4
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/plugin.properties
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2017 CEA LIST.
+# 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:
+# Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+###############################################################################
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = SysML 1.4 Papyrus for Requirements - Migration To PapyrusReq UI (Incubation)
+
+papyrus.requirements.sysml14.migrationtoreq.menu.label = Migration Tools
+papyrus.requirements.sysml14.migrationtoreq.sysml14topapyrusre.label = Migrate SysML14 Requirements to PapyrusReq
+papyrus.requirements.sysml14.migrationtoreq.sysml14topapyrusre.description = Migrate SysML14 Requirements to PapyrusReq
\ No newline at end of file
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/plugin.xml b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/plugin.xml
new file mode 100644
index 0000000..d8aebb9
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/plugin.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:papyrus.requirements.menu">
+ <menu
+ id="papyrus.requirements.sysml14.migrationtoreq.menu"
+ label="%papyrus.requirements.sysml14.migrationtoreq.menu.label">
+ <command
+ commandId="papyrus.requirements.sysml14.migrationtoreq.sysml14topapyrusre.command"
+ label="%papyrus.requirements.sysml14.migrationtoreq.sysml14topapyrusre.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menu>
+ </menuContribution>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ description="%papyrus.requirements.sysml14.migrationtoreq.sysml14topapyrusre.description"
+ id="papyrus.requirements.sysml14.migrationtoreq.sysml14topapyrusre.command"
+ name="%papyrus.requirements.sysml14.migrationtoreq.sysml14topapyrusre.label">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui.handler.SysML14ToPapyrusREHandler"
+ commandId="papyrus.requirements.sysml14.migrationtoreq.sysml14topapyrusre.command">
+ <activeWhen>
+ <and>
+ <with
+ variable="selection">
+ <iterate>
+ <adapt
+ type="org.eclipse.emf.ecore.EObject">
+ <instanceof
+ value="org.eclipse.uml2.uml.Package">
+ </instanceof>
+ </adapt>
+ </iterate>
+ </with>
+ <count
+ value="1">
+ </count>
+ </and>
+ </activeWhen>
+ </handler>
+ </extension>
+
+</plugin>
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/pom.xml b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/pom.xml
new file mode 100644
index 0000000..c3ff70c
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ /*****************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Parent POM (i.e., Bundles) -->
+ <parent>
+ <groupId>org.eclipse.papyrus.requirements</groupId>
+ <artifactId>org.eclipse.papyrus.requirements.plugins.sysml14</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </parent>
+
+ <!-- POM Description -->
+ <artifactId>org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project>
\ No newline at end of file
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/Activator.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/Activator.java
new file mode 100644
index 0000000..a850ff2
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/Activator.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ * 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:
+ * Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.requirements.sysml14.migrationtoreq.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 = "org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ 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/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/SysML14ToPapyrusREHandler.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/SysML14ToPapyrusREHandler.java
new file mode 100644
index 0000000..dc85c5e
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/SysML14ToPapyrusREHandler.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ * 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:
+ * Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.requirements.sysml14.migrationtoreq.SysML14ToPapyrusRE;
+import org.eclipse.papyrus.requirements.sysml14.migrationtoreq.SysML14ToPapyrusRERules;
+import org.eclipse.papyrus.requirements.sysml14.papyrusre.set.PapyrusRESet;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+
+/**
+ * Handler class for migrating a SysML 1.4 model to a PapyrusRE model.
+ *
+ */
+public class SysML14ToPapyrusREHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ EObject selectedEObject = getEObjectOfSelection();
+
+ if (selectedEObject == null) {
+ return null;
+ }
+
+ if (selectedEObject instanceof Package) {
+ Package selectedPackage = (Package) selectedEObject;
+
+ Model topModel = (Model) getTopElement(selectedPackage);
+
+ Profile papyrusREProfile = (Profile) PackageUtil.loadPackage(URI.createURI(PapyrusRESet.PROFILE_PATH), topModel.eResource().getResourceSet());
+ SysML14ToPapyrusRERules rules = new SysML14ToPapyrusRERules();
+ SysML14ToPapyrusRE.executeMigration(selectedPackage, rules, papyrusREProfile, topModel);
+ }
+
+ return null;
+ }
+
+ /**
+ * Get top owner element of the given element.
+ *
+ * @param element
+ * Starting point of the search
+ * @return Top model found
+ */
+ private static Element getTopElement(final Element element) {
+
+ if (element.getOwner() != null) {
+ return getTopElement(element.getOwner());
+ } else {
+ return element;
+ }
+
+ }
+
+ /**
+ * Get the selected EObject from Model Explorer.
+ *
+ * @return
+ */
+ private static EObject getEObjectOfSelection() {
+ IStructuredSelection selection = (IStructuredSelection) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ EObject selectedEObject = null;
+
+ if (selection != null) {
+ selectedEObject = EMFHelper.getEObject(selection.getFirstElement());
+ }
+
+ return selectedEObject;
+ }
+
+ /**
+ * The handler is capable of executing at this time if the selected element is a UML Class.
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEnabled() {
+ if (getEObjectOfSelection() instanceof Package) {
+ return true;
+ }
+ return super.isEnabled();
+ }
+
+}
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.classpath b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.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/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.project b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.project
new file mode 100644
index 0000000..0f47663
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.requirements.sysml14.migrationtoreq</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/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.settings/org.eclipse.jdt.core.prefs b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/META-INF/MANIFEST.MF b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..b4081aa
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-Vendor: %Bundle-Vendor
+Bundle-Localization: plugin
+Bundle-Version: 0.7.0.qualifier
+Bundle-SymbolicName: org.eclipse.papyrus.requirements.sysml14.migrationtoreq;singleton:=true
+Bundle-Activator: org.eclipse.papyrus.requirements.sysml14.migrationtoreq.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.uml2.uml;bundle-version="5.3.0",
+ org.eclipse.gmf.runtime.emf.core,
+ org.eclipse.emf.common,
+ org.eclipse.papyrus.requirements.sysml14.papyrusre;bundle-version="0.7.0",
+ org.eclipse.papyrus.requirements.sysml14.papyrusre.modellibrary;bundle-version="0.7.0",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="3.1.0",
+ org.eclipse.emf.transaction,
+ org.eclipse.papyrus.infra.emf,
+ org.eclipse.papyrus.infra.core.log,
+ org.eclipse.ui.workbench
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.papyrus.requirements.sysml14.migrationtoreq
+
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/about.html b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/about.html
new file mode 100644
index 0000000..d35d5ae
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/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>June 5, 2007</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>
+
+</body>
+</html>
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/build.properties b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/build.properties
new file mode 100644
index 0000000..5195293
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/build.properties
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2017 CEA LIST.
+# 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:
+# Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ about.html
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/plugin.properties b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/plugin.properties
new file mode 100644
index 0000000..8c865c2
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/plugin.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2017 CEA LIST.
+# 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:
+# Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+###############################################################################
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = SysML 1.4 Papyrus for Requirements - Migration to PapyrusReq (Incubation)
\ No newline at end of file
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/pom.xml b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/pom.xml
new file mode 100644
index 0000000..4a08266
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ /*****************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Parent POM (i.e., Bundles) -->
+ <parent>
+ <groupId>org.eclipse.papyrus.requirements</groupId>
+ <artifactId>org.eclipse.papyrus.requirements.plugins.sysml14</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </parent>
+
+ <!-- POM Description -->
+ <artifactId>org.eclipse.papyrus.requirements.sysml14.migrationtoreq</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project>
\ No newline at end of file
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/Activator.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/Activator.java
new file mode 100644
index 0000000..f7bf653
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/Activator.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ * 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:
+ * Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.requirements.sysml14.migrationtoreq;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.requirements.sysml14.migrationtoreq"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ 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/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/MigrationFromSysML14Rules.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/MigrationFromSysML14Rules.java
new file mode 100644
index 0000000..4af4098
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/MigrationFromSysML14Rules.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ * 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:
+ * Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.requirements.sysml14.migrationtoreq;
+
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * Interface to define the migration rules from SysML 1.4 model to a target domain model.
+ *
+ */
+public interface MigrationFromSysML14Rules {
+
+ /**
+ * Set migration of a requirement (SysML 1.4) to another element from target domain model.
+ *
+ * @param element
+ * @param sysmlRequirement
+ */
+ public void setRequirement(Element element, org.eclipse.papyrus.sysml14.requirements.Requirement sysmlRequirement);
+
+}
\ No newline at end of file
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRE.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRE.java
new file mode 100644
index 0000000..254f801
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRE.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ * 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:
+ * Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.requirements.sysml14.migrationtoreq;
+
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.sysml14.requirements.Requirement;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * This class executes the migration from SysML 1.4 model to PapyrusRE model.
+ *
+ */
+public class SysML14ToPapyrusRE {
+
+ /** Label of the command to apply annotation on the UML model. */
+ private static final String CMD_LABEL_APPLY_ANNOTATION_ON_UML_MODEL = "PapyrusRE: Apply Annotation on the UML model"; //$NON-NLS-1$
+
+ /** Message of the error during the service registry search. */
+ private static final String ERROR_SERVICE_REAGITRY_SEARCH = "Error during the service registry search"; //$NON-NLS-1$
+
+ public static void executeMigration(final Package rootPackage, final MigrationFromSysML14Rules migrationRules, final Profile targetProfile, Model topModel) {
+
+ TransactionalEditingDomain domain = getTransactionalEditingDomain(rootPackage);
+
+ RecordingCommand applyAnnotationCmd = new RecordingCommand(domain, CMD_LABEL_APPLY_ANNOTATION_ON_UML_MODEL) {
+ @Override
+ protected void doExecute() {
+ if (!topModel.isProfileApplied(targetProfile)) {
+ PackageUtil.applyProfile(topModel, targetProfile, true);
+ }
+
+ if (topModel.isProfileApplied(targetProfile)) {
+ walkThroughPackageAndApplyRules(rootPackage, migrationRules);
+ }
+ }
+ };
+
+ try {
+ domain.getCommandStack().execute(applyAnnotationCmd);
+ } catch (final IllegalArgumentException exception) {
+ Activator.log.error("Error during the application of the PapyrusRE annotation on the model", exception); //$NON-NLS-1$
+
+ }
+ }
+
+ protected static void walkThroughPackageAndApplyRules(Package rootPackage, MigrationFromSysML14Rules migrationRules) {
+ for (Element element : rootPackage.allOwnedElements()) {
+ Requirement sysmlRequirement = UMLUtil.getStereotypeApplication(element, Requirement.class);
+
+ if (sysmlRequirement != null) {
+ migrationRules.setRequirement(element, sysmlRequirement);
+ element.unapplyStereotype(UMLUtil.getStereotype(sysmlRequirement));
+ }
+ }
+
+ }
+
+
+ /**
+ * Get transactional editing domain.
+ *
+ * @param element
+ * Element for which an editing domain is searched
+ * @return TransactionalEditingDomain found
+ */
+ private static TransactionalEditingDomain getTransactionalEditingDomain(final Element element) {
+ TransactionalEditingDomain editingDomain = null;
+
+ ServicesRegistry vServiceRegistry = null;
+ try {
+ vServiceRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(element);
+ } catch (final ServiceException exception) {
+ Activator.log.error(ERROR_SERVICE_REAGITRY_SEARCH, exception);
+ }
+
+ try {
+ editingDomain = vServiceRegistry.getService(TransactionalEditingDomain.class);
+ } catch (final ServiceException exception) {
+ Activator.log.error(ERROR_SERVICE_REAGITRY_SEARCH, exception);
+ }
+
+ return editingDomain;
+ }
+}
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRERules.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRERules.java
new file mode 100644
index 0000000..a67b4b0
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRERules.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ * 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:
+ * Yupanqui Munoz Julho (CEA LIST) <yupanqui.munozjulho@cea.fr> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.requirements.sysml14.migrationtoreq;
+
+import org.eclipse.papyrus.requirements.sysml14.papyrusre.requirementgenericcharacteristics.Requirement;
+import org.eclipse.papyrus.requirements.sysml14.papyrusre.requirementgenericcharacteristics.RequirementGenericCharacteristicsPackage;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * This class to define the migration rules from SysML 1.4 model to PapyrusRE model.
+ *
+ */
+public class SysML14ToPapyrusRERules implements MigrationFromSysML14Rules {
+
+ /**
+ * @see org.eclipse.papyrus.requirements.sysml14.migrationtoreq.MigrationFromSysML14Rules#setRequirement(org.eclipse.uml2.uml.Element, org.eclipse.papyrus.sysml14.requirements.Requirement)
+ *
+ * @param element
+ * @param sysmlRequirement
+ */
+ @Override
+ public void setRequirement(Element element, org.eclipse.papyrus.sysml14.requirements.Requirement sysmlRequirement) {
+ UMLUtil.StereotypeApplicationHelper.getInstance(element).applyStereotype(element, RequirementGenericCharacteristicsPackage.eINSTANCE.getRequirement());
+
+ Requirement requirement = UMLUtil.getStereotypeApplication(element, Requirement.class);
+
+ requirement.setId(sysmlRequirement.getId());
+ requirement.setText(sysmlRequirement.getText());
+ }
+
+}
diff --git a/plugins/sysml14/pom.xml b/plugins/sysml14/pom.xml
index 2db576a..08e57e7 100755
--- a/plugins/sysml14/pom.xml
+++ b/plugins/sysml14/pom.xml
@@ -49,6 +49,13 @@
org.eclipse.papyrus.requirements.sysml14.papyrusre.modellibrary.ui
</module>
+ <module>
+ org.eclipse.papyrus.requirements.sysml14.migrationtoreq
+ </module>
+ <module>
+ org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui
+ </module>
+
<module>
org.eclipse.papyrus.requirements.sysml14.assistant.commands