Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauricio Alferez2015-11-05 17:11:27 +0000
committerGerrit Code Review @ Eclipse.org2015-11-10 09:52:02 +0000
commit723215e77aaeda9e8acf6b6ca588db7dbd235a4c (patch)
tree3b7d01e2240f002f0ce5cc03a9325ddaf39de883 /extraplugins
parent84360d0f239ccb65f943204b85a29a444f2d122e (diff)
downloadorg.eclipse.papyrus-723215e77aaeda9e8acf6b6ca588db7dbd235a4c.tar.gz
org.eclipse.papyrus-723215e77aaeda9e8acf6b6ca588db7dbd235a4c.tar.xz
org.eclipse.papyrus-723215e77aaeda9e8acf6b6ca588db7dbd235a4c.zip
Bug 481377 - [Extra plugins][Req] The assistant shall support the
creation of initial profiles based on class diagram - New plugin req.domainModel2profile - New submenu in PapyrusReq called "Tools to define requirements profile" with two entries: "Define or Update Stereotype and Profile on Demand", and "Generate Profile from Domain Model". --- - I updated the org.eclipse.papyrus.req.feature to include the new req.domainModel2profile plugin and the pom.xml files. - I also took the time to correct comments and typos. Change-Id: Id829cd3dad789e691f1164af89463f8afbeb72e9 Signed-off-by: Mauricio Alferez <mauricio.alferez@cea.fr>
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.classpath7
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.gitignore1
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.project28
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/META-INF/MANIFEST.MF28
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/about.html28
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/build.properties8
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/bundle.properties4
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/plugin.xml14
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/pom.xml13
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/Activator.java44
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/command/CreateProfileFromDomainModelCommand.java48
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/generator/ProfileGenerator.java466
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/handler/CreateProfileFromDomainModelHandler.java54
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/handler/PapyrusAbstractHandler.java123
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/utils/Utils.java282
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/META-INF/MANIFEST.MF16
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/images/Profile.gifbin0 -> 154 bytes
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.properties12
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.xml47
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/I_SysMLStereotype.java2
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddDerivedLinkReqCommand.java2
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddSatisfyLinkCommand.java2
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddVerifyLinkCommand.java2
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/CommentReqCommand.java2
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DecomposeReqCommand.java9
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DerivationReqCreateCommand.java2
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/ExtractCommentCommand.java2
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitCreateProfileFromDomainModelCommand.java66
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDecomposeReqCommand.java32
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDefineDomainSpecificRequirementsConceptsCommand.java69
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDerivedReqCommand.java2
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/PapyrusReqSysMLRequirementCreateCommand.java77
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/SatisfyCreateCommand.java32
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/VerifyCreateCommand.java32
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddDerivedLinkReqHandler.java34
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddSatisfyLinkHandler.java33
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddVerifyLinkHandler.java33
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/CommentReqHandler.java24
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/DecomposeReqHandler.java11
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/ExtractCommentsHandler.java24
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitCreateInitialProfileFromDomainModelHandler.java54
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDefineRequirementsLanguageHandler.java53
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDerivedReqHandler.java25
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusAbstractHandler.java (renamed from extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusReqSysMLAbstractHandler.java)6
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusReqSysMLRequirementHandler.java29
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/testers/ProfileTester.java52
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceConstants.java6
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceInitializer.java12
-rw-r--r--extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferencePage.java39
50 files changed, 1760 insertions, 238 deletions
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.classpath b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.classpath
new file mode 100644
index 00000000000..b1dabee3829
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.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.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.gitignore b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.gitignore
new file mode 100644
index 00000000000..ae3c1726048
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.project b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.project
new file mode 100644
index 00000000000..ff8662e7ce2
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.req.domainModel2Profile</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/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.settings/org.eclipse.jdt.core.prefs b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..11f6e462df7
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/.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.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/META-INF/MANIFEST.MF b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..974a54a881c
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.papyrus.req.domainModel2Profile;singleton:=true
+Bundle-Version: 0.7.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.req.domainModel2Profile.Activator
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.common,
+ org.eclipse.emf.ecore,
+ org.eclipse.uml2.uml,
+ org.eclipse.uml2.uml.resources,
+ org.eclipse.ui,
+ org.eclipse.emf.transaction,
+ org.eclipse.papyrus.infra.core,
+ org.eclipse.papyrus.infra.emf,
+ org.eclipse.gmf.runtime.diagram.ui,
+ org.eclipse.core.resources,
+ org.eclipse.papyrus.req.sysml.preferences
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.gmf.runtime.notation
+Export-Package: org.eclipse.papyrus.req.domainModel2Profile,
+ org.eclipse.papyrus.req.domainModel2Profile.command,
+ org.eclipse.papyrus.req.domainModel2Profile.generator,
+ org.eclipse.papyrus.req.domainModel2Profile.handler,
+ org.eclipse.papyrus.req.domainModel2Profile.utils
+Bundle-Localization: bundle
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/about.html b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/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>November 14, 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/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/build.properties b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/build.properties
new file mode 100644
index 00000000000..34dfd31bf32
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ about.html,\
+ bundle.properties
+src.includes = about.html
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/bundle.properties b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/bundle.properties
new file mode 100644
index 00000000000..2ed4d95ced8
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/bundle.properties
@@ -0,0 +1,4 @@
+#Properties file for org.eclipse.papyrus.req.domainModel2Profile
+command.name = Generate Profile from Domain Model
+Bundle-Vendor = CEA
+Bundle-Name = Generate Profile from Domain Model \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/plugin.xml b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/plugin.xml
new file mode 100644
index 00000000000..b272649564a
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/plugin.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.req.domainModel2Profile.handler.CreateProfileFromDomainModelHandler"
+ id="org.eclipse.papyrus.req.domainModel2Profile.handler.CreateProfileFromDomainModelHandler"
+ name="%command.name">
+ </command>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/pom.xml b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/pom.xml
new file mode 100644
index 00000000000..426587db605
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/pom.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.extra.releng</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../../../releng/extra</relativePath>
+ </parent>
+ <artifactId>org.eclipse.papyrus.req.domainModel2Profile</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/Activator.java b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/Activator.java
new file mode 100644
index 00000000000..94c8fdca588
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/Activator.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ *
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.req.domainModel2Profile;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/command/CreateProfileFromDomainModelCommand.java b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/command/CreateProfileFromDomainModelCommand.java
new file mode 100644
index 00000000000..22eca870443
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/command/CreateProfileFromDomainModelCommand.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ *
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.req.domainModel2Profile.command;
+
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.req.domainModel2Profile.generator.ProfileGenerator;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+
+/**
+ *
+ * Generates an UML profile based on a UML domain model
+ *
+ */
+
+public class CreateProfileFromDomainModelCommand extends RecordingCommand {
+ protected Element selectedElement;
+
+ public CreateProfileFromDomainModelCommand(TransactionalEditingDomain domain, Element selectedElement) {
+ super(domain, "CreateProfileFromDomainModelCommand");
+ this.selectedElement = selectedElement;
+ }
+
+ protected void createProfile(org.eclipse.uml2.uml.Package selectedPackage) {
+ ProfileGenerator profileGenerator = new ProfileGenerator(selectedPackage);
+ profileGenerator.generate();
+ }
+
+ @Override
+ protected void doExecute() {
+ if (selectedElement instanceof Package) {
+ createProfile((Package) selectedElement);
+ }
+ }
+} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/generator/ProfileGenerator.java b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/generator/ProfileGenerator.java
new file mode 100644
index 00000000000..8b7a3dcdaa1
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/generator/ProfileGenerator.java
@@ -0,0 +1,466 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ *
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.req.domainModel2Profile.generator;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.req.domainModel2Profile.utils.Utils;
+import org.eclipse.papyrus.req.sysml.preferences.Activator;
+import org.eclipse.papyrus.req.sysml.preferences.PreferenceConstants;
+import org.eclipse.uml2.uml.Abstraction;
+import org.eclipse.uml2.uml.Association;
+//import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.resource.UMLResource;
+import org.eclipse.uml2.uml.resources.util.UMLResourcesUtil;
+
+/**
+ * Generates an UML profile based on a UML domain model
+ *
+ */
+public class ProfileGenerator {
+ protected static ResourceSet resourceSet;
+ // Output profile created based on the domain model
+ protected Profile profile;
+ // Input package representing the domain model
+ protected Package sourcePackage;
+ // File of the sourcePackage
+ protected File sourceModelFile;
+ // Generation options
+ private static String NSURI_PREFIX = "https://www.eclipse.org/papyrus/";
+ private static boolean GENERATE_ABSTRACTIONS_MODEL = false;
+ private static boolean FROM_ASSOCIATIONS_TO_STEREOTYPES = false;
+ private static String METACLASS_EXTENDED_BY_NODES = UMLPackage.Literals.CLASS.getName();
+ private static String METACLASS_EXTENDED_BY_EDGES = UMLPackage.Literals.ASSOCIATION.getName();
+ // Debug=true will automatically refresh the project to show the output
+ // files.
+ private static boolean DEBUG = true;
+ protected Stereotype baseNodeStereotype;
+ protected Stereotype baseEdgeStereotype;
+ protected Map<Element, Element> mapClassNodes = new HashMap<Element, Element>();
+ protected Map<Element, Element> mapAssociationsEdges = new HashMap<Element, Element>();
+ protected Map<Element, Element> mapPrimitiveTypesNodes = new HashMap<Element, Element>();
+ protected Map<Element, Element> mapEnumerationsNodes = new HashMap<Element, Element>();
+ protected Map<Element, Element> mapPackagesNodes = new HashMap<Element, Element>();
+ protected List<PrimitiveType> listStandardPrimitiveTypes = new ArrayList<PrimitiveType>();
+ protected String outputDirectoryPath;
+ protected List<Generalization> listInternalGeneralizations = new ArrayList<Generalization>();
+ protected Model abstractionsModel;
+
+ /**
+ * Constructor to be called by Eclipse, takes into account generation
+ * preferences
+ *
+ * @param selectedPackage
+ * uml domain model
+ */
+ public ProfileGenerator(Package selectedPackage) {
+ DEBUG = false;
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ NSURI_PREFIX = store.getString(PreferenceConstants.NSURI_PREFIX);
+ GENERATE_ABSTRACTIONS_MODEL = store.getBoolean(PreferenceConstants.GENERATE_ABSTRACTIONS_MODEL);
+ FROM_ASSOCIATIONS_TO_STEREOTYPES = store.getBoolean(PreferenceConstants.FROM_ASSOCIATIONS_TO_STEREOTYPES);
+ // METACLASS_EXTENDED_BY_NODES =
+ // store.getString(PreferenceConstants.METACLASS_EXTENDED_BY_NODES);
+ // //by default "none"
+ // METACLASS_EXTENDED_BY_EDGES =
+ // store.getString(PreferenceConstants.METACLASS_EXTENDED_BY_EDGES);
+ // //by default "none"
+ sourcePackage = selectedPackage;
+ URI uri = sourcePackage.eResource().getURI();
+ sourceModelFile = Utils.getFileFromURI(uri);
+ outputDirectoryPath = sourceModelFile.getParent();
+ setResourceSet();
+ }
+
+ /**
+ * Constructor to be used in an standalone Java application, takes into
+ * account
+ *
+ * @param selectedPackage
+ */
+ public ProfileGenerator(String _inputModelPath, String _outputDirectoryPath, String _prefix) {
+ DEBUG = true;
+ NSURI_PREFIX = _prefix;
+ ResourceSet resourceSetSourceModel = new ResourceSetImpl();
+ UMLResourcesUtil.init(resourceSetSourceModel);
+ URI _inputModelURI = URI.createFileURI(new File(_inputModelPath).getAbsolutePath());
+ Resource r = resourceSetSourceModel.getResource(_inputModelURI, true);
+ sourcePackage = (Package) EcoreUtil.getObjectByType(r.getContents(), UMLPackage.Literals.PACKAGE);
+ sourceModelFile = new File(_inputModelPath).getAbsoluteFile();
+ outputDirectoryPath = new File(_outputDirectoryPath).getAbsolutePath();
+ setResourceSet();
+ }
+
+ protected void setResourceSet() {
+ resourceSet = new ResourceSetImpl();
+ UMLResourcesUtil.init(resourceSet);
+ }
+
+ public void generate() {
+ String nameOfAbstractionsModel = sourcePackage.getName() + "_refinement";
+ String nameOfProfile = sourcePackage.getName();
+ setProfile(Utils.createProfile(nameOfProfile, NSURI_PREFIX + sourcePackage.getName()));
+
+ if (!METACLASS_EXTENDED_BY_NODES.contentEquals("none")) {
+ baseNodeStereotype = Utils.createStereotype(profile, "baseNodeStereotype", true);
+ }
+ if (!METACLASS_EXTENDED_BY_EDGES.contentEquals("none")) {
+ baseEdgeStereotype = Utils.createStereotype(profile, "baseEdgeStereotype", true);
+ }
+
+ visitPackagedElements(sourcePackage);
+
+ String[] requiredPrimitiveTypes = { "Boolean", "Real", "String", "Integer", "UnlimitedNatural" };
+ createStandardPrimitiveTypes(requiredPrimitiveTypes);
+
+ createProfiles(mapClassNodes);
+ createProfiles(mapPrimitiveTypesNodes);
+ createProfiles(mapEnumerationsNodes);
+ if (FROM_ASSOCIATIONS_TO_STEREOTYPES) {
+ createProfiles(mapAssociationsEdges);
+ }
+ createEnumerationLiterals();
+ createTagDefinitions();
+ createInternalGeneralizations();
+
+ if (!METACLASS_EXTENDED_BY_NODES.contentEquals("none")
+ && referenceMetaclass(profile, METACLASS_EXTENDED_BY_NODES) != null) {
+ createGeneralizations(mapClassNodes.keySet(), baseNodeStereotype);
+ Utils.createExtension(referenceMetaclass(profile, METACLASS_EXTENDED_BY_NODES), baseNodeStereotype, false);
+ }
+ if (!METACLASS_EXTENDED_BY_EDGES.contentEquals("none")
+ && referenceMetaclass(profile, METACLASS_EXTENDED_BY_NODES) != null) {
+ createGeneralizations(mapAssociationsEdges.keySet(), baseEdgeStereotype);
+ Utils.createExtension(referenceMetaclass(profile, METACLASS_EXTENDED_BY_EDGES), baseEdgeStereotype, false);
+ }
+
+ Utils.defineProfile(profile);
+
+ for (Element element : mapPackagesNodes.keySet()) {
+ if (element instanceof Profile) {
+ Utils.defineProfile((Profile) element);
+ }
+ }
+
+ save(profile, outputDirectoryPath, nameOfProfile, UMLResource.PROFILE_FILE_EXTENSION);
+
+ if (GENERATE_ABSTRACTIONS_MODEL) {
+ abstractionsModel = Utils.createModel(nameOfAbstractionsModel);
+ createAbstractionsModel(mapClassNodes);
+ abstractionsModel.setURI(NSURI_PREFIX + nameOfAbstractionsModel);
+ save(abstractionsModel, outputDirectoryPath, nameOfAbstractionsModel, UMLResource.FILE_EXTENSION);
+ }
+ // Debug=true will automatically refresh the project to show the
+ // generated ...profile.uml file.
+ if (!DEBUG) {
+ Utils.refreshProject(sourceModelFile);
+ }
+ }
+
+ /**
+ * Generates the mapping model between source elements and produced
+ * elements. Each abstraction relationship can have many sources and many
+ * targets which is ideal to allow N 2 M mappings.
+ *
+ * @param map
+ * containing the element (value) in the domain model that
+ * originated the element (key) in the profile
+ */
+ protected void createAbstractionsModel(Map<Element, Element> map) {
+ for (Map.Entry<Element, Element> entry : map.entrySet()) {
+ NamedElement key = (NamedElement) entry.getKey();
+ NamedElement value = (NamedElement) entry.getValue();
+ Abstraction _abstraction = UMLFactory.eINSTANCE.createAbstraction();
+ _abstraction.getSuppliers().add(key);
+ _abstraction.getClients().add(value);
+ _abstraction.setName(key.getName() + "-" + value.getName());
+ abstractionsModel.getPackagedElements().add(_abstraction);
+ }
+ }
+
+ protected void visitPackagedElements(Element element) {
+ if (element instanceof org.eclipse.uml2.uml.Package) {
+ org.eclipse.uml2.uml.Package packageInMetamodel = (org.eclipse.uml2.uml.Package) element;
+ for (Element e : packageInMetamodel.getPackagedElements()) {
+ visitPackagedElements(e);
+ }
+ } else if (element instanceof org.eclipse.uml2.uml.Class) {
+ mapClassNodes.put((Element) Utils.createStereotype(profile, ((NamedElement) element).getName(),
+ ((Class) element).isAbstract()), element);
+ if (((Classifier) element).getGeneralizations() != null) {
+ for (Generalization generalization : ((Classifier) element).getGeneralizations()) {
+ listInternalGeneralizations.add(generalization);
+ }
+ }
+ } else if (element instanceof PrimitiveType) {
+ mapPrimitiveTypesNodes.put((Element) Utils.createPrimitiveType(profile, ((NamedElement) element).getName()),
+ element);
+ } else if (element instanceof Enumeration) {
+ mapEnumerationsNodes.put((Element) Utils.createEnumeration(profile, ((NamedElement) element).getName()),
+ element);
+ } else if (element instanceof Association) {
+ if (FROM_ASSOCIATIONS_TO_STEREOTYPES) {
+ mapAssociationsEdges.put(
+ (Element) Utils.createStereotype(profile, ((NamedElement) element).getName(), false), element);
+ }
+ }
+ }
+
+ protected void createInternalGeneralizations() {
+ for (Generalization generalizationInMM : listInternalGeneralizations) {
+ Classifier specificInMM = generalizationInMM.getSpecific();
+ Classifier generalInMM = generalizationInMM.getGeneral();
+ Stereotype specificInProfile = null;
+ Stereotype generalInProfile = null;
+ Set<Element> classNodesStereotypesInProfile = mapClassNodes.keySet();
+ for (Element e : classNodesStereotypesInProfile) {
+ Stereotype classNodeStereotypeInProfile = (Stereotype) e;
+ if (classNodeStereotypeInProfile.getName().contentEquals(specificInMM.getName())) {
+ specificInProfile = classNodeStereotypeInProfile;
+ } else if (classNodeStereotypeInProfile.getName().contentEquals(generalInMM.getName())) {
+ generalInProfile = classNodeStereotypeInProfile;
+ }
+ }
+ if (specificInProfile != null && generalInProfile != null) {
+ Utils.createGeneralization(specificInProfile, generalInProfile);
+ }
+ }
+ }
+
+ protected static org.eclipse.uml2.uml.Package load(URI uri) {
+ org.eclipse.uml2.uml.Package package_ = null;
+ try {
+ // Load the requested resource
+ Resource resource = resourceSet.getResource(uri, true);
+ // Get the first (should be only) package from it
+ package_ = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(resource.getContents(),
+ UMLPackage.Literals.PACKAGE);
+ } catch (WrappedException we) {
+ System.err.println();
+ System.exit(1);
+ }
+ return package_;
+ }
+
+ public static PrimitiveType importPrimitiveType(org.eclipse.uml2.uml.Package package_, String name) {
+ org.eclipse.uml2.uml.Package umlLibrary = load(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI));
+ PrimitiveType primitiveType = (PrimitiveType) umlLibrary.getOwnedType(name);
+ package_.createElementImport(primitiveType);
+ return primitiveType;
+ }
+
+ protected static org.eclipse.uml2.uml.Class referenceMetaclass(Profile profile, String metaclassName) {
+ Model umlMetamodel = (Model) load(URI.createURI(UMLResource.UML_METAMODEL_URI));
+ // my hack
+ Class metaclass = null;
+ if (umlMetamodel.getOwnedType(metaclassName) instanceof Class) {
+ metaclass = (Class) umlMetamodel.getOwnedType(metaclassName);
+ if (metaclass != null) {
+ profile.createMetaclassReference(metaclass);
+ }
+ }
+ return metaclass;
+ }
+
+ /**
+ * @param stereotypeInProfile
+ * @param propertyInClass
+ */
+ protected void addEnumerationProperty(Stereotype stereotypeInProfile, Property propertyInClass) {
+ Set<Element> enumerationsInProfile = mapEnumerationsNodes.keySet();
+ for (Element e : enumerationsInProfile) {
+ Enumeration enumerationInProfile = (Enumeration) e;
+ if (enumerationInProfile.getName().contentEquals(propertyInClass.getType().getName())) {
+ Utils.createAttribute((Class) stereotypeInProfile, propertyInClass.getName(), enumerationInProfile, 0,
+ 1, null);
+ }
+ }
+ }
+
+ /**
+ * @param stereotypeInProfile
+ * @param propertyInClass
+ */
+ protected void addPrimitiveTypeProperty(Stereotype stereotypeInProfile, Property propertyInClass) {
+ boolean foundStandardPrimitiveType = false;
+ for (PrimitiveType standardPrimitiveType : listStandardPrimitiveTypes) {
+ if (standardPrimitiveType.getName().contentEquals(propertyInClass.getType().getName())) {
+ foundStandardPrimitiveType = true;
+
+ Utils.createAttribute((Class) stereotypeInProfile, propertyInClass.getName(), standardPrimitiveType,
+ propertyInClass.getLower(), propertyInClass.getUpper(), null);
+ break;
+ }
+ }
+ if (!foundStandardPrimitiveType) {
+ Set<Element> primitiveTypesInProfile = mapPrimitiveTypesNodes.keySet();
+ for (Element e : primitiveTypesInProfile) {
+ PrimitiveType primitiveTypeInProfile = (PrimitiveType) e;
+ if (primitiveTypeInProfile.getName().contentEquals(propertyInClass.getType().getName())) {
+ Utils.createAttribute((Class) stereotypeInProfile, propertyInClass.getName(),
+ primitiveTypeInProfile, propertyInClass.getLower(), propertyInClass.getUpper(), null);
+ }
+ }
+ }
+ }
+
+ protected void createEnumerationLiterals() {
+ for (Map.Entry<Element, Element> entry : mapEnumerationsNodes.entrySet()) {
+ Element key = entry.getKey();
+ Element value = entry.getValue();
+ if (key instanceof Enumeration && value instanceof Enumeration) {
+ Enumeration enumInProfile = (Enumeration) key;
+ Enumeration enumInMetamodel = (Enumeration) value;
+ for (EnumerationLiteral literalInMM : enumInMetamodel.getOwnedLiterals()) {
+ Utils.createEnumerationLiteral(enumInProfile, literalInMM.getName().replaceAll("\\s", ""));
+ }
+ }
+ }
+ }
+
+ protected void createGeneralizations(Set<Element> specificStereotypes, Stereotype generalStereotype) {
+ for (Element element : specificStereotypes) {
+ if (element instanceof Stereotype) {
+ Stereotype specificStereotype = (Stereotype) element;
+ if (specificStereotype.getGeneralizations().size() == 0) {
+ Utils.createGeneralization(specificStereotype, generalStereotype);
+ }
+ }
+ }
+ }
+
+ /**
+ * Creates a profile and sub-profiles based on the packages structure of the
+ * domain model. Each Package becomes a new profile.
+ *
+ * @param map
+ * in the map, the key is an Stereotype, PrimitiveType, Profile,
+ * etc. and the value is the Element that originated the creation
+ * of the key. For example, a Class X (the key) originated an
+ * Stereotype X (the value)
+ *
+ */
+ protected void createProfiles(Map<Element, Element> map) {
+ boolean foundPackage;
+ for (Map.Entry<Element, Element> entry : map.entrySet()) {
+ Element key = entry.getKey();
+ Element value = entry.getValue();
+ Package package_ = value.getNearestPackage();
+ foundPackage = false;
+ for (Package nestedPackage : profile.getNestedPackages()) {
+ if (nestedPackage.getName().contentEquals(package_.getName())) {
+ foundPackage = true;
+ nestedPackage.getPackagedElements().add((PackageableElement) key);
+ break;
+ }
+ }
+ if (!foundPackage) {
+ Profile newSubProfile = Utils.createProfile(package_.getName(), NSURI_PREFIX + package_.getName());
+ mapPackagesNodes.put(newSubProfile, package_);
+ profile.getNestedPackages().add(newSubProfile);
+ newSubProfile.getPackagedElements().add((PackageableElement) key);
+ }
+ }
+ }
+
+ protected void createStandardPrimitiveTypes(String[] requiredPrimitiveTypes) {
+ for (String primitiveTypeName : requiredPrimitiveTypes) {
+ listStandardPrimitiveTypes.add(importPrimitiveType(profile, primitiveTypeName));
+ }
+ }
+
+ protected void createTagDefinitions() {
+ for (Map.Entry<Element, Element> entry : mapClassNodes.entrySet()) {
+ Element key = entry.getKey();
+ Element value = entry.getValue();
+ if (key instanceof Stereotype && value instanceof Class) {
+ Stereotype stereotypeInProfile = (Stereotype) key;
+ Class classInMetamodel = (Class) value;
+ for (Property propertyInClass : classInMetamodel.getOwnedAttributes()) {
+ if (propertyInClass.getType() instanceof PrimitiveType) {
+ addPrimitiveTypeProperty(stereotypeInProfile, propertyInClass);
+ } else if (propertyInClass.getType() instanceof Enumeration) {
+ addEnumerationProperty(stereotypeInProfile, propertyInClass);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @return the profile
+ */
+ public Profile getProfile() {
+ return profile;
+ }
+
+ /**
+ * Save our refinement model to a file in the user-specified output
+ * directory
+ *
+ */
+ protected void save(Package model, String outputDirectoryPath, String fileName, String fileExtension) {
+ URI outputURI = URI.createFileURI(outputDirectoryPath).appendSegment(fileName)
+ .appendFileExtension(fileExtension);
+ save(model, outputURI);
+ }
+
+ protected static void save(org.eclipse.uml2.uml.Package package_, URI uri) {
+ Resource resource = resourceSet.createResource(uri);
+ resource.getContents().add(package_);
+ try {
+ resource.save(null);
+ } catch (IOException ioe) {
+ System.err.println(ioe.getMessage());
+ }
+ }
+
+ /**
+ * @param profile
+ * the profile to set
+ */
+ public void setProfile(Profile profile) {
+ this.profile = profile;
+ }
+}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/handler/CreateProfileFromDomainModelHandler.java b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/handler/CreateProfileFromDomainModelHandler.java
new file mode 100644
index 00000000000..8a78cd57db1
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/handler/CreateProfileFromDomainModelHandler.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ *
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.req.domainModel2Profile.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.req.domainModel2Profile.command.CreateProfileFromDomainModelCommand;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+
+/**
+ * Executes the generation of an UML profile based on a UML domain model
+ * according to the Papyrus Req Preferences
+ */
+public class CreateProfileFromDomainModelHandler extends PapyrusAbstractHandler {
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ super.execute(event);
+ Element selectedElement = getSelection();
+ if (selectedElement instanceof Package) {
+ CreateProfileFromDomainModelCommand createProfileFromDomainModelCommand = new CreateProfileFromDomainModelCommand(
+ transactionalEditingDomain, selectedElement);
+ transactionalEditingDomain.getCommandStack().execute(createProfileFromDomainModelCommand);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ *
+ * @return true if the handler is possible
+ */
+ @Override
+ public boolean isEnabled() {
+ Element selectedElement = getSelection();
+ if (selectedElement instanceof Package) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/handler/PapyrusAbstractHandler.java b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/handler/PapyrusAbstractHandler.java
new file mode 100644
index 00000000000..b2b91545aa8
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/handler/PapyrusAbstractHandler.java
@@ -0,0 +1,123 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+*******************************************************************************/
+package org.eclipse.papyrus.req.domainModel2Profile.handler;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForHandlers;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * Abstract handler in order to do the connection with Papyrus
+ *
+ */
+public abstract class PapyrusAbstractHandler extends AbstractHandler {
+
+ protected TransactionalEditingDomain transactionalEditingDomain=null;
+ protected IMultiDiagramEditor papyrusEditor;
+
+
+ /**
+ * install element of Papyrus in order to execute commands
+ * @param event the context of the execution
+ */
+ protected void setPapyrusEnvironment(ExecutionEvent event){
+ //look for papyrus
+ try {
+ papyrusEditor = ServiceUtilsForHandlers.getInstance().getService(IMultiDiagramEditor.class, event);
+ transactionalEditingDomain= ServiceUtilsForHandlers.getInstance().getService(org.eclipse.emf.transaction.TransactionalEditingDomain.class, event);
+
+ } catch (ServiceException ex) {
+ System.err.println(ex);
+ }
+ }
+ /**
+ * getSelected element in the diagram or in the model explorer
+ * @return Element or null
+ */
+ protected Element getSelection(){
+ org.eclipse.uml2.uml.Element selectedElement =null;
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ ISelection selection = selectionService.getSelection();
+ //look for papyrus
+ if(selection instanceof IStructuredSelection) {
+ Object selectedobject = ((IStructuredSelection)selection).getFirstElement();
+ if(selectedobject instanceof GraphicalEditPart) {
+ Object graphicalElement = ((GraphicalEditPart)selectedobject).getModel();
+ if((graphicalElement instanceof View) && ((View)graphicalElement).getElement() instanceof org.eclipse.uml2.uml.Element) {
+ selectedElement = (org.eclipse.uml2.uml.Element)((View)graphicalElement).getElement();
+ }
+ }
+ else if(selectedobject instanceof IAdaptable) {
+ EObject selectedEObject = (EObject)((IAdaptable)selectedobject).getAdapter(EObject.class);
+ if (selectedEObject instanceof org.eclipse.uml2.uml.Element){
+ selectedElement=(Element)selectedEObject;
+ }
+ }
+ }
+ return selectedElement;
+ }
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ setPapyrusEnvironment(event);
+ return null;
+ }
+ /**
+ * getSelected element in the diagram or in the model explorer
+ * @return Element or null
+ */
+ protected ArrayList<Element> getSelectionSet(){
+ ArrayList<Element> selectedSet =new ArrayList<Element>();
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ ISelection selection = selectionService.getSelection();
+
+
+ if(selection instanceof IStructuredSelection) {
+ @SuppressWarnings("rawtypes")
+ Iterator selectedobjectIteractor = ((IStructuredSelection)selection).iterator();
+ while (selectedobjectIteractor.hasNext()) {
+ Object currentSelection = selectedobjectIteractor.next();
+ if(currentSelection instanceof GraphicalEditPart) {
+ Object graphicalElement = ((GraphicalEditPart)currentSelection).getModel();
+ if((graphicalElement instanceof View) && ((View)graphicalElement).getElement() instanceof org.eclipse.uml2.uml.Element) {
+ selectedSet.add( (org.eclipse.uml2.uml.Element)((View)graphicalElement).getElement());
+ }
+ }
+ else if(currentSelection instanceof IAdaptable) {
+ EObject selectedEObject = (EObject)((IAdaptable)currentSelection).getAdapter(EObject.class);
+ if (selectedEObject instanceof org.eclipse.uml2.uml.Element){
+ selectedSet.add((Element)selectedEObject);
+ }
+ }
+ }
+
+
+ }
+ return selectedSet;
+ }
+}
+
diff --git a/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/utils/Utils.java b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/utils/Utils.java
new file mode 100644
index 00000000000..211b146d706
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.domainModel2Profile/src/org/eclipse/papyrus/req/domainModel2Profile/utils/Utils.java
@@ -0,0 +1,282 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ *
+ * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST - Initial API and implementation based on UML2 tutorials.
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.req.domainModel2Profile.utils;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.LiteralBoolean;
+import org.eclipse.uml2.uml.LiteralString;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Utility methods to create a profile
+ *
+ */
+public class Utils {
+ /**
+ * Creates a new UML model with a specific name
+ *
+ * @param name
+ * The name of the model
+ * @return the UML model
+ */
+ public static Model createModel(String name) {
+ Model model = UMLFactory.eINSTANCE.createModel();
+ model.setName(name);
+ return model;
+ }
+
+ /**
+ * Refresh the project that contains a file without user intervention (e.g.,
+ * by using the F5 key)
+ *
+ * @param file
+ * The file contained in the project to be refreshed
+ */
+ public static void refreshProject(File file) {
+ IProject iproject = ResourcesPlugin.getWorkspace().getRoot().getProject(file.getParentFile().getName());
+ try {
+ iproject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Creates an enumeration in a UML package
+ *
+ * @param package_
+ * The UML package that will owns the enumeration
+ * @param name
+ * The name of the enumeration contained in package_
+ * @return a new Enumeration
+ */
+ public static Enumeration createEnumeration(org.eclipse.uml2.uml.Package package_, String name) {
+ Enumeration enumeration = package_.createOwnedEnumeration(name);
+ return enumeration;
+ }
+
+ /**
+ * Creates an enumeration literal
+ *
+ * @param enumeration
+ * The enumeration that will own the literal
+ * @param name
+ * The name of the literal
+ * @return a new enumeration literal
+ */
+ public static EnumerationLiteral createEnumerationLiteral(Enumeration enumeration, String name) {
+ EnumerationLiteral enumerationLiteral = enumeration.createOwnedLiteral(name);
+ return enumerationLiteral;
+ }
+
+ /**
+ * Creates a extension of the specified metaclass with this stereotype.
+ *
+ * @param metaclass
+ * The UML metaclass that will be extended, for example Class or
+ * Association
+ * @param stereotype
+ * The stereotype that will extend the metaclass
+ * @param required
+ * Whether the new extension should be required
+ * @return the new extension
+ */
+ public static Extension createExtension(org.eclipse.uml2.uml.Class metaclass, Stereotype stereotype,
+ boolean required) {
+ Extension extension = stereotype.createExtension(metaclass, required);
+ return extension;
+ }
+
+ /**
+ * Creates a new {@link org.eclipse.uml2.uml.Generalization}, with the
+ * specified '<em><b>General</b></em>', and appends it to the
+ * '<em><b>Generalization</b></em>' containment reference list.
+ *
+ * @param specificClassifier
+ * The '<em><b>Specific</b></em>' for the new
+ * {@link org.eclipse.uml2.uml.Generalization}
+ * @param generalClassifier
+ * The '<em><b>General</b></em>' for the new
+ * {@link org.eclipse.uml2.uml.Generalization}
+ * @return the new generalization
+ */
+ public static Generalization createGeneralization(Classifier specificClassifier, Classifier generalClassifier) {
+ Generalization generalization = specificClassifier.createGeneralization(generalClassifier);
+ return generalization;
+ }
+
+ /**
+ * Creates a new UML package inside another package
+ *
+ * @param nestingPackage
+ * The package that will contain the new package
+ * @param name
+ * The name of the new package
+ * @return the new UML package
+ */
+ public static org.eclipse.uml2.uml.Package createPackage(org.eclipse.uml2.uml.Package nestingPackage, String name) {
+ org.eclipse.uml2.uml.Package package_ = nestingPackage.createNestedPackage(name);
+ return package_;
+ }
+
+ /**
+ * Creates a new primitive type inside a Package
+ *
+ * @param package_
+ * The name of the package
+ * @param name
+ * The name of the primitive type
+ * @return the primitive type
+ */
+ public static PrimitiveType createPrimitiveType(org.eclipse.uml2.uml.Package package_, String name) {
+ PrimitiveType primitiveType = package_.createOwnedPrimitiveType(name);
+ return primitiveType;
+ }
+
+ /**
+ * Creates a UML profile with a specific name and nsURI
+ *
+ * @param name
+ * The new of the new profile
+ * @param nsURI
+ * The nsURI of the new package
+ * @return the new UML profile
+ */
+ public static Profile createProfile(String name, String nsURI) {
+ Profile profile = UMLFactory.eINSTANCE.createProfile();
+ profile.setName(name);
+ profile.setURI(nsURI);
+ return profile;
+ }
+
+ /**
+ * Creates a new stereotype in a specific profile
+ *
+ * @param profile
+ * The profile that will contain the stereotype
+ * @param name
+ * The name of the stereotype
+ * @param isAbstract
+ * Whether the stereotype is abstract
+ * @return
+ */
+ public static Stereotype createStereotype(Profile profile, String name, boolean isAbstract) {
+ Stereotype stereotype = profile.createOwnedStereotype(name, isAbstract);
+ return stereotype;
+ }
+
+ /**
+ * Defines a profile
+ *
+ * @param profile
+ * the profile to be defined
+ */
+ public static void defineProfile(Profile profile) {
+ profile.define();
+ }
+
+ /**
+ * Applies a profile to a package
+ *
+ * @param package_
+ * The package where the profile will be applied
+ * @param profile
+ * The profile that will be applied to the package
+ */
+ protected static void applyProfile(org.eclipse.uml2.uml.Package package_, Profile profile) {
+ package_.applyProfile(profile);
+ }
+
+ /**
+ * Creates a property with the specified name, type, lower bound, upper
+ * bound and default value as an owned attribute of a class
+ *
+ * @param class_
+ * The class that will have the attribute
+ * @param name
+ * The name of the attribute
+ * @param type
+ * The type of the attribute
+ * @param lowerBound
+ * The lower bound for the new attribute
+ * @param upperBound
+ * The upper bound for the new attribute
+ * @param defaultValue
+ * The default value of the new attribute
+ * @return the new attribute
+ */
+ public static Property createAttribute(org.eclipse.uml2.uml.Class class_, String name, Type type, int lowerBound,
+ int upperBound, Object defaultValue) {
+ Property attribute = class_.createOwnedAttribute(name, type, lowerBound, upperBound);
+ if (defaultValue instanceof Boolean) {
+ LiteralBoolean literal = (LiteralBoolean) attribute.createDefaultValue(null, null,
+ UMLPackage.Literals.LITERAL_BOOLEAN);
+ literal.setValue(((Boolean) defaultValue).booleanValue());
+ } else if (defaultValue instanceof String) {
+ if (type instanceof Enumeration) {
+ InstanceValue value = (InstanceValue) attribute.createDefaultValue(null, null,
+ UMLPackage.Literals.INSTANCE_VALUE);
+ value.setInstance(((Enumeration) type).getOwnedLiteral((String) defaultValue));
+ } else {
+ LiteralString literal = (LiteralString) attribute.createDefaultValue(null, null,
+ UMLPackage.Literals.LITERAL_STRING);
+ literal.setValue((String) defaultValue);
+ }
+ }
+ return attribute;
+ }
+
+ /**
+ * Obtains a java.io.File in a workspace based on a URI
+ * @param uri The URI
+ * @return the file
+ */
+ public static File getFileFromURI(URI uri) {
+ if (uri != null) {
+ IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IPath path = new Path(uri.toPlatformString(true));
+ IFile file = myWorkspaceRoot.getFile(path);
+ if (file != null && file.getLocation() != null) {
+ File f = file.getLocation().toFile();
+ return f;
+ }
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/META-INF/MANIFEST.MF b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/META-INF/MANIFEST.MF
index 55597fec105..85aea43fb41 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/META-INF/MANIFEST.MF
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/META-INF/MANIFEST.MF
@@ -5,19 +5,19 @@ Bundle-SymbolicName: org.eclipse.papyrus.req.sysml.assistant;singleton:=true
Bundle-Version: 0.7.0.qualifier
Bundle-Activator: org.eclipse.papyrus.req.sysml.assistant.Activator
Bundle-Vendor: %Bundle-Vendor
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0",
- org.eclipse.uml2.uml;bundle-version="4.0.0",
+Require-Bundle: org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0",
org.eclipse.papyrus.req.sysml.preferences;bundle-version="0.1.0",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0";resolution:=optional,
org.eclipse.papyrus.infra.emf;bundle-version="0.10.0";resolution:=optional,
org.eclipse.papyrus.uml.tools;bundle-version="0.9.1";resolution:=optional,
org.eclipse.papyrus.infra.widgets;bundle-version="0.9.1";resolution:=optional,
org.eclipse.papyrus.infra.core;bundle-version="0.9.0";resolution:=optional,
- org.eclipse.papyrus.editor;bundle-version="0.9.0";resolution:=optional,
- org.eclipse.core.expressions;bundle-version="3.5.0"
+ org.eclipse.core.expressions;bundle-version="3.5.0",
+ org.eclipse.papyrus.req.domainModel2Profile;bundle-version="0.7.0",
+ org.eclipse.papyrus.uml.profile.drafter;bundle-version="1.2.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.papyrus.req.sysml.assistant
+Export-Package: org.eclipse.papyrus.req.sysml.assistant,
+ org.eclipse.papyrus.req.sysml.assistant.command,
+ org.eclipse.papyrus.req.sysml.assistant.handler,
+ org.eclipse.papyrus.req.sysml.assistant.testers
Bundle-Localization: plugin
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/images/Profile.gif b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/images/Profile.gif
new file mode 100644
index 00000000000..18eed1f5cb9
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/images/Profile.gif
Binary files differ
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.properties b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.properties
index fefb5730826..4a611ebf869 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.properties
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.properties
@@ -1,6 +1,8 @@
#Properties file for org.eclipse.papyrus.req.sysml.assistant
menu.label = Papyrus Req
-menu.tooltip = Papyrus Req
+menu.tooltip = Assistants to manage SysML requirements
+menu.label.0 = Tools to Define Requirements Profile
+menu.tooltip.0 = Tools to Define Requirements Language
command.label = Create New Requirement
command.tooltip = Create New Requirement
@@ -18,15 +20,21 @@ command.label.5 = Add Satisfy Link
command.tooltip.5 = Add Satisfy Link
command.label.6 = Add Verify Link
command.tooltip.6 = Add Verify Link
+command.label.7 = Define or Update Stereotype and Profile on Demand
+command.tooltip.7 = Define or Update Stereotype and Profile on Demand
+command.label.8 = Generate Profile from Domain Model
+command.tooltip.8 = Generates an initial profile from a domain model according to user-defined Papyrus Req preferences
command.name = Extract Comments Assistant
command.name.0 = InitDerivedRequirement Assistant
command.name.1 = Create Comments
-command.name.2 = Create new Papyrus SysML Requirement
+command.name.2 = Create New Papyrus SysML Requirement
command.name.3 = Add Derived Link
command.name.4 = Decompose Requirement
command.name.5 = Add Satisfy Link
command.name.6 = Add Verify Link
+command.name.7 = Generate Profile from a Domain Model
+command.name.8 = Define or Update Stereotypes
Bundle-Vendor = Eclipse Modeling Project
Bundle-Name = Papyrus Req SysML Assistant (Incubation) \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.xml b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.xml
index 9e92d9be140..1a482f562f5 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.xml
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/plugin.xml
@@ -62,7 +62,6 @@
<with
variable="selection">
<test
- forcePluginActivation="true"
property="org.eclipse.papyrus.req.sysml.assistant.requirement.isRequirementElement"
value="true">
</test>
@@ -80,7 +79,6 @@
<with
variable="selection">
<test
- forcePluginActivation="true"
property="org.eclipse.papyrus.req.sysml.assistant.requirement.isRequirementElement"
value="true">
</test>
@@ -98,7 +96,6 @@
<with
variable="selection">
<test
- forcePluginActivation="true"
property="org.eclipse.papyrus.req.sysml.assistant.requirement.isRequirementElement"
value="true">
</test>
@@ -116,7 +113,6 @@
<with
variable="selection">
<test
- forcePluginActivation="true"
property="org.eclipse.papyrus.req.sysml.assistant.requirement.isRequirementElement"
value="true">
</test>
@@ -134,7 +130,6 @@
<with
variable="selection">
<test
- forcePluginActivation="true"
property="org.eclipse.papyrus.req.sysml.assistant.requirement.isRequirementElement"
value="true">
</test>
@@ -170,13 +165,34 @@
<with
variable="selection">
<test
- forcePluginActivation="true"
property="org.eclipse.papyrus.req.sysml.assistant.requirement.isRequirementElement"
value="true">
</test>
</with>
</visibleWhen>
</command>
+ <menu
+ icon="images/Profile.gif"
+ id="org.eclipse.papyrus.req.sysml.defineReqLang.menu"
+ label="%menu.label.0"
+ tooltip="%menu.tooltip.0">
+ </menu>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.req.sysml.defineReqLang.menu">
+ <command
+ commandId="org.eclipse.papyrus.req.sysml.assistant.handler.InitDefineRequirementsLanguageHandler"
+ label="%command.label.7"
+ style="push"
+ tooltip="%command.tooltip.7">
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.req.sysml.assistant.handler.InitCreateInitialProfileFromDomainModelHandler"
+ label="%command.label.8"
+ style="push"
+ tooltip="%command.tooltip.8">
+ </command>
</menuContribution>
</extension>
<extension
@@ -229,6 +245,18 @@
id="org.eclipse.papyrus.req.sysml.assistant.handler.AddVerifyLinkHandler"
name="%command.name.6">
</command>
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.req.sysml.assistant.handler.InitCreateInitialProfileFromDomainModelHandler"
+ id="org.eclipse.papyrus.req.sysml.assistant.handler.InitCreateInitialProfileFromDomainModelHandler"
+ name="%command.name.7">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.uml.profile.drafter.ui.handler.UpdateProfileHandler"
+ id="org.eclipse.papyrus.req.sysml.assistant.handler.InitDefineRequirementsLanguageHandler"
+ name="%command.name.8">
+ </command>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
@@ -246,6 +274,13 @@
properties="isUMLPackage"
type="org.eclipse.jface.viewers.IStructuredSelection">
</propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.req.sysml.assistant.testers.ProfileTester"
+ id="org.eclipse.papyrus.req.sysml.assistant.profileElement"
+ namespace="org.eclipse.papyrus.req.sysml.assistant.profileElement"
+ properties="isUMLProfile"
+ type="org.eclipse.jface.viewers.IStructuredSelection">
+ </propertyTester>
</extension>
</plugin>
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/I_SysMLStereotype.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/I_SysMLStereotype.java
index 3b04feff829..4996b3bbd01 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/I_SysMLStereotype.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/I_SysMLStereotype.java
@@ -13,7 +13,7 @@
package org.eclipse.papyrus.req.sysml.assistant;
/**
- * list of constant for SysML
+ * list of constants for SysML
*
*/
public interface I_SysMLStereotype {
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddDerivedLinkReqCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddDerivedLinkReqCommand.java
index 75e485a7967..356396fb1d1 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddDerivedLinkReqCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddDerivedLinkReqCommand.java
@@ -28,7 +28,7 @@ import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLPackage;
/**
*
- * This class creates a set of DerivedReq links
+ * Creates a set of DerivedReq links
*/
public class AddDerivedLinkReqCommand extends RecordingCommand {
protected Element selectedElement;
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddSatisfyLinkCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddSatisfyLinkCommand.java
index 349402a1048..854db174a41 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddSatisfyLinkCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddSatisfyLinkCommand.java
@@ -28,7 +28,7 @@ import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.UMLPackage;
/**
*
- * This class creates a set of Satisfy links
+ * Creates a set of Satisfy links
*/
public class AddSatisfyLinkCommand extends RecordingCommand {
protected Element selectedElement;
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddVerifyLinkCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddVerifyLinkCommand.java
index 81212472958..49dfbc989c8 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddVerifyLinkCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/AddVerifyLinkCommand.java
@@ -28,7 +28,7 @@ import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.UMLPackage;
/**
*
- * This class creates a set of Verify links
+ * Creates a set of Verify links
*/
public class AddVerifyLinkCommand extends RecordingCommand {
protected Element selectedElement;
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/CommentReqCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/CommentReqCommand.java
index d55f878eee1..72760303a8a 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/CommentReqCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/CommentReqCommand.java
@@ -21,7 +21,7 @@ import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Element;
/**
*
- * parse the text of the requirement and move some parts as comment
+ * Parses the text of the requirement and move some parts as comment
*
*/
public class CommentReqCommand extends RecordingCommand {
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DecomposeReqCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DecomposeReqCommand.java
index 91d83df1343..11eb366a336 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DecomposeReqCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DecomposeReqCommand.java
@@ -18,7 +18,7 @@ import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
/**
- * this command is used to create a "decompose" link between requirements
+ * This class creates a "Decompose" link between requirements
*
*/
public class DecomposeReqCommand extends RecordingCommand {
@@ -36,7 +36,8 @@ public class DecomposeReqCommand extends RecordingCommand {
* element that will nest the child
*
*/
- public DecomposeReqCommand(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Class child, org.eclipse.uml2.uml.Class parent) {
+ public DecomposeReqCommand(TransactionalEditingDomain domain, org.eclipse.uml2.uml.Class child,
+ org.eclipse.uml2.uml.Class parent) {
super(domain, "Create a Decompositon");
this.parent = parent;
this.child = child;
@@ -44,7 +45,7 @@ public class DecomposeReqCommand extends RecordingCommand {
@Override
protected void doExecute() {
- parent.getNestedClassifiers().add(child);
- }
+ parent.getNestedClassifiers().add(child);
+ }
}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DerivationReqCreateCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DerivationReqCreateCommand.java
index d26804a7c1e..040e1d8fc19 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DerivationReqCreateCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/DerivationReqCreateCommand.java
@@ -23,7 +23,7 @@ import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
/**
- * this command is used to create a "DerivedReq" link between requirements
+ * Creates a "DerivedReq" link between requirements
*
*/
public class DerivationReqCreateCommand extends RecordingCommand {
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/ExtractCommentCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/ExtractCommentCommand.java
index ba6bf708b53..970fbcc626d 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/ExtractCommentCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/ExtractCommentCommand.java
@@ -24,7 +24,7 @@ import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
/**
*
- * parse the text of the requirement and move some parts as comment
+ * Parses the text of the requirement and move some parts as comments
*
*/
public class ExtractCommentCommand extends RecordingCommand {
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitCreateProfileFromDomainModelCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitCreateProfileFromDomainModelCommand.java
new file mode 100644
index 00000000000..666fa0b597d
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitCreateProfileFromDomainModelCommand.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.req.sysml.assistant.command;
+
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
+import org.eclipse.papyrus.req.domainModel2Profile.command.CreateProfileFromDomainModelCommand;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.swt.widgets.Display;
+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.UMLPackage;
+
+/**
+ * Executes the generation of a profile based on a class diagram according to
+ * the preferences page of Papyrus Req
+ *
+ */
+public class InitCreateProfileFromDomainModelCommand extends RecordingCommand {
+ protected Element selectedElement;
+ TransactionalEditingDomain domain;
+
+ public InitCreateProfileFromDomainModelCommand(TransactionalEditingDomain domain, Element selectedElement) {
+ super(domain, "InitCreateProfileFromDomainModelCommand");
+ this.selectedElement = selectedElement;
+ this.domain = domain;
+ }
+
+ @Override
+ protected void doExecute() {
+ org.eclipse.uml2.uml.Package sourcePackage = null;
+ if (selectedElement instanceof Model){ //&& !(selectedElement instanceof Profile)) {
+ org.eclipse.uml2.uml.Package _package = (Package) selectedElement;
+ TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell());
+ dialog.setContentProvider(
+ new UMLContentProvider(_package, UMLPackage.eINSTANCE.getPackage_NestedPackage()));
+ dialog.setLabelProvider(new UMLLabelProvider());
+ dialog.setMessage("Choose the domain model");
+ dialog.setTitle("Choose the domain model");
+ dialog.create();
+ dialog.setDescription("Choose the domain model");
+ if (dialog.open() == org.eclipse.jface.window.Window.OK) {
+ Object[] result = dialog.getResult();
+ sourcePackage = ((org.eclipse.uml2.uml.Package) result[0]);
+ } else
+ return;
+ CreateProfileFromDomainModelCommand createProfileFromDomainModelCommand = new CreateProfileFromDomainModelCommand(
+ domain, sourcePackage);
+ createProfileFromDomainModelCommand.execute();
+ }
+ }
+} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDecomposeReqCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDecomposeReqCommand.java
index 89b557388f6..57b75a50b91 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDecomposeReqCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDecomposeReqCommand.java
@@ -29,13 +29,11 @@ import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
/**
- *
- * This command is used to create a requirement and add a decomposition link from
- * the selected requirement to the new requirement. The names are based on the
- * Papyrus Req preferences
+ * Creates a requirement and adds a decomposition link from the selected
+ * requirement to the new requirement. The names are based on the Papyrus Req
+ * preferences.
*
*/
-
public class InitDecomposeReqCommand extends RecordingCommand {
protected Element selectedElement;
TransactionalEditingDomain domain;
@@ -68,19 +66,27 @@ public class InitDecomposeReqCommand extends RecordingCommand {
}
/**
- * get a new name of a Papyrus SysML child requirement based on the Papyrus req preferences and the Id of the parent Requirement
+ * get a new name of a Papyrus SysML child requirement based on the Papyrus
+ * req preferences and the Id of the parent Requirement
*
- * @param parent the parent requirement
+ * @param parent
+ * the parent requirement
* @return the name for a potential requirement
*/
public static String getNewIDReq(org.eclipse.uml2.uml.Class parent, Stereotype stereotype) {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String prefix = store.getString(PreferenceConstants.REQUIREMENT_ID_PREFIX);//by default "REQ_"
- String separator = store.getString(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR); //by default "_"
-
+ String prefix = store.getString(PreferenceConstants.REQUIREMENT_ID_PREFIX);// by
+ // default
+ // "REQ_"
+ String separator = store.getString(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR); // by
+ // default
+ // "_"
+
String parentRequirementId = (String) parent.getValue(stereotype, I_SysMLStereotype.REQUIREMENT_ID_ATT);
String parentRequirementIdSuffix = parentRequirementId.replaceAll(prefix, "");
- int digit = store.getInt(PreferenceConstants.REQUIREMENT_ID_DIGIT);//by default 3
+ int digit = store.getInt(PreferenceConstants.REQUIREMENT_ID_DIGIT);// by
+ // default
+ // 3
int i = 0;
DecimalFormat df = new DecimalFormat();
df.setMinimumIntegerDigits(digit);
@@ -99,9 +105,7 @@ public class InitDecomposeReqCommand extends RecordingCommand {
if (classifier.getValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_ID_ATT) != null) {
String existedID = (String) classifier.getValue(reqStereotype,
I_SysMLStereotype.REQUIREMENT_ID_ATT);
- String newID = prefix
- + parentRequirementIdSuffix
- + separator + value;
+ String newID = prefix + parentRequirementIdSuffix + separator + value;
// id already exists so increment suffix
if (newID.equals(existedID)) {
IDexist = true;
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDefineDomainSpecificRequirementsConceptsCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDefineDomainSpecificRequirementsConceptsCommand.java
new file mode 100644
index 00000000000..0c1c4c3fdb5
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDefineDomainSpecificRequirementsConceptsCommand.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.req.sysml.assistant.command;
+
+import java.util.List;
+
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
+import org.eclipse.papyrus.req.domainModel2Profile.command.CreateProfileFromDomainModelCommand;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Executes the wizard to create specializations of SysML
+ *
+ */
+public class InitDefineDomainSpecificRequirementsConceptsCommand extends RecordingCommand {
+ protected Element selectedElement;
+ TransactionalEditingDomain domain;
+
+ public InitDefineDomainSpecificRequirementsConceptsCommand(TransactionalEditingDomain domain, Element selectedElement) {
+ super(domain, "InitDefineDomainSpecificRequirementsConceptsCommand");
+ this.selectedElement = selectedElement;
+ this.domain = domain;
+ }
+
+ @Override
+ protected void doExecute() {
+ org.eclipse.uml2.uml.Package sourcePackage = null;
+ if (selectedElement instanceof Package) {
+ org.eclipse.uml2.uml.Package _package = (Package) selectedElement;
+
+ TreeSelectorDialog dialog = new TreeSelectorDialog(Display.getDefault().getActiveShell());
+ dialog.setContentProvider(
+ new UMLContentProvider(_package, UMLPackage.eINSTANCE.getPackage_NestedPackage()));
+ dialog.setLabelProvider(new UMLLabelProvider());
+ dialog.setMessage("Choose the source model");
+ dialog.setTitle("Choose the source model");
+ dialog.create();
+ dialog.setDescription("Choose the source model");
+ if (dialog.open() == org.eclipse.jface.window.Window.OK) {
+ Object[] result = dialog.getResult();
+ sourcePackage = ((org.eclipse.uml2.uml.Package) result[0]);
+ } else
+ return;
+ CreateProfileFromDomainModelCommand createProfileFromDomainModelCommand = new CreateProfileFromDomainModelCommand(
+ domain, sourcePackage);
+ createProfileFromDomainModelCommand.execute();
+
+ }
+ }
+} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDerivedReqCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDerivedReqCommand.java
index 1fa46957069..21c707f2ea5 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDerivedReqCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/InitDerivedReqCommand.java
@@ -30,7 +30,7 @@ import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLPackage;
/**
*
- *create a derived requirement from a set of requirement with concatened text
+ * Creates a derived requirement from a set of requirements with concatened text
*
*/
public class InitDerivedReqCommand extends RecordingCommand {
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/PapyrusReqSysMLRequirementCreateCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/PapyrusReqSysMLRequirementCreateCommand.java
index b66c2917311..ab1b25a96f5 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/PapyrusReqSysMLRequirementCreateCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/PapyrusReqSysMLRequirementCreateCommand.java
@@ -26,24 +26,24 @@ import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.PackageableElement;
import org.eclipse.uml2.uml.Stereotype;
+
/**
- *
- * parse the text of the requirement and move some parts as comment
+ * Creates a new SysML requirements based on the Papyrus Req preferences page.
*
*/
-
public class PapyrusReqSysMLRequirementCreateCommand extends RecordingCommand {
protected Element selectedElement;
+
public PapyrusReqSysMLRequirementCreateCommand(TransactionalEditingDomain domain, Element selectedElements) {
- super(domain,"PapyrusReqSysMLRequirementCreateCommand" );
- this.selectedElement=selectedElements;
+ super(domain, "PapyrusReqSysMLRequirementCreateCommand");
+ this.selectedElement = selectedElements;
}
- protected void createRequirement(org.eclipse.uml2.uml.Package owner,String text){
- org.eclipse.uml2.uml.Class requirement=owner.createOwnedClass("tmpName", false);
- Stereotype reqStereotype=requirement.getApplicableStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
+ protected void createRequirement(org.eclipse.uml2.uml.Package owner, String text) {
+ org.eclipse.uml2.uml.Class requirement = owner.createOwnedClass("tmpName", false);
+ Stereotype reqStereotype = requirement.getApplicableStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
requirement.applyStereotype(reqStereotype);
- String id= getNewIDReq(owner);
+ String id = getNewIDReq(owner);
requirement.setName(id);
requirement.setValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_ID_ATT, id);
@@ -51,53 +51,56 @@ public class PapyrusReqSysMLRequirementCreateCommand extends RecordingCommand {
/**
* get new name of Papyrus SysML requirement
- * @param owner the package that will contain requirement
+ *
+ * @param owner
+ * the package that will contain requirement
* @return the name for a potential requirement
*/
- public static String getNewIDReq(org.eclipse.uml2.uml.Package owner){
+ public static String getNewIDReq(org.eclipse.uml2.uml.Package owner) {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String prefix=store.getString(PreferenceConstants.REQUIREMENT_ID_PREFIX);
- int digit=store.getInt(PreferenceConstants.REQUIREMENT_ID_DIGIT);
- int i=0;
+ String prefix = store.getString(PreferenceConstants.REQUIREMENT_ID_PREFIX);
+ int digit = store.getInt(PreferenceConstants.REQUIREMENT_ID_DIGIT);
+ int i = 0;
DecimalFormat df = new DecimalFormat();
- //create suffix
+ // create suffix
df.setMinimumIntegerDigits(digit);
- String value= (df.format(i));
- //got through all elements
- boolean IDexist=true;
- while (IDexist){
- IDexist=false;
+ String value = (df.format(i));
+ // got through all elements
+ boolean IDexist = true;
+ while (IDexist) {
+ IDexist = false;
i++;
- value= (df.format(i));
- EList<PackageableElement> packelements=owner.getPackagedElements();
- for(Iterator<PackageableElement> iterator = packelements.iterator(); iterator.hasNext()&&(!IDexist);) {
- PackageableElement packageableElement = (PackageableElement)iterator.next();
- //current element is a Req?
- Stereotype reqStereotype=packageableElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
-
+ value = (df.format(i));
+ EList<PackageableElement> packelements = owner.getPackagedElements();
+ for (Iterator<PackageableElement> iterator = packelements.iterator(); iterator.hasNext() && (!IDexist);) {
+ PackageableElement packageableElement = (PackageableElement) iterator.next();
+ // current element is a Req?
+ Stereotype reqStereotype = packageableElement
+ .getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
- if( reqStereotype!=null){
- if(packageableElement.getValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_ID_ATT)!=null){
- String existedID=(String)packageableElement.getValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_ID_ATT);
- String newID= prefix+value;
- //id already exist so increment suffix
- if( newID.equals(existedID)){
- IDexist=true;
+ if (reqStereotype != null) {
+ if (packageableElement.getValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_ID_ATT) != null) {
+ String existedID = (String) packageableElement.getValue(reqStereotype,
+ I_SysMLStereotype.REQUIREMENT_ID_ATT);
+ String newID = prefix + value;
+ // id already exist so increment suffix
+ if (newID.equals(existedID)) {
+ IDexist = true;
}
}
}
}
}
- return prefix+value;
+ return prefix + value;
}
@Override
protected void doExecute() {
- if( selectedElement instanceof Package){
- createRequirement((Package)selectedElement, "");
+ if (selectedElement instanceof Package) {
+ createRequirement((Package) selectedElement, "");
}
}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/SatisfyCreateCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/SatisfyCreateCommand.java
index 21f2b780559..a92c9182569 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/SatisfyCreateCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/SatisfyCreateCommand.java
@@ -22,35 +22,39 @@ import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
-
/**
- * This command is used to create a "Satisfy" link between a requirement and a namedElement
+ * Creates a "Satisfy" link between a requirement and a namedElement
*
*/
public class SatisfyCreateCommand extends RecordingCommand {
private NamedElement source;
private NamedElement target;
- /**
- * use to make an abstraction
- * @param domain the domain to execute a transaction
- * @param source the source of the abstraction (the more concrete element)
- * @param target the target of the abstraction (the more abstract element)
+ /**
+ * use to make an abstraction
+ *
+ * @param domain
+ * the domain to execute a transaction
+ * @param source
+ * the source of the abstraction (the more concrete element)
+ * @param target
+ * the target of the abstraction (the more abstract element)
+ *
*/
- public SatisfyCreateCommand(TransactionalEditingDomain domain, NamedElement source, NamedElement target){
- super(domain,"Create an Abstraction");
- this.source=source;
- this.target=target;
+ public SatisfyCreateCommand(TransactionalEditingDomain domain, NamedElement source, NamedElement target) {
+ super(domain, "Create an Abstraction");
+ this.source = source;
+ this.target = target;
}
@Override
protected void doExecute() {
- Abstraction theAbstraction= UMLFactory.eINSTANCE.createAbstraction();
+ Abstraction theAbstraction = UMLFactory.eINSTANCE.createAbstraction();
source.getNearestPackage().getPackagedElements().add(theAbstraction);
theAbstraction.getSuppliers().add(target);
theAbstraction.getClients().add(source);
- theAbstraction.setName("Satisfies_"+this.target.getName());
- Stereotype satisfyStereotype= theAbstraction.getApplicableStereotype(I_SysMLStereotype.SATISFY_STEREOTYPE);
+ theAbstraction.setName("Satisfies_" + this.target.getName());
+ Stereotype satisfyStereotype = theAbstraction.getApplicableStereotype(I_SysMLStereotype.SATISFY_STEREOTYPE);
theAbstraction.applyStereotype(satisfyStereotype);
}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/VerifyCreateCommand.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/VerifyCreateCommand.java
index 562ee5bce05..121f457331f 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/VerifyCreateCommand.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/command/VerifyCreateCommand.java
@@ -22,35 +22,39 @@ import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
-
/**
- * This command is used to create a "Verify" link between a requirement and a namedElement
+ * Creates a "Verify" link between a requirement and a namedElement
*
*/
public class VerifyCreateCommand extends RecordingCommand {
private NamedElement source;
private NamedElement target;
- /**
- * use to make an abstraction
- * @param domain the domain to execute a transaction
- * @param source the source of the abstraction (the more concrete element)
- * @param target the target of the abstraction (the more abstract element)
+ /**
+ * use to make an abstraction
+ *
+ * @param domain
+ * the domain to execute a transaction
+ * @param source
+ * the source of the abstraction (the more concrete element)
+ * @param target
+ * the target of the abstraction (the more abstract element)
+ *
*/
- public VerifyCreateCommand(TransactionalEditingDomain domain, NamedElement source, NamedElement target){
- super(domain,"Create an Abstraction");
- this.source=source;
- this.target=target;
+ public VerifyCreateCommand(TransactionalEditingDomain domain, NamedElement source, NamedElement target) {
+ super(domain, "Create an Abstraction");
+ this.source = source;
+ this.target = target;
}
@Override
protected void doExecute() {
- Abstraction theAbstraction= UMLFactory.eINSTANCE.createAbstraction();
+ Abstraction theAbstraction = UMLFactory.eINSTANCE.createAbstraction();
source.getNearestPackage().getPackagedElements().add(theAbstraction);
theAbstraction.getSuppliers().add(target);
theAbstraction.getClients().add(source);
- theAbstraction.setName("Verifies_"+this.target.getName());
- Stereotype verifyStereotype= theAbstraction.getApplicableStereotype(I_SysMLStereotype.VERIFY_STEREOTYPE);
+ theAbstraction.setName("Verifies_" + this.target.getName());
+ Stereotype verifyStereotype = theAbstraction.getApplicableStereotype(I_SysMLStereotype.VERIFY_STEREOTYPE);
theAbstraction.applyStereotype(verifyStereotype);
}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddDerivedLinkReqHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddDerivedLinkReqHandler.java
index db459ccb923..d9b39f70cec 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddDerivedLinkReqHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddDerivedLinkReqHandler.java
@@ -22,25 +22,25 @@ import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
/**
- * this class execute a derived link
+ * Executes the addition of DerivedReqt links
+ *
*/
-
-public class AddDerivedLinkReqHandler extends PapyrusReqSysMLAbstractHandler {
-
-
+public class AddDerivedLinkReqHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
- ArrayList<Element> selectedElements=getSelectionSet();
- if( selectedElements.size()==2){
- DerivationReqCreateCommand addDerivedLinkReqCommand= new DerivationReqCreateCommand(transactionalEditingDomain,(NamedElement)selectedElements.get(1),(NamedElement) selectedElements.get(0));
+ ArrayList<Element> selectedElements = getSelectionSet();
+ if (selectedElements.size() == 2) {
+ DerivationReqCreateCommand addDerivedLinkReqCommand = new DerivationReqCreateCommand(
+ transactionalEditingDomain, (NamedElement) selectedElements.get(1),
+ (NamedElement) selectedElements.get(0));
transactionalEditingDomain.getCommandStack().execute(addDerivedLinkReqCommand);
- }
- else{
+ } else {
- Element selectedElement=getSelection();
- if( selectedElement!=null){
- AddDerivedLinkReqCommand addDerivedLinkReqCommand= new AddDerivedLinkReqCommand(transactionalEditingDomain,selectedElement);
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ AddDerivedLinkReqCommand addDerivedLinkReqCommand = new AddDerivedLinkReqCommand(
+ transactionalEditingDomain, selectedElement);
transactionalEditingDomain.getCommandStack().execute(addDerivedLinkReqCommand);
}
}
@@ -55,12 +55,12 @@ public class AddDerivedLinkReqHandler extends PapyrusReqSysMLAbstractHandler {
*/
@Override
public boolean isEnabled() {
- Element selectedElement=getSelection();
- if( selectedElement!=null){
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
return true;
+ } else {
+ return false;
}
- else{ return false;}
}
-
} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddSatisfyLinkHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddSatisfyLinkHandler.java
index b6ffdd007a9..52d9d6140cb 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddSatisfyLinkHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddSatisfyLinkHandler.java
@@ -22,25 +22,24 @@ import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
/**
- * This class executes Satisfy link
+ * Executes the addition of Satisfy links
+ *
*/
-
-public class AddSatisfyLinkHandler extends PapyrusReqSysMLAbstractHandler {
-
-
+public class AddSatisfyLinkHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
- ArrayList<Element> selectedElements=getSelectionSet();
- if( selectedElements.size()==2){
- SatisfyCreateCommand addSatisfyCreateCommand= new SatisfyCreateCommand(transactionalEditingDomain,(NamedElement)selectedElements.get(1),(NamedElement) selectedElements.get(0));
+ ArrayList<Element> selectedElements = getSelectionSet();
+ if (selectedElements.size() == 2) {
+ SatisfyCreateCommand addSatisfyCreateCommand = new SatisfyCreateCommand(transactionalEditingDomain,
+ (NamedElement) selectedElements.get(1), (NamedElement) selectedElements.get(0));
transactionalEditingDomain.getCommandStack().execute(addSatisfyCreateCommand);
- }
- else{
+ } else {
- Element selectedElement=getSelection();
- if( selectedElement!=null){
- AddSatisfyLinkCommand addAddSatisfyLinkCommand= new AddSatisfyLinkCommand(transactionalEditingDomain,selectedElement);
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ AddSatisfyLinkCommand addAddSatisfyLinkCommand = new AddSatisfyLinkCommand(transactionalEditingDomain,
+ selectedElement);
transactionalEditingDomain.getCommandStack().execute(addAddSatisfyLinkCommand);
}
}
@@ -55,12 +54,12 @@ public class AddSatisfyLinkHandler extends PapyrusReqSysMLAbstractHandler {
*/
@Override
public boolean isEnabled() {
- Element selectedElement=getSelection();
- if( selectedElement!=null){
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
return true;
+ } else {
+ return false;
}
- else{ return false;}
}
-
} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddVerifyLinkHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddVerifyLinkHandler.java
index 9255119da9f..e365d0726af 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddVerifyLinkHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/AddVerifyLinkHandler.java
@@ -22,25 +22,24 @@ import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
/**
- * This class executes Verify link
+ * Executes the addition of Verify links
+ *
*/
-
-public class AddVerifyLinkHandler extends PapyrusReqSysMLAbstractHandler {
-
-
+public class AddVerifyLinkHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
- ArrayList<Element> selectedElements=getSelectionSet();
- if( selectedElements.size()==2){
- VerifyCreateCommand addVerifyCreateCommand= new VerifyCreateCommand(transactionalEditingDomain,(NamedElement)selectedElements.get(1),(NamedElement) selectedElements.get(0));
+ ArrayList<Element> selectedElements = getSelectionSet();
+ if (selectedElements.size() == 2) {
+ VerifyCreateCommand addVerifyCreateCommand = new VerifyCreateCommand(transactionalEditingDomain,
+ (NamedElement) selectedElements.get(1), (NamedElement) selectedElements.get(0));
transactionalEditingDomain.getCommandStack().execute(addVerifyCreateCommand);
- }
- else{
+ } else {
- Element selectedElement=getSelection();
- if( selectedElement!=null){
- AddVerifyLinkCommand addAddVerifyLinkCommand= new AddVerifyLinkCommand(transactionalEditingDomain,selectedElement);
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ AddVerifyLinkCommand addAddVerifyLinkCommand = new AddVerifyLinkCommand(transactionalEditingDomain,
+ selectedElement);
transactionalEditingDomain.getCommandStack().execute(addAddVerifyLinkCommand);
}
}
@@ -55,12 +54,12 @@ public class AddVerifyLinkHandler extends PapyrusReqSysMLAbstractHandler {
*/
@Override
public boolean isEnabled() {
- Element selectedElement=getSelection();
- if( selectedElement!=null){
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
return true;
+ } else {
+ return false;
}
- else{ return false;}
}
-
} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/CommentReqHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/CommentReqHandler.java
index 563edcbc6e0..3e387a2560e 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/CommentReqHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/CommentReqHandler.java
@@ -20,23 +20,21 @@ import org.eclipse.papyrus.req.sysml.assistant.command.CommentReqCommand;
import org.eclipse.uml2.uml.Element;
/**
- * this class create a comment with the annotated element filled
+ * Executes the creation of a comment with the annotated element filled
+ *
*/
-
-public class CommentReqHandler extends PapyrusReqSysMLAbstractHandler {
-
-
+public class CommentReqHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
- ArrayList<Element> selectedElement=getSelectionSet();
- if( selectedElement.size()!=0){
- CommentReqCommand commentReqCommand= new CommentReqCommand(transactionalEditingDomain,selectedElement);
+ ArrayList<Element> selectedElement = getSelectionSet();
+ if (selectedElement.size() != 0) {
+ CommentReqCommand commentReqCommand = new CommentReqCommand(transactionalEditingDomain, selectedElement);
transactionalEditingDomain.getCommandStack().execute(commentReqCommand);
}
return null;
}
-
+
/**
*
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
@@ -45,12 +43,12 @@ public class CommentReqHandler extends PapyrusReqSysMLAbstractHandler {
*/
@Override
public boolean isEnabled() {
- ArrayList<Element> selectedElement=getSelectionSet();
- if( selectedElement.size()!=0){
+ ArrayList<Element> selectedElement = getSelectionSet();
+ if (selectedElement.size() != 0) {
return true;
+ } else {
+ return false;
}
- else{ return false;}
}
-
} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/DecomposeReqHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/DecomposeReqHandler.java
index de1cb3d187c..44f98342034 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/DecomposeReqHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/DecomposeReqHandler.java
@@ -8,8 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST. - initial API and implementation
- *
+ * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST. - initial API and implementation
*******************************************************************************/
package org.eclipse.papyrus.req.sysml.assistant.handler;
@@ -19,10 +18,12 @@ import org.eclipse.papyrus.req.sysml.assistant.command.InitDecomposeReqCommand;
import org.eclipse.uml2.uml.Element;
/**
- * is used to create a "decompose" link between requirements
+ * Executes the decomposition of a parent requirement to create a new child
+ * requirement with a name based on its ancestors as defined in the Papyrus Req
+ * preferences page.
+ *
*/
-
-public class DecomposeReqHandler extends PapyrusReqSysMLAbstractHandler {
+public class DecomposeReqHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/ExtractCommentsHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/ExtractCommentsHandler.java
index 0cadd1d1856..71c12a13957 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/ExtractCommentsHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/ExtractCommentsHandler.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (patrick.tessier@cea.fr) CEA LIST. - initial API and implementation
+ *
*******************************************************************************/
package org.eclipse.papyrus.req.sysml.assistant.handler;
@@ -20,23 +21,22 @@ import org.eclipse.papyrus.req.sysml.assistant.command.ExtractCommentCommand;
import org.eclipse.uml2.uml.Element;
/**
- * this class execute parses of comment
+ * Executes the parsing of a requirement to extract comments
*/
-public class ExtractCommentsHandler extends PapyrusReqSysMLAbstractHandler {
-
-
+public class ExtractCommentsHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
- ArrayList<Element> selectedElement=getSelectionSet();
- if( selectedElement.size()!=0){
- ExtractCommentCommand extractCommentCommand= new ExtractCommentCommand(transactionalEditingDomain,selectedElement);
+ ArrayList<Element> selectedElement = getSelectionSet();
+ if (selectedElement.size() != 0) {
+ ExtractCommentCommand extractCommentCommand = new ExtractCommentCommand(transactionalEditingDomain,
+ selectedElement);
transactionalEditingDomain.getCommandStack().execute(extractCommentCommand);
}
return null;
}
-
+
/**
*
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
@@ -45,12 +45,12 @@ public class ExtractCommentsHandler extends PapyrusReqSysMLAbstractHandler {
*/
@Override
public boolean isEnabled() {
- ArrayList<Element> selectedElement=getSelectionSet();
- if( selectedElement.size()!=0){
+ ArrayList<Element> selectedElement = getSelectionSet();
+ if (selectedElement.size() != 0) {
return true;
+ } else {
+ return false;
}
- else{ return false;}
}
-
} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitCreateInitialProfileFromDomainModelHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitCreateInitialProfileFromDomainModelHandler.java
new file mode 100644
index 00000000000..874d3c0dbf3
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitCreateInitialProfileFromDomainModelHandler.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.req.sysml.assistant.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.req.sysml.assistant.command.InitCreateProfileFromDomainModelCommand;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * Executes the generation of a profile based on a class diagram according to
+ * the preferences page of Papyrus Req
+ *
+ */
+public class InitCreateInitialProfileFromDomainModelHandler extends PapyrusAbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ super.execute(event);
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ InitCreateProfileFromDomainModelCommand initCreateProfileFromDomainModelCommand = new InitCreateProfileFromDomainModelCommand(
+ transactionalEditingDomain, selectedElement);
+ transactionalEditingDomain.getCommandStack().execute(initCreateProfileFromDomainModelCommand);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ *
+ * @return true if the handler is possible
+ */
+ @Override
+ public boolean isEnabled() {
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDefineRequirementsLanguageHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDefineRequirementsLanguageHandler.java
new file mode 100644
index 00000000000..38fa675e289
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDefineRequirementsLanguageHandler.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.req.sysml.assistant.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.req.sysml.assistant.command.InitDefineDomainSpecificRequirementsConceptsCommand;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * Executes the creation of a requirements specific language
+ *
+ */
+public class InitDefineRequirementsLanguageHandler extends PapyrusAbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ super.execute(event);
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ InitDefineDomainSpecificRequirementsConceptsCommand initDefineDomainSpecificRequirementsConceptsCommand = new InitDefineDomainSpecificRequirementsConceptsCommand(
+ transactionalEditingDomain, selectedElement);
+ transactionalEditingDomain.getCommandStack().execute(initDefineDomainSpecificRequirementsConceptsCommand);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ *
+ * @return true if the handler is possible
+ */
+ @Override
+ public boolean isEnabled() {
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDerivedReqHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDerivedReqHandler.java
index 96c45451d28..e9357a959e5 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDerivedReqHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/InitDerivedReqHandler.java
@@ -20,23 +20,22 @@ import org.eclipse.papyrus.req.sysml.assistant.command.InitDerivedReqCommand;
import org.eclipse.uml2.uml.Element;
/**
- * Use to create a derived requirement
+ * Executes the creation of a derived requirement
+ *
*/
-
-public class InitDerivedReqHandler extends PapyrusReqSysMLAbstractHandler {
-
-
+public class InitDerivedReqHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
- ArrayList<Element> selectedElement=getSelectionSet();
- if( selectedElement.size()!=0){
- InitDerivedReqCommand initDerivedReqCommand= new InitDerivedReqCommand(transactionalEditingDomain,selectedElement);
+ ArrayList<Element> selectedElement = getSelectionSet();
+ if (selectedElement.size() != 0) {
+ InitDerivedReqCommand initDerivedReqCommand = new InitDerivedReqCommand(transactionalEditingDomain,
+ selectedElement);
transactionalEditingDomain.getCommandStack().execute(initDerivedReqCommand);
}
return null;
}
-
+
/**
*
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
@@ -45,12 +44,12 @@ public class InitDerivedReqHandler extends PapyrusReqSysMLAbstractHandler {
*/
@Override
public boolean isEnabled() {
- ArrayList<Element> selectedElement=getSelectionSet();
- if( selectedElement.size()!=0){
+ ArrayList<Element> selectedElement = getSelectionSet();
+ if (selectedElement.size() != 0) {
return true;
+ } else {
+ return false;
}
- else{ return false;}
}
-
} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusReqSysMLAbstractHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusAbstractHandler.java
index 4a92218fa82..0c905d2b965 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusReqSysMLAbstractHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusAbstractHandler.java
@@ -33,10 +33,10 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Element;
/**
- * Abstract handler in order to connect to Papyrus
+ * Abstract handler in order to do the connection with Papyrus
*
*/
-public abstract class PapyrusReqSysMLAbstractHandler extends AbstractHandler {
+public abstract class PapyrusAbstractHandler extends AbstractHandler {
protected TransactionalEditingDomain transactionalEditingDomain=null;
protected IMultiDiagramEditor papyrusEditor;
@@ -87,7 +87,7 @@ public abstract class PapyrusReqSysMLAbstractHandler extends AbstractHandler {
return null;
}
/**
- * getSelected element in the diagram or in hte model explorer
+ * getSelected element in the diagram or in the model explorer
* @return Element or null
*/
protected ArrayList<Element> getSelectionSet(){
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusReqSysMLRequirementHandler.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusReqSysMLRequirementHandler.java
index b360f1079c9..68568671cf6 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusReqSysMLRequirementHandler.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/handler/PapyrusReqSysMLRequirementHandler.java
@@ -19,23 +19,23 @@ import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
/**
- * this class create a new requirement from the preferences
+ * Executes the creation of a new SysML requirement based on the Papyrus Req
+ * preferences page.
+ *
*/
-
-public class PapyrusReqSysMLRequirementHandler extends PapyrusReqSysMLAbstractHandler {
-
-
+public class PapyrusReqSysMLRequirementHandler extends PapyrusAbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
super.execute(event);
- Element selectedElement=getSelection();
- if( selectedElement instanceof Package){
- PapyrusReqSysMLRequirementCreateCommand darwinRequirementCommand= new PapyrusReqSysMLRequirementCreateCommand(transactionalEditingDomain,selectedElement);
+ Element selectedElement = getSelection();
+ if (selectedElement instanceof Package) {
+ PapyrusReqSysMLRequirementCreateCommand darwinRequirementCommand = new PapyrusReqSysMLRequirementCreateCommand(
+ transactionalEditingDomain, selectedElement);
transactionalEditingDomain.getCommandStack().execute(darwinRequirementCommand);
}
return null;
}
-
+
/**
*
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
@@ -44,13 +44,14 @@ public class PapyrusReqSysMLRequirementHandler extends PapyrusReqSysMLAbstractHa
*/
@Override
public boolean isEnabled() {
- Element selectedElement=getSelection();
- if( selectedElement instanceof Package){
+ Element selectedElement = getSelection();
+ if (selectedElement instanceof Package) {
return true;
}
-
- else{ return false;}
+
+ else {
+ return false;
+ }
}
-
} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/testers/ProfileTester.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/testers/ProfileTester.java
new file mode 100644
index 00000000000..e828214a329
--- /dev/null
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.assistant/src/org/eclipse/papyrus/req/sysml/assistant/testers/ProfileTester.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.req.sysml.assistant.testers;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.uml2.uml.Profile;
+
+/**
+ * This class helps to test if the selected element is a UML Profile or not
+ */
+public class ProfileTester extends PropertyTester {
+
+ public static final String isUMLProfile = "isUMLProfile";//NLS
+
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (isUMLProfile.equals(property)) {
+ boolean testResult = isExpected((IStructuredSelection) receiver);
+
+ return expectedValue.equals(testResult);
+ }
+ return false;
+ }
+ private boolean isExpected(IStructuredSelection receiver) {
+ for (Object current : receiver.toArray()) {
+ // Adapt current selection to EObject
+ if (current instanceof IAdaptable) {
+ EObject eObj = (EObject) ((IAdaptable) current)
+ .getAdapter(EObject.class);
+ if (eObj instanceof Profile)
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+
+}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceConstants.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceConstants.java
index c4ff952bc6c..7431f4ece27 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceConstants.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceConstants.java
@@ -21,4 +21,10 @@ public class PreferenceConstants {
public static final String REQUIREMENT_ID_PREFIX = "REQUIREMENT_ID_PREFIX";
public static final String REQUIREMENT_ID_DIGIT = "REQUIREMENT_ID_DIGIT";
public static final String CHILD_REQUIREMENTS_SEPARATOR = "CHILD_REQUIREMENTS_SEPARATOR";
+
+ public static final String NSURI_PREFIX = "NSURI_PREFIX";
+ public static final String GENERATE_ABSTRACTIONS_MODEL = "GENERATE_ABSTRACTIONS_MODEL";
+ public static final String FROM_ASSOCIATIONS_TO_STEREOTYPES = "FROM_ASSOCIATIONS_TO_STEREOTYPES";
+// public static final String METACLASS_EXTENDED_BY_NODES = "METACLASS_EXTENDED_BY_NODES";
+// public static final String METACLASS_EXTENDED_BY_EDGES = "METACLASS_EXTENDED_BY_EDGES";
} \ No newline at end of file
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceInitializer.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceInitializer.java
index b6ff73f3a30..ae77ee1b2eb 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceInitializer.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferenceInitializer.java
@@ -9,7 +9,7 @@
*
* Contributors:
* CEA LIST. - initial API and implementation
- * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST - Bugs 477726, 478595
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Bugs 477726, 478595, 481377
*
******************************************************************************/
package org.eclipse.papyrus.req.sysml.preferences;
@@ -17,20 +17,22 @@ package org.eclipse.papyrus.req.sysml.preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
-
/**
- * Initializes the preferences for the creation of Papyrus REQ SysML requirements
+ * Initializes the preferences for the creation of Papyrus REQ SysML
+ * requirements
*
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(PreferenceConstants.REQUIREMENT_ID_PREFIX, "REQ_");
store.setDefault(PreferenceConstants.REQUIREMENT_ID_DIGIT, 3);
store.setDefault(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR, "_");
- }
+ store.setDefault(PreferenceConstants.NSURI_PREFIX, "https://www.eclipse.org/papyrus/");
+ store.setDefault(PreferenceConstants.GENERATE_ABSTRACTIONS_MODEL, false);
+ store.setDefault(PreferenceConstants.FROM_ASSOCIATIONS_TO_STEREOTYPES, false);
+ }
}
diff --git a/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferencePage.java b/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferencePage.java
index 5566d592c44..1f9884442ad 100644
--- a/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferencePage.java
+++ b/extraplugins/req/org.eclipse.papyrus.req.sysml.preferences/src/org/eclipse/papyrus/req/sysml/preferences/PreferencePage.java
@@ -9,12 +9,13 @@
*
* Contributors:
* CEA LIST. - initial API and implementation
- * Mauricio Alférez (mauricio.alferez@cea.fr) CEA LIST - Bugs 477726, 478595
+ * Mauricio Alferez (mauricio.alferez@cea.fr) CEA LIST - Bugs 477726, 478595,
*
*******************************************************************************/
package org.eclipse.papyrus.req.sysml.preferences;
+import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
@@ -26,10 +27,10 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
- * Preference page related to SysML Papyrus REQ
+ * Preference page related to SysML Papyrus REQ
*
*/
-public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public PreferencePage() {
super(GRID);
@@ -37,33 +38,42 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkb
setDescription("Papyrus SysML Requirements");
}
-
/**
- * Creates the field editors. Field editors are abstractions of
- * the common GUI blocks needed to manipulate various types
- * of preferences. Each field editor knows how to save and
- * restore itself.
+ * Creates the field editors. Field editors are abstractions of the common
+ * GUI blocks needed to manipulate various types of preferences. Each field
+ * editor knows how to save and restore itself.
*/
@Override
public void createFieldEditors() {
+ Group reqCreationOptions = createGroup("Requirement");
+ addField(new StringFieldEditor(PreferenceConstants.REQUIREMENT_ID_PREFIX, "Prefix for requirement ID",
+ reqCreationOptions));
+ addField(new IntegerFieldEditor(PreferenceConstants.REQUIREMENT_ID_DIGIT, "Number of digits for requirement ID",
+ reqCreationOptions));
+ addField(new StringFieldEditor(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR,
+ "Separator between parent and child requirements IDs", reqCreationOptions));
- Group dmGroup = createGroup("Requirement");
- addField(new StringFieldEditor(PreferenceConstants.REQUIREMENT_ID_PREFIX,"Prefix for requirement ID",dmGroup));
- addField(new IntegerFieldEditor(PreferenceConstants.REQUIREMENT_ID_DIGIT,"Number of digits for requirement ID",dmGroup));
- addField(new StringFieldEditor(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR,"Separator between parent and child requirements IDs",dmGroup));
+ Group profileCreationOptions = createGroup("Profile Creation");
+ addField(new BooleanFieldEditor(PreferenceConstants.GENERATE_ABSTRACTIONS_MODEL,
+ "Generate an abstraction model?", profileCreationOptions));
+ addField(new BooleanFieldEditor(PreferenceConstants.FROM_ASSOCIATIONS_TO_STEREOTYPES,
+ "Transform from associations to stereotypes?", profileCreationOptions));
+ addField(new StringFieldEditor(PreferenceConstants.NSURI_PREFIX, "Ns URI prefix for new profile",
+ profileCreationOptions));
}
/*
* (non-Javadoc)
*
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ * @see
+ * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
}
private Group createGroup(String text) {
Group group = new Group(getFieldEditorParent(), SWT.NONE);
- //group.setLayout(new GridLayout(1, false));
+ // group.setLayout(new GridLayout(1, false));
GridLayout gridLayout = new GridLayout(2, false);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
@@ -77,5 +87,4 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkb
return group;
}
-
} \ No newline at end of file

Back to the top