Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2018-11-12 04:41:28 -0500
committerPatrick Tessier2019-01-18 12:59:35 -0500
commit5e61a5490724d2ddf52caf45af21744482e8ada8 (patch)
tree9b4050c2a69eec4a77f2ef8f429e6fdda6dda340
parent9155f6ef5a453a6af60c5b79349f20c79b5ef2fd (diff)
downloadorg.eclipse.papyrus-5e61a5490724d2ddf52caf45af21744482e8ada8.tar.gz
org.eclipse.papyrus-5e61a5490724d2ddf52caf45af21744482e8ada8.tar.xz
org.eclipse.papyrus-5e61a5490724d2ddf52caf45af21744482e8ada8.zip
Bug 447665: [Profiles] Removing profiles definitions causing a profile
definition https://bugs.eclipse.org/bugs/show_bug.cgi?id=447665 - Disconnect save listner on Profile Diagram - Make functionnal Profile Definition view Change-Id: Ibcf8cc9ddd90a5e31ca287db1b3788221981d145 Signed-off-by: Gabriel Pascual <gabriel.pascual@all4tec.net>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java15
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/ProfileService.java11
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/pom.xml2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleProfileDefinition.xwt12
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java70
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionObservableValue.java106
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionValueFactory.java90
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DefineProfileCommand.java247
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java3
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/PapyrusDefinitionAnnotation.java35
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/IPapyrusProfileDefinition.java41
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/PapyrusProfileDefinition.java68
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/tests/DefineProfileCommandTest.java12
18 files changed, 689 insertions, 47 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
index 1c3b7b49ae4..40210f35877 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
@@ -80,7 +80,7 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.services.markerlistener;bundle-version="[2.0.0,3.0.0)"
Bundle-Vendor: %providerName
Eclipse-LazyStart: true
-Bundle-Version: 3.1.0.qualifier
+Bundle-Version: 3.2.0.qualifier
Bundle-Activator: org.eclipse.papyrus.uml.diagram.profile.part.UMLDiagramEditorPlugin
Bundle-ManifestVersion: 2
Bundle-Description: %pluginDescription
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java
index e635477e288..3baa77179ad 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java
@@ -63,8 +63,9 @@ import org.eclipse.uml2.uml.util.UMLUtil.UML2EcoreConverter;
* This command is used to define a profile
*
* @author Vincent Lorenzo
- *
+ * @deprecated since 3.2. Use {@code org.eclipse.papyrus.uml.tools.commands.DefineProfileCommand} instead.
*/
+@Deprecated
public class DefineProfileCommand extends AbstractTransactionalCommand {
/**
@@ -103,7 +104,7 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
* the package to define (if it is a profile)
*/
public static List<EPackage> defineProfiles(Package thePackage, boolean saveConstraintInDef) {
- Map<String, String> options = new HashMap<String, String>();
+ Map<String, String> options = new HashMap<>();
options.put(UML2EcoreConverter.OPTION__ECORE_TAGGED_VALUES, UMLUtil.OPTION__PROCESS);
options.put(UML2EcoreConverter.OPTION__DERIVED_FEATURES, UMLUtil.OPTION__REPORT);
@@ -124,8 +125,8 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
options.put(UML2EcoreConverter.OPTION__VALIDATION_DELEGATES, handleConstraints);
options.put(UML2EcoreConverter.OPTION__INVOCATION_DELEGATES, handleConstraints);
options.put(UML2EcoreConverter.OPTION__OPERATION_BODIES, handleConstraints);
-
- // Assure that "right" (consistent with xtext editor) OCL delegate is used , see bug 512428
+
+ // Assure that "right" (consistent with xtext editor) OCL delegate is used , see bug 512428
options.put(UML2EcoreConverter.OPTION__OCL_DELEGATE_URI, "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot"); //$NON-NLS-1$
options.put(UML2EcoreConverter.OPTION__COMMENTS, UMLUtil.OPTION__IGNORE);
@@ -133,7 +134,7 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
options.put(UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES, UMLUtil.OPTION__PROCESS); // Closer to the UML semantics of untyped properties
- List<Profile> toDefine = new ArrayList<Profile>();
+ List<Profile> toDefine = new ArrayList<>();
for (TreeIterator<EObject> all = UML2Util.getAllContents(thePackage, true, false); all.hasNext();) {
EObject next = all.next();
if (next instanceof Profile) {
@@ -149,7 +150,7 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
ProfileUtil.sortProfiles(toDefine);
}
- List<EPackage> result = new ArrayList<EPackage>(toDefine.size());
+ List<EPackage> result = new ArrayList<>(toDefine.size());
for (Profile next : toDefine) {
result.add(next.define(options, null, null));
}
@@ -253,7 +254,7 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
IFile f = WorkspaceSynchronizer.getFile(rootProfile.eResource());
return f != null ? Collections.<IFile> singletonList(f) : Collections.<IFile> emptyList();
}
-
+
/**
* Clean undefine tag.
*/
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java
index 7ee18d130d7..e3e659edbd7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/PreSaveProfileListener.java
@@ -59,7 +59,10 @@ import org.eclipse.uml2.uml.Profile;
*
*
* This class describes the actions to do just before the save action
+ *
+ * @deprecated since 3.2
*/
+@Deprecated
public class PreSaveProfileListener implements ISaveEventListener {
/**
@@ -67,12 +70,13 @@ public class PreSaveProfileListener implements ISaveEventListener {
*
* This function is called before the user make a "save" action
*/
+ @Override
public void doSave(DoSaveEvent event) {
if (event.isAutoSave()) {
return;
}
try {
- //System.out.println("preSave Event received"); //$NON-NLS-1$
+ // System.out.println("preSave Event received"); //$NON-NLS-1$
/**
* if the root is a profile, we must define it. If it's another thing, we
* do nothing
@@ -237,9 +241,10 @@ public class PreSaveProfileListener implements ISaveEventListener {
*
* This function is called before the user make a "save as" action
*/
+ @Override
public void doSaveAs(DoSaveEvent event) {
try {
- //System.out.println("preSaveAS Event received"); //$NON-NLS-1$
+ // System.out.println("preSaveAS Event received"); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/ProfileService.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/ProfileService.java
index 233611afedf..86e5492fb8c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/ProfileService.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/service/ProfileService.java
@@ -28,7 +28,9 @@ import org.eclipse.papyrus.infra.ui.lifecycleevents.LifeCycleEventsProvider;
* This class is registered as a Papyrus service.
* It then registered itself to the {@link LifeCycleEventsProvider}.
*
+ * @deprecated since 3.2.
*/
+@Deprecated
public class ProfileService implements IService {
/**
@@ -55,16 +57,17 @@ public class ProfileService implements IService {
*/
public ProfileService() {
aboutToSaveListener = new PreSaveProfileListener();
- // System.out.println("ProfileService created"); //$NON-NLS-1$
+ // System.out.println("ProfileService created"); //$NON-NLS-1$
}
/**
* @see org.eclipse.papyrus.infra.core.services.IService#disposeService()
*
*/
+ @Override
public void disposeService() {
deactivate();
- // System.out.println("ProfileService disposed"); //$NON-NLS-1$
+ // System.out.println("ProfileService disposed"); //$NON-NLS-1$
}
@@ -76,6 +79,7 @@ public class ProfileService implements IService {
*
* @param servicesRegistry
*/
+ @Override
public void init(ServicesRegistry servicesRegistry) {
this.servicesRegistry = servicesRegistry;
@@ -85,9 +89,10 @@ public class ProfileService implements IService {
* @see org.eclipse.papyrus.infra.core.services.IService#startService()
*
*/
+ @Override
public void startService() {
activate();
- // System.out.println("ProfileService started"); //$NON-NLS-1$
+ // System.out.println("ProfileService started"); //$NON-NLS-1$
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml
index d5893b4f545..78c0adbeb0b 100755
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml
@@ -186,15 +186,6 @@
<extension point="org.eclipse.ui.handlers" id="menu-handlers">
<?gmfgen generated="true"?>
</extension>
-<extension
- point="org.eclipse.papyrus.infra.core.service">
- <service
- classname="org.eclipse.papyrus.uml.diagram.profile.service.ProfileService"
- priority="1"
- startKind="startup"
- useClassTypeAsKey="true">
- </service>
-</extension>
<extension point="org.eclipse.ui.preferencePages" id="prefpages">
<?gmfgen generated="true"?>
<page
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/pom.xml
index f6e9f207608..c03ee068986 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/pom.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.diagram.profile</artifactId>
- <version>3.1.0-SNAPSHOT</version>
+ <version>3.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleProfileDefinition.xwt b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleProfileDefinition.xwt
index 33846103795..80ecfba7400 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleProfileDefinition.xwt
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleProfileDefinition.xwt
@@ -10,14 +10,14 @@
<Composite.layout>
<ppel:PropertiesLayout numColumns="2"></ppel:PropertiesLayout>
</Composite.layout>
- <ppe:StringLabel input="{Binding}"
+ <ppe:StringEditor input="{Binding}"
property="ProfileDefinitionAnnotation:PapyrusVersion:Version"
- readOnly="true"></ppe:StringLabel>
- <ppe:StringLabel input="{Binding}"
- property="ProfileDefinitionAnnotation:PapyrusVersion:Date" readOnly="true"></ppe:StringLabel>
- <ppe:StringLabel input="{Binding}"
+ readOnly="true"></ppe:StringEditor>
+ <ppe:StringEditor input="{Binding}"
+ property="ProfileDefinitionAnnotation:PapyrusVersion:Date" readOnly="true"></ppe:StringEditor>
+ <ppe:StringEditor input="{Binding}"
property="ProfileDefinitionAnnotation:PapyrusVersion:Author"
- readOnly="true"></ppe:StringLabel>
+ readOnly="true"></ppe:StringEditor>
</Composite>
<Composite>
<Composite.layout>
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java
index 8ca3ea5d907..280ed80ace9 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionModelElement.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2014 CEA LIST and others.
+ * Copyright (c) 2013, 2014, 2018 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 323802
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 447665
*
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
@@ -21,20 +22,29 @@ import org.eclipse.emf.databinding.EMFObservables;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.TransactionHelper;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.properties.ui.modelelement.AbstractModelElement;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList;
+import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
+import org.eclipse.papyrus.uml.tools.Activator;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.util.UMLUtil;
-
+/**
+ * Model Element for Profile Definitions.
+ */
public class ProfileDefinitionModelElement extends AbstractModelElement {
+ /** The Constant RETRIEVE_EANNOTATION_ERROR. */
+ private static final String RETRIEVE_EANNOTATION_ERROR = "Failed to retrieve Profile Defintion root annotation."; //$NON-NLS-1$
+
/**
* The Profile::definitions property. Contains the list of definitions (EPackage) of this profile
*/
@@ -51,17 +61,43 @@ public class ProfileDefinitionModelElement extends AbstractModelElement {
if (DEFINITIONS.equals(propertyPath)) {
if (profile != null) {
- EAnnotation definitions = profile.getEAnnotation(UMLUtil.UML2_UML_PACKAGE_2_0_NS_URI);
- if (definitions != null) {
- EditingDomain domain = EMFHelper.resolveEditingDomain(profile);
- return new PapyrusObservableList(EMFObservables.observeList(definitions, EcorePackage.eINSTANCE.getEAnnotation_Contents()), domain, definitions, EcorePackage.eINSTANCE.getEAnnotation_Contents());
- }
+ EditingDomain domain = EMFHelper.resolveEditingDomain(profile);
+ EAnnotation definitions = getProfileDefinitionsRootAnnotation((TransactionalEditingDomain) domain);
+ return new ProfileDefinitionObservableValue(profile, EMFObservables.observeList(definitions, EcorePackage.eINSTANCE.getEAnnotation_Contents()), domain, definitions, EcorePackage.eINSTANCE.getEAnnotation_Contents());
+
}
}
return Observables.emptyObservableList();
}
+ /**
+ * Gets the profile definitions root annotation.
+ *
+ * @param domain
+ * the domain
+ * @return the profile definitions root annotation
+ */
+ private EAnnotation getProfileDefinitionsRootAnnotation(final TransactionalEditingDomain domain) {
+
+ try {
+ TransactionHelper.run(domain, new Runnable() {
+ @Override
+ public void run() {
+ UMLUtil.getEAnnotation(profile, UMLUtil.UML2_UML_PACKAGE_2_0_NS_URI, true);
+ }
+ });
+
+ } catch (InterruptedException e) {
+ Activator.log.error(RETRIEVE_EANNOTATION_ERROR, e);
+ } catch (RollbackException e) {
+ Activator.log.error(RETRIEVE_EANNOTATION_ERROR, e);
+ }
+
+ return profile.getEAnnotation(UMLUtil.UML2_UML_PACKAGE_2_0_NS_URI);
+
+ }
+
@Override
public ILabelProvider getLabelProvider(String propertyPath) {
try {
@@ -71,6 +107,24 @@ public class ProfileDefinitionModelElement extends AbstractModelElement {
}
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement#getValueFactory(java.lang.String)
+ */
+ @Override
+ public ReferenceValueFactory getValueFactory(final String propertyPath) {
+ ReferenceValueFactory valueFactory = null;
+ if (DEFINITIONS.equals(propertyPath)) {
+ valueFactory = new ProfileDefinitionValueFactory(profile, EcorePackage.eINSTANCE.getEAnnotation_Contents());
+ } else {
+ // Try with inherited implementation
+ valueFactory = super.getValueFactory(propertyPath);
+ }
+
+ return valueFactory;
+ }
+
@Override
public boolean isOrdered(String propertyPath) {
return false;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionObservableValue.java
new file mode 100644
index 00000000000..5db5648331c
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionObservableValue.java
@@ -0,0 +1,106 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.properties.modelelement;
+
+import java.util.List;
+
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.uml.tools.commands.DefineProfileCommand;
+import org.eclipse.papyrus.uml.tools.commands.UndefineProfileCommand;
+import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList;
+import org.eclipse.papyrus.uml.tools.profile.definition.IPapyrusVersionConstants;
+import org.eclipse.papyrus.uml.tools.profile.definition.PapyrusDefinitionAnnotation;
+import org.eclipse.papyrus.uml.tools.util.IPapyrusProfileDefinition;
+import org.eclipse.uml2.uml.Profile;
+
+/**
+ * Observable for Profile Definition list of a profile.
+ */
+public class ProfileDefinitionObservableValue extends PapyrusObservableList implements IObservable {
+
+ /** The profile which contains definitions. */
+ private Profile profile = null;
+
+ /**
+ * Instantiates a new profile definition observable value.
+ *
+ * @param profile
+ * the profile
+ * @param wrappedList
+ * the wrapped list
+ * @param domain
+ * the domain
+ * @param source
+ * the source
+ * @param feature
+ * the feature
+ */
+ public ProfileDefinitionObservableValue(final Profile profile, final List<?> wrappedList, final EditingDomain domain, final EObject source, final EStructuralFeature feature) {
+ super(wrappedList, domain, source, feature);
+ this.profile = profile;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList#getAddCommand(java.lang.Object)
+ *
+ * @param value
+ * @return
+ */
+ @Override
+ public Command getAddCommand(final Object value) {
+ Command addCommand = null;
+ if (value instanceof IPapyrusProfileDefinition) {
+ EObject rootProfile = EcoreUtil.getRootContainer(profile);
+ if (rootProfile instanceof Profile) {
+ addCommand = new DefineProfileCommand((TransactionalEditingDomain) editingDomain, (IPapyrusProfileDefinition) value, (Profile) rootProfile);
+ }
+ } else {
+ // Get command from parent
+ addCommand = super.getAddCommand(value);
+ }
+
+ return addCommand;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList#getRemoveCommand(java.lang.Object)
+ */
+ @Override
+ public Command getRemoveCommand(final Object value) {
+ Command removeCommand = null;
+ if (value instanceof EPackage) {
+ EObject rootProfile = EcoreUtil.getRootContainer(profile);
+ PapyrusDefinitionAnnotation papyrusAnnotation = PapyrusDefinitionAnnotation.parseEAnnotation(((EPackage) value).getEAnnotation(IPapyrusVersionConstants.PAPYRUS_EANNOTATION_SOURCE));
+ if (rootProfile instanceof Profile) {
+ removeCommand = new UndefineProfileCommand((TransactionalEditingDomain) editingDomain, papyrusAnnotation, (Profile) rootProfile);
+ }
+ } else {
+ removeCommand = super.getRemoveCommand(value);
+ }
+ return removeCommand;
+ }
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionValueFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionValueFactory.java
new file mode 100644
index 00000000000..5c3794911d5
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionValueFactory.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.properties.modelelement;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.papyrus.infra.properties.ui.creation.EcorePropertyEditorFactory;
+import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
+import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileDefinitionDialog;
+import org.eclipse.papyrus.uml.tools.util.PapyrusProfileDefinition;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.uml2.uml.Profile;
+
+/**
+ * Property Editor Factory for Profile Definition.
+ */
+public class ProfileDefinitionValueFactory extends EcorePropertyEditorFactory implements ReferenceValueFactory {
+
+ /** The Constant EDIT_DIALOG_TITLE. */
+ private static final String EDIT_DIALOG_TITLE = "Edit Profile Definition"; //$NON-NLS-1$
+
+ /** The profile to define. */
+ private final Profile profileToDefine;
+
+ /**
+ * Instantiates a new profile definition value factory.
+ *
+ * @param profile
+ * The profile.
+ * @param referenceIn
+ * The reference.
+ */
+ public ProfileDefinitionValueFactory(final Profile profile, final EReference referenceIn) {
+ super(referenceIn);
+ profileToDefine = profile;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.views.properties.creation.EcorePropertyEditorFactory#doCreateObject(org.eclipse.swt.widgets.Control, java.lang.Object)
+ */
+ @Override
+ protected Object doCreateObject(final Control widget, final Object context) {
+ Object createdObject = null;
+ EObject rootProfile = EcoreUtil.getRootContainer(profileToDefine);
+ if (rootProfile instanceof Profile) {
+ ProfileDefinitionDialog dialog = new ProfileDefinitionDialog(widget.getShell(), (Profile) rootProfile);
+ int returnDialog = dialog.open();
+ if (Dialog.OK == returnDialog) {
+ createdObject = new PapyrusProfileDefinition(dialog.getPapyrusDefinitionAnnotation(), dialog.saveConstraintInDefinition());
+ }
+ }
+
+ return createdObject;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.views.properties.creation.EcorePropertyEditorFactory#getEditionDialogTitle(java.lang.Object)
+ */
+ @Override
+ public String getEditionDialogTitle(final Object objectToEdit) {
+ String dialogTitle = null;
+ if (objectToEdit instanceof EPackage) {
+ dialogTitle = EDIT_DIALOG_TITLE;
+ } else {
+ dialogTitle = super.getEditionDialogTitle(objectToEdit);
+ }
+
+ return dialogTitle;
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF
index e7ce3964cf0..4128e22f8bf 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF
@@ -33,7 +33,7 @@ Require-Bundle: org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)";visibility:=
org.eclipse.papyrus.infra.services.decoration;bundle-version="[2.0.0,3.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 4.1.0.qualifier
+Bundle-Version: 4.2.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.uml.tools.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml
index 78dd48f7c21..6d634f293e3 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml
@@ -9,7 +9,7 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.tools</artifactId>
- <version>4.1.0-SNAPSHOT</version>
+ <version>4.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<description>This plugin contributes a set of common tools for UML</description>
</project>
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DefineProfileCommand.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DefineProfileCommand.java
new file mode 100644
index 00000000000..d46d0832785
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DefineProfileCommand.java
@@ -0,0 +1,247 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2014 CEA LIST, Christian W. Damus, and others.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 451613
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 447665
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.commands;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.DiagnosticChain;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.tools.Activator;
+import org.eclipse.papyrus.uml.tools.profile.definition.PapyrusDefinitionAnnotation;
+import org.eclipse.papyrus.uml.tools.profile.definition.ProfileRedefinition;
+import org.eclipse.papyrus.uml.tools.util.IPapyrusProfileDefinition;
+import org.eclipse.papyrus.uml.tools.utils.ProfileUtil;
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.util.UMLUtil;
+import org.eclipse.uml2.uml.util.UMLUtil.Profile2EPackageConverter;
+import org.eclipse.uml2.uml.util.UMLUtil.UML2EcoreConverter;
+
+/**
+ * This command is used to define a profile
+ *
+ * @author Vincent Lorenzo
+ * @since 4.2
+ */
+public class DefineProfileCommand extends RecordingCommand {
+
+ /** The Constant COMMAND_LABEL. */
+ private static final String COMMAND_LABEL = "Define Profile Command";
+
+ /**
+ * the {@link PapyrusDefinitionAnnotation}
+ */
+ private IPapyrusProfileDefinition papyrusAnnotation;
+
+ /**
+ * the profile to define
+ */
+ private Profile rootProfile;
+
+
+ /**
+ * Instantiates a new define profile command.
+ *
+ * @param domain
+ * the domain
+ * @param papyrusAnnotation
+ * the papyrus annotation
+ * @param rootProfile
+ * the root profile
+ */
+ public DefineProfileCommand(final TransactionalEditingDomain domain, final IPapyrusProfileDefinition papyrusAnnotation, final Profile rootProfile) {
+ super(domain, COMMAND_LABEL, null);
+ this.rootProfile = rootProfile;
+ this.papyrusAnnotation = papyrusAnnotation;
+ }
+
+
+ /**
+ * Define this package if it is a profile and its sub-profiles
+ *
+ * @param thePackage
+ * the package to define (if it is a profile)
+ */
+ public static List<EPackage> defineProfiles(Package thePackage, boolean saveConstraintInDef) {
+ Map<String, String> options = new HashMap<>();
+
+ options.put(UML2EcoreConverter.OPTION__ECORE_TAGGED_VALUES, UMLUtil.OPTION__PROCESS);
+ options.put(UML2EcoreConverter.OPTION__DERIVED_FEATURES, UMLUtil.OPTION__REPORT);
+ options.put(UML2EcoreConverter.OPTION__DUPLICATE_FEATURE_INHERITANCE, UMLUtil.OPTION__PROCESS);
+ options.put(UML2EcoreConverter.OPTION__DUPLICATE_FEATURES, UMLUtil.OPTION__PROCESS);
+ options.put(UML2EcoreConverter.OPTION__DUPLICATE_OPERATIONS, UMLUtil.OPTION__REPORT);
+ options.put(UML2EcoreConverter.OPTION__DUPLICATE_OPERATION_INHERITANCE, UMLUtil.OPTION__REPORT);
+ options.put(UML2EcoreConverter.OPTION__REDEFINING_OPERATIONS, UMLUtil.OPTION__REPORT);
+ options.put(UML2EcoreConverter.OPTION__REDEFINING_PROPERTIES, UMLUtil.OPTION__REPORT);
+ options.put(UML2EcoreConverter.OPTION__SUBSETTING_PROPERTIES, UMLUtil.OPTION__REPORT);
+ options.put(UML2EcoreConverter.OPTION__UNION_PROPERTIES, UMLUtil.OPTION__PROCESS);
+ options.put(UML2EcoreConverter.OPTION__SUPER_CLASS_ORDER, UMLUtil.OPTION__REPORT);
+ options.put(UML2EcoreConverter.OPTION__ANNOTATION_DETAILS, UMLUtil.OPTION__REPORT);
+
+ // Generate constraints for the validation
+ String handleConstraints = saveConstraintInDef ? UMLUtil.OPTION__PROCESS : UMLUtil.OPTION__IGNORE;
+ options.put(UML2EcoreConverter.OPTION__INVARIANT_CONSTRAINTS, handleConstraints);
+ options.put(UML2EcoreConverter.OPTION__VALIDATION_DELEGATES, handleConstraints);
+ options.put(UML2EcoreConverter.OPTION__INVOCATION_DELEGATES, handleConstraints);
+ options.put(UML2EcoreConverter.OPTION__OPERATION_BODIES, handleConstraints);
+ //
+
+ options.put(UML2EcoreConverter.OPTION__COMMENTS, UMLUtil.OPTION__IGNORE);
+ options.put(Profile2EPackageConverter.OPTION__FOREIGN_DEFINITIONS, UMLUtil.OPTION__PROCESS);
+
+ options.put(UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES, UMLUtil.OPTION__PROCESS); // Closer to the UML semantics of untyped properties
+
+ List<Profile> toDefine = new ArrayList<>();
+ for (TreeIterator<EObject> all = UML2Util.getAllContents(thePackage, true, false); all.hasNext();) {
+ EObject next = all.next();
+ if (next instanceof Profile) {
+ toDefine.add((Profile) next);
+ } else if (!(next instanceof Package)) {
+ all.prune();
+ }
+ }
+
+ if (toDefine.size() > 1) {
+ // Sort the profiles in dependency order: used profiles ahead of the profiles that use them. This ensures that
+ // Ecore definitions are available for reference in the 4.1.0-style annotations instead of 4.0.0-style
+ ProfileUtil.sortProfiles(toDefine);
+ }
+
+ List<EPackage> result = new ArrayList<>(toDefine.size());
+ for (Profile next : toDefine) {
+ result.add(next.define(options, null, null));
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Post validate.
+ *
+ * @param profileDefinitions
+ * the profile definitions
+ * @return the i status
+ * @throws ExecutionException
+ * the execution exception
+ */
+ protected IStatus postValidate(List<EPackage> profileDefinitions) throws ExecutionException {
+
+ EditingDomain domain = EMFHelper.resolveEditingDomain(rootProfile);
+ AdapterFactory adapterFactory = domain instanceof AdapterFactoryEditingDomain ? ((AdapterFactoryEditingDomain) domain).getAdapterFactory() : null;
+ Diagnostician diagnostician = createDiagnostician(adapterFactory, new NullProgressMonitor());
+ diagnostic = diagnostician.createDefaultDiagnostic(rootProfile);
+ Map<Object, Object> context = diagnostician.createDefaultContext();
+
+ for (EPackage ePackage : profileDefinitions) {
+ diagnostician.validate(ePackage, diagnostic, context);
+ }
+
+ if (diagnostic.getSeverity() == Diagnostic.ERROR) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The defined profile is invalid");
+ }
+
+ if (diagnostic.getSeverity() == Diagnostic.WARNING) {
+ return new Status(IStatus.WARNING, Activator.PLUGIN_ID, "The profile has been successfully defined");
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ protected BasicDiagnostic diagnostic;
+
+ public Diagnostic getDiagnostic() {
+ return diagnostic;
+ }
+
+ /**
+ * Creates the diagnostician.
+ *
+ * @param adapterFactory
+ * the adapter factory
+ * @param progressMonitor
+ * the progress monitor
+ * @return the diagnostician
+ */
+ protected Diagnostician createDiagnostician(final AdapterFactory adapterFactory, final IProgressMonitor progressMonitor) {
+ return new Diagnostician() {
+
+ @Override
+ public String getObjectLabel(EObject eObject) {
+ if (adapterFactory != null && !eObject.eIsProxy()) {
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(eObject, IItemLabelProvider.class);
+ if (itemLabelProvider != null) {
+ return itemLabelProvider.getText(eObject);
+ }
+ }
+ return super.getObjectLabel(eObject);
+ }
+
+ @Override
+ public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
+ progressMonitor.worked(1);
+ return super.validate(eClass, eObject, diagnostics, context);
+ }
+ };
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ *
+ */
+ @Override
+ protected void doExecute() {
+
+ List<EPackage> profileDefinitions = defineProfiles(rootProfile, papyrusAnnotation.saveConstraintDefinition());
+
+ ProfileRedefinition.redefineProfile(rootProfile, papyrusAnnotation.getPapyrusAnnotation());
+ ProfileRedefinition.cleanProfile(rootProfile);
+ try {
+ postValidate(profileDefinitions);
+ } catch (ExecutionException e) {
+ Activator.log.error(e);
+ }
+
+
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java
index 6e168a7b7da..b5c5ca11789 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java
@@ -35,8 +35,7 @@ import org.eclipse.uml2.uml.util.UMLUtil;
/**
* Removed all Profile Definitions of all Profile model.
- *
- * @author Gabriel Pascual
+
* @since 4.1
*
*/
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/PapyrusDefinitionAnnotation.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/PapyrusDefinitionAnnotation.java
index 73901b41aeb..ca17409a362 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/PapyrusDefinitionAnnotation.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/profile/definition/PapyrusDefinitionAnnotation.java
@@ -151,4 +151,39 @@ public class PapyrusDefinitionAnnotation {
public String getAuthor() {
return author;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ boolean equal = false;
+ if (obj instanceof PapyrusDefinitionAnnotation) {
+ PapyrusDefinitionAnnotation definitionAnnotation = (PapyrusDefinitionAnnotation) obj;
+ equal = definitionAnnotation.author.equals(this.author) &&
+ definitionAnnotation.comment.equals(this.comment) &&
+ definitionAnnotation.copyright.equals(this.copyright) &&
+ definitionAnnotation.version.toString().equals(this.version.toString());
+ }
+ return equal;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ int hash = 1;
+
+ hash = hash * 13 * this.author.hashCode();
+ hash = hash * 32 * this.comment.hashCode();
+ hash = hash * 21 * this.copyright.hashCode();
+ hash = hash * 8 * this.version.toString().hashCode();
+
+ return hash;
+ }
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/IPapyrusProfileDefinition.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/IPapyrusProfileDefinition.java
new file mode 100644
index 00000000000..69e05846c53
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/IPapyrusProfileDefinition.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.tools.util;
+
+import org.eclipse.papyrus.uml.tools.profile.definition.PapyrusDefinitionAnnotation;
+
+/**
+ * Interface for Papyrus Definition of Profile.
+ *
+ * @since 4.2
+ */
+public interface IPapyrusProfileDefinition {
+
+ /**
+ * Gets the papyrus annotation.
+ *
+ * @return the papyrus annotation
+ */
+ public PapyrusDefinitionAnnotation getPapyrusAnnotation();
+
+ /**
+ * Save constraint.
+ *
+ * @return true, if successful
+ */
+ public boolean saveConstraintDefinition();
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/PapyrusProfileDefinition.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/PapyrusProfileDefinition.java
new file mode 100644
index 00000000000..f96f908fdbb
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/PapyrusProfileDefinition.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.tools.util;
+
+import org.eclipse.papyrus.uml.tools.profile.definition.PapyrusDefinitionAnnotation;
+
+/**
+ * Class for Papyrus Profile definition.
+ *
+ * @since 4.2
+ */
+public class PapyrusProfileDefinition implements IPapyrusProfileDefinition {
+
+ /** The annotation. */
+ private final PapyrusDefinitionAnnotation annotation;
+
+ /** The save constraint definition. */
+ private final boolean saveConstraintDefinition;
+
+
+ /**
+ * Instantiates a new papyrus profile definition.
+ *
+ * @param papyrusDefinitionAnnotation
+ * the papyrus definition annotation.
+ * @param saveConstraint
+ * the save constraint.
+ */
+ public PapyrusProfileDefinition(final PapyrusDefinitionAnnotation papyrusDefinitionAnnotation, final boolean saveConstraint) {
+ annotation = papyrusDefinitionAnnotation;
+ saveConstraintDefinition = saveConstraint;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.tools.util.IPapyrusProfileDefinition#getPapyrusAnnotation()
+ */
+ @Override
+ public PapyrusDefinitionAnnotation getPapyrusAnnotation() {
+ return annotation;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.tools.util.IPapyrusProfileDefinition#saveConstraintDefinition()
+ */
+ @Override
+ public boolean saveConstraintDefinition() {
+ return saveConstraintDefinition;
+ }
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/tests/DefineProfileCommandTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/tests/DefineProfileCommandTest.java
index 9ad1ac9836b..3313d712dc8 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/tests/DefineProfileCommandTest.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile.tests/src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/tests/DefineProfileCommandTest.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2014 Christian W. Damus and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*
* Contributors:
* Christian W. Damus - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.profile.custom.commands.tests;
@@ -22,13 +22,13 @@ import static org.hamcrest.MatcherAssert.assertThat;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.eclipse.papyrus.junit.utils.rules.ModelSetFixture;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
-import org.eclipse.papyrus.uml.diagram.profile.custom.commands.DefineProfileCommand;
+import org.eclipse.papyrus.uml.tools.commands.DefineProfileCommand;
import org.eclipse.papyrus.uml.tools.profile.definition.PapyrusDefinitionAnnotation;
import org.eclipse.papyrus.uml.tools.profile.definition.Version;
+import org.eclipse.papyrus.uml.tools.util.PapyrusProfileDefinition;
import org.eclipse.uml2.uml.Profile;
import org.junit.Rule;
import org.junit.Test;
@@ -80,8 +80,8 @@ public class DefineProfileCommandTest extends AbstractPapyrusTest {
void executeDefineCommand(Profile profile, String version) {
PapyrusDefinitionAnnotation annotation = new PapyrusDefinitionAnnotation(Version.parseVersion(version), "", "", "", "");
- DefineProfileCommand command = new DefineProfileCommand(modelSet.getEditingDomain(), annotation, profile, true);
- modelSet.getEditingDomain().getCommandStack().execute(GMFtoEMFCommandWrapper.wrap(command));
+ DefineProfileCommand command = new DefineProfileCommand(modelSet.getEditingDomain(), new PapyrusProfileDefinition(annotation, true), profile);
+ modelSet.getEditingDomain().getCommandStack().execute(command);
}
static EAnnotation getUMLAnnotation(ENamedElement namedElement) {

Back to the top