Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2018-11-12 09:41:28 +0000
committerPatrick Tessier2019-01-18 17:59:35 +0000
commit5e61a5490724d2ddf52caf45af21744482e8ada8 (patch)
tree9b4050c2a69eec4a77f2ef8f429e6fdda6dda340 /plugins/uml/properties
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>
Diffstat (limited to 'plugins/uml/properties')
-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
4 files changed, 264 insertions, 14 deletions
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;
+ }
+}

Back to the top