Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauricio Alferez2016-02-22 13:57:09 +0000
committerGerrit Code Review @ Eclipse.org2016-02-24 15:10:19 +0000
commit3dec4967ac2a6fcfb71f059bf7e347091b81df89 (patch)
treef53afdb069c269258c4ed16652f1e86b3d622994
parentb55f2cbe11571743b459d4506d87faafc471c579 (diff)
downloadorg.eclipse.papyrus-3dec4967ac2a6fcfb71f059bf7e347091b81df89.tar.gz
org.eclipse.papyrus-3dec4967ac2a6fcfb71f059bf7e347091b81df89.tar.xz
org.eclipse.papyrus-3dec4967ac2a6fcfb71f059bf7e347091b81df89.zip
Checking Standard Profile application in Refines-RefinedBy relationships
Change-Id: I9a50b7f60659f07cf0ac01fdd5328df0e429a8e5 Signed-off-by: Mauricio Alferez <mauricio.alferez@cea.fr>
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.common/src/org/eclipse/papyrus/requirements/common/Utils.java23
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.common/src/org/eclipse/papyrus/requirements/sysml/common/I_SysMLStereotype.java2
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinedByCommand.java29
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinesCommand.java27
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/RefinementCreateCommand.java43
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinedByLinkHandler.java11
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinesLinkHandler.java3
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.ui/plugin.xml2
8 files changed, 100 insertions, 40 deletions
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.common/src/org/eclipse/papyrus/requirements/common/Utils.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.common/src/org/eclipse/papyrus/requirements/common/Utils.java
index df98b28d5d9..2006e07fcab 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.common/src/org/eclipse/papyrus/requirements/common/Utils.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.common/src/org/eclipse/papyrus/requirements/common/Utils.java
@@ -16,10 +16,16 @@ package org.eclipse.papyrus.requirements.common;
import java.util.ArrayList;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
public class Utils {
+
+ private Utils() {
+ }
+
/**
* @param elem UML model element
* @return the highest level Package of the element
@@ -37,7 +43,7 @@ public class Utils {
* @param element
* the model element that can apply profiles
* @param requiredProfiles
- * the profiles that will be verified
+ * the qualified names of the profiles that will be verified
* @return the list of missing profiles
*/
public static ArrayList<String> getMissingRequiredProfileApplications(org.eclipse.uml2.uml.Package element,
@@ -50,4 +56,19 @@ public class Utils {
}
return missingProfiles;
}
+
+ /**
+ * Prints a list of missing profiles
+ *
+ * @param requiredProfiles
+ */
+ public static void printMissingProfiles(Package thePackage, ArrayList<String> requiredProfiles) {
+ for (String missingProfileQN : Utils
+ .getMissingRequiredProfileApplications(thePackage, requiredProfiles)) {
+ MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Missing profile application",
+ "Please apply the profile " + missingProfileQN + " to "
+ + thePackage.getName());
+ }
+ }
+
}
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.common/src/org/eclipse/papyrus/requirements/sysml/common/I_SysMLStereotype.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.common/src/org/eclipse/papyrus/requirements/sysml/common/I_SysMLStereotype.java
index f861b793514..609546848a3 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.common/src/org/eclipse/papyrus/requirements/sysml/common/I_SysMLStereotype.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.common/src/org/eclipse/papyrus/requirements/sysml/common/I_SysMLStereotype.java
@@ -17,6 +17,8 @@ package org.eclipse.papyrus.requirements.sysml.common;
*
*/
public interface I_SysMLStereotype {
+ /** Qualified name of the SysML for Requirements profile*/
+ public static final String SYSML_4_REQUIREMENTS_PROFILE = "SysML::Requirements";
/** Qualified name of the stereotype Conform */
public static final String CONFORM_STEREOTYPE = "SysML::ModelElements::Conform";
/** name of property base_Dependency of the stereotype Conform */
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinedByCommand.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinedByCommand.java
index 5da512430ee..f855b5704a9 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinedByCommand.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinedByCommand.java
@@ -14,6 +14,9 @@
*****************************************************************************/
package org.eclipse.papyrus.requirements.sysml.traceability.commands;
+import java.util.ArrayList;
+import java.util.Arrays;
+
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.widgets.editors.MultipleValueSelectionDialog;
@@ -27,11 +30,11 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.UseCase;
/**
*
- * Creates a set of Refine links based on a requirement
+ * Creates a set of Refine links based on a requirement that is refined by the
+ * model element(s) selected in a MultipleValueSelectionDialog
*
*/
public class AddRefinedByCommand extends RecordingCommand {
@@ -46,30 +49,42 @@ public class AddRefinedByCommand extends RecordingCommand {
@Override
protected void doExecute() {
- if (selectedElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE) != null) {
+ if (selectedElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE) != null) {
final IStaticContentProvider provider = new UMLContentProvider(Utils.getToPackage(selectedElement),
UMLPackage.eINSTANCE.getPackage_PackagedElement());
ReferenceSelector selector = new ReferenceSelector();
selector.setLabelProvider(new UMLLabelProvider());
selector.setContentProvider(provider);
MultipleValueSelectionDialog dialog = new MultipleValueSelectionDialog(
- Display.getDefault().getActiveShell(), selector, "Choose the Use Cases that refine the requirement");
-
+ Display.getDefault().getActiveShell(), selector,
+ "Choose the model element(s) (for example, use cases) that refine "
+ + ((NamedElement) selectedElement).getName());
dialog.setLabelProvider(new UMLLabelProvider());
dialog.create();
+
if (dialog.open() == org.eclipse.jface.window.Window.OK) {
Object[] result = dialog.getResult();
for (int i = 0; i < result.length; i++) {
Element currentElement = (Element) result[i];
- if (currentElement instanceof UseCase) {
+ // chosen elements cannot be requirements
+ if (currentElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE) == null) {
+ ArrayList<String> requiredProfiles = new ArrayList<String>(Arrays.asList("StandardProfile"));
+ ArrayList<String> missingProfiles = Utils.getMissingRequiredProfileApplications(
+ currentElement.getNearestPackage(), requiredProfiles);
+ if (missingProfiles.size() > 0) {
+ Utils.printMissingProfiles(currentElement.getNearestPackage(), missingProfiles);
+ return;
+ }
RefinementCreateCommand refinementCreateCommand = new RefinementCreateCommand(domain,
- (UseCase) currentElement, (NamedElement) selectedElement);
+ (NamedElement) currentElement, (NamedElement) selectedElement);
refinementCreateCommand.execute();
}
}
+
}
}
}
+
} \ No newline at end of file
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinesCommand.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinesCommand.java
index 5b2da0f49d3..d4dce752ac3 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinesCommand.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/AddRefinesCommand.java
@@ -14,6 +14,9 @@
*****************************************************************************/
package org.eclipse.papyrus.requirements.sysml.traceability.commands;
+import java.util.ArrayList;
+import java.util.Arrays;
+
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.widgets.editors.MultipleValueSelectionDialog;
@@ -26,12 +29,13 @@ 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.Stereotype;
import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.UseCase;
/**
*
- * Creates a set of Refine links based on the model elements that refine the selected requirement
+ * Creates a set of Refine links based on the model element that refines the the
+ * requirement(s) selected in a MultipleValueSelectionDialog
*
*/
public class AddRefinesCommand extends RecordingCommand {
@@ -46,15 +50,23 @@ public class AddRefinesCommand extends RecordingCommand {
@Override
protected void doExecute() {
- if (selectedElement instanceof UseCase) {
+ if (selectedElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE) == null) {
+ ArrayList<String> requiredProfiles = new ArrayList<String>(Arrays.asList("StandardProfile"));
+ ArrayList<String> missingProfiles = Utils
+ .getMissingRequiredProfileApplications(selectedElement.getNearestPackage(), requiredProfiles);
+ if (missingProfiles.size() > 0) {
+ Utils.printMissingProfiles(selectedElement.getNearestPackage(), missingProfiles);
+ return;
+ }
+ Stereotype reqStereotype = selectedElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
final IStaticContentProvider provider = new UMLContentProvider(Utils.getToPackage(selectedElement),
- UMLPackage.eINSTANCE.getPackage_PackagedElement());
+ UMLPackage.eINSTANCE.getPackage_PackagedElement(), reqStereotype);
ReferenceSelector selector = new ReferenceSelector();
selector.setLabelProvider(new UMLLabelProvider());
selector.setContentProvider(provider);
MultipleValueSelectionDialog dialog = new MultipleValueSelectionDialog(
- Display.getDefault().getActiveShell(), selector, "Choose the requirements refined by the Use Case");
-
+ Display.getDefault().getActiveShell(), selector,
+ "Choose the requirement(s) refined by " + ((NamedElement) selectedElement).getName());
dialog.setLabelProvider(new UMLLabelProvider());
dialog.create();
@@ -63,9 +75,10 @@ public class AddRefinesCommand extends RecordingCommand {
for (int i = 0; i < result.length; i++) {
Element currentElement = (Element) result[i];
+ // chosen elements must be requirements
if (currentElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE) != null) {
RefinementCreateCommand refinementCreateCommand = new RefinementCreateCommand(domain,
- (UseCase) selectedElement, (NamedElement) currentElement);
+ (NamedElement) selectedElement, (NamedElement) currentElement);
refinementCreateCommand.execute();
}
}
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/RefinementCreateCommand.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/RefinementCreateCommand.java
index fe6e5d3fec6..1f161b27f1c 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/RefinementCreateCommand.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.commands/src/org/eclipse/papyrus/requirements/sysml/traceability/commands/RefinementCreateCommand.java
@@ -15,29 +15,33 @@
*****************************************************************************/
package org.eclipse.papyrus.requirements.sysml.traceability.commands;
+import java.util.ArrayList;
+import java.util.Arrays;
+
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.requirements.common.Utils;
import org.eclipse.uml2.uml.Abstraction;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UseCase;
+
/**
- * Used to create a link "Refine" between requirement and UseCase
+ * Used to create a link "Refine" between requirement and a Model Element
*
*/
public class RefinementCreateCommand extends RecordingCommand {
- private UseCase source;
+ private NamedElement source;
private NamedElement target;
/**
- * use to make an abstraction
+ * Makes an abstraction
* @param domain the domain to execute a transaction
- * @param source the source of the abstraction (the more concrete element) - client
- * @param target the target of the abstraction (the more abstract element) - supplier
+ * @param source the source of the abstraction (the more concrete element) - client. For example, a Use Case
+ * @param target the target of the abstraction (the more abstract element) - supplier. For example, a Requirement
*/
- public RefinementCreateCommand(TransactionalEditingDomain domain, UseCase source, NamedElement target){
+ public RefinementCreateCommand(TransactionalEditingDomain domain, NamedElement source, NamedElement target){
super(domain,"Create an Abstraction");
this.source=source;
this.target=target;
@@ -45,15 +49,20 @@ public class RefinementCreateCommand extends RecordingCommand {
@Override
protected void doExecute() {
- Abstraction theAbstraction= UMLFactory.eINSTANCE.createAbstraction();
- source.getNearestPackage().getPackagedElements().add(theAbstraction);
- theAbstraction.getSuppliers().add(target);
- theAbstraction.getClients().add(source);
- theAbstraction.setName("Refines_"+this.target.getName());
-// final String packageQN = UMLUtil.getProfile(StandardPackage.eINSTANCE, source.getNearestPackage()).getQualifiedName();
-// Stereotype refineStereotype= theAbstraction.getApplicableStereotype(packageQN+"::Refine");// now it is "StandardProfile::Refine" before it was "StandardProfileL2::Refine"
- Stereotype refineStereotype= theAbstraction.getApplicableStereotype("StandardProfile::Refine");
- theAbstraction.applyStereotype(refineStereotype);
+ ArrayList<String> requiredProfiles = new ArrayList<String>(
+ Arrays.asList("StandardProfile"));
+ ArrayList<String> missingProfiles = Utils.getMissingRequiredProfileApplications(source.getNearestPackage(), requiredProfiles);
+ if (missingProfiles.size() == 0) {
+ Abstraction theAbstraction = UMLFactory.eINSTANCE.createAbstraction();
+ source.getNearestPackage().getPackagedElements().add(theAbstraction);
+ theAbstraction.getSuppliers().add(target);
+ theAbstraction.getClients().add(source);
+ theAbstraction.setName("Refines_" + this.target.getName());
+ Stereotype refineStereotype = theAbstraction.getApplicableStereotype("StandardProfile::Refine");
+ theAbstraction.applyStereotype(refineStereotype);
+ } else {
+ Utils.printMissingProfiles(source.getNearestPackage(), missingProfiles);
+ return;
+ }
}
-
}
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinedByLinkHandler.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinedByLinkHandler.java
index e6855743213..e2e746410a2 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinedByLinkHandler.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinedByLinkHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST.
+ * Copyright (c) 2016 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -8,8 +8,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * CEA LIST. - initial API and implementation
- *******************************************************************************/
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.requirements.sysml.traceability.handlers;
import java.util.ArrayList;
@@ -21,7 +23,6 @@ import org.eclipse.papyrus.requirements.sysml.traceability.commands.AddRefinedBy
import org.eclipse.papyrus.requirements.sysml.traceability.commands.RefinementCreateCommand;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.UseCase;
/**
* Executes the addition of Refine links based on a selected requirement
@@ -34,7 +35,7 @@ public class AddRefinedByLinkHandler extends PapyrusAbstractHandler {
ArrayList<Element> selectedElements = getSelectionSet();
if (selectedElements.size() == 2) {
RefinementCreateCommand refinementCreateCommand = new RefinementCreateCommand(
- transactionalEditingDomain, (UseCase) selectedElements.get(0),
+ transactionalEditingDomain, (NamedElement) selectedElements.get(0),//e.g. a use case
(NamedElement) selectedElements.get(1));
transactionalEditingDomain.getCommandStack().execute(refinementCreateCommand);
} else {
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinesLinkHandler.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinesLinkHandler.java
index 5f3e9501c61..7963f48eab7 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinesLinkHandler.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.handlers/src/org/eclipse/papyrus/requirements/sysml/traceability/handlers/AddRefinesLinkHandler.java
@@ -21,7 +21,6 @@ import org.eclipse.papyrus.requirements.sysml.traceability.commands.AddRefinesCo
import org.eclipse.papyrus.requirements.sysml.traceability.commands.RefinementCreateCommand;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.UseCase;
/**
* Executes the addition of Refine links based on a selected model element (e.g. an Use Case)
@@ -34,7 +33,7 @@ public class AddRefinesLinkHandler extends PapyrusAbstractHandler {
ArrayList<Element> selectedElements = getSelectionSet();
if (selectedElements.size() == 2) {
RefinementCreateCommand refinementCreateCommand = new RefinementCreateCommand(
- transactionalEditingDomain, (UseCase) selectedElements.get(1),
+ transactionalEditingDomain, (NamedElement) selectedElements.get(1),
(NamedElement) selectedElements.get(0));
transactionalEditingDomain.getCommandStack().execute(refinementCreateCommand);
} else {
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.ui/plugin.xml b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.ui/plugin.xml
index 3bc0ac89fdf..355b2aa7722 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.ui/plugin.xml
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.traceability.ui/plugin.xml
@@ -68,7 +68,7 @@
<test
forcePluginActivation="true"
property="org.eclipse.papyrus.requirements.sysml.testers.isRequirementElement"
- value="false">
+ value="true">
</test>
</with>
</visibleWhen>

Back to the top