Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2019-08-01 03:59:33 -0400
committervincent lorenzo2019-08-22 08:42:50 -0400
commit5c5a7ce5063b1a82749b8cbca2b38c03a7934641 (patch)
tree1944d0fe7c3d0974c15846caa0b3537628cec1a2 /plugins
parent608d7afe93439e73e91518094c56e8ab6cddea7f (diff)
downloadorg.eclipse.papyrus-5c5a7ce5063b1a82749b8cbca2b38c03a7934641.tar.gz
org.eclipse.papyrus-5c5a7ce5063b1a82749b8cbca2b38c03a7934641.tar.xz
org.eclipse.papyrus-5c5a7ce5063b1a82749b8cbca2b38c03a7934641.zip
Bug 549705: [Properties View] The stereotype properties modified by
properties view does not use the correct request Manage the stereotypes properties with SetStereotypeValueRequest instead of SetRequest for the properties view. With this, we can use element types of stereotype properties. + Manage it while keeping the API. Change-Id: I709ee5154bb966926f0f091e3516780df60ac686 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF2
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml2
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/utils/EStructuralFeatureUtil.java13
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.types.core/META-INF/MANIFEST.MF7
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.types.core/pom.xml2
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.types.core/src/org/eclipse/papyrus/uml/types/core/advices/settype/SetTypeAdviceEditHelperAdvice.java35
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF5
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypePropertyObservableList.java90
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypePropertyObservableValue.java129
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java27
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java170
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java13
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeEStructuralFeatureEditor.java110
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java18
15 files changed, 568 insertions, 57 deletions
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF
index 5c33d841f44..543ad095645 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.papyrus.toolsmiths.profilemigration.ui;singleton:=true
-Bundle-Version: 0.8.0.qualifier
+Bundle-Version: 0.8.100.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.ui,
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml
index d9c63cc4812..487cc530c45 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.toolsmiths.profilemigration.ui</artifactId>
- <version>0.8.0-SNAPSHOT</version>
+ <version>0.8.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/utils/EStructuralFeatureUtil.java b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/utils/EStructuralFeatureUtil.java
index d4b81d21987..f01c2e691c7 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/utils/EStructuralFeatureUtil.java
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/utils/EStructuralFeatureUtil.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2017 CEA LIST.
+ * Copyright (c) 2017, 2019 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
*
* Contributors:
* Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 549705
*
*****************************************************************************/
@@ -45,12 +46,12 @@ public class EStructuralFeatureUtil {
/**
* Change displayed values according to the new element
- *
+ *
* @param editor
* @param stereotypedElement
* @param property
* @param stereotype
- *
+ *
*/
public static void setValueToEditor(EStructuralFeatureEditor editor, Element stereotypedElement, Property property, Stereotype stereotype) {
EObject stereotypeApplication = stereotypedElement.getStereotypeApplication(stereotype);
@@ -60,13 +61,13 @@ public class EStructuralFeatureUtil {
editor.setValueFactory(getUMLPropertyEditorFactory(stereotypeApplication, (EReference) structuralFeature));
}
- editor.setFeatureToEdit(property.getName(), structuralFeature, stereotypeApplication);
+ editor.setFeatureToEdit(property.getName(), structuralFeature, stereotypedElement, stereotypeApplication);
}
/**
* Get the structural feature according to the stereotype application and the property
- *
+ *
* @param stereotypeApplication
* @return
*/
@@ -76,7 +77,7 @@ public class EStructuralFeatureUtil {
/**
* Get an UMLPropertyEditorFactory
- *
+ *
* @param stereotypeApplication
* @param reference
* @return
diff --git a/plugins/uml/org.eclipse.papyrus.uml.types.core/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.types.core/META-INF/MANIFEST.MF
index 66d97901610..6dd2f0b5d15 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.types.core/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.types.core/META-INF/MANIFEST.MF
@@ -1,6 +1,5 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.uml2.uml.edit;bundle-version="[5.3.0,6.0.0)";visibility:=reexport,
- org.eclipse.papyrus.uml.properties;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.views.properties;bundle-version="[4.0.0,5.0.0)",
org.eclipse.papyrus.infra.types.rulebased;bundle-version="[4.0.0,5.0.0)",
org.eclipse.papyrus.infra.emf.types;bundle-version="[4.0.0,5.0.0)",
@@ -12,7 +11,9 @@ Require-Bundle: org.eclipse.uml2.uml.edit;bundle-version="[5.3.0,6.0.0)";visibil
org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.types.edit;bundle-version="[4.0.0,5.0.0)",
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.100,2.0.0)",
- org.eclipse.papyrus.infra.types.core;bundle-version="[4.0.0,5.0.0)"
+ org.eclipse.papyrus.infra.types.core;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="[3.3.0,4.0.0)"
Export-Package: org.eclipse.papyrus.uml.types.core,
org.eclipse.papyrus.uml.types.core.advices.applystereotype,
org.eclipse.papyrus.uml.types.core.advices.applystereotype.impl,
@@ -41,7 +42,7 @@ Export-Package: org.eclipse.papyrus.uml.types.core,
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
-Bundle-Version: 4.0.0.qualifier
+Bundle-Version: 4.1.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-ManifestVersion: 2
diff --git a/plugins/uml/org.eclipse.papyrus.uml.types.core/pom.xml b/plugins/uml/org.eclipse.papyrus.uml.types.core/pom.xml
index 4881f967c15..189fef26fc9 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.types.core/pom.xml
+++ b/plugins/uml/org.eclipse.papyrus.uml.types.core/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.types.core</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.types.core/src/org/eclipse/papyrus/uml/types/core/advices/settype/SetTypeAdviceEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.types.core/src/org/eclipse/papyrus/uml/types/core/advices/settype/SetTypeAdviceEditHelperAdvice.java
index ccaeddbcf7c..500dd47d3c0 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.types.core/src/org/eclipse/papyrus/uml/types/core/advices/settype/SetTypeAdviceEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.types.core/src/org/eclipse/papyrus/uml/types/core/advices/settype/SetTypeAdviceEditHelperAdvice.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2019 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,16 +10,19 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 549705
*
*****************************************************************************/
package org.eclipse.papyrus.uml.types.core.advices.settype;
import java.util.Arrays;
+import java.util.Optional;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
@@ -28,12 +31,17 @@ import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCo
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.papyrus.infra.properties.contexts.Context;
+import org.eclipse.papyrus.infra.properties.contexts.DataContextRoot;
+import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElement;
+import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElementFactory;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
-import org.eclipse.papyrus.uml.properties.modelelement.UMLModelElement;
import org.eclipse.papyrus.uml.types.core.Activator;
import org.eclipse.papyrus.uml.types.core.advices.applystereotype.ApplyStereotypeAdviceConfiguration;
+import org.eclipse.papyrus.views.properties.runtime.ConfigurationManager;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Element;
@@ -86,17 +94,30 @@ public class SetTypeAdviceEditHelperAdvice extends AbstractEditHelperAdvice {
// retrieve edit service to get features from configure command
IElementEditService service = ElementEditServiceUtils.getCommandProvider(elementToConfigure);
if (service == null) {
- Activator.log.error("Impossible to get edit service from element: " + elementToConfigure, null);
+ Activator.log.error("Impossible to get edit service from element: " + elementToConfigure, null); //$NON-NLS-1$
return null;
}
- resultCommand = new AbstractTransactionalCommand(editingDomain, "Editing type", Arrays.asList((WorkspaceSynchronizer.getFile(elementToConfigure.eResource())))) {
+ resultCommand = new AbstractTransactionalCommand(editingDomain, "Editing type", Arrays.asList((WorkspaceSynchronizer.getFile(elementToConfigure.eResource())))) { //$NON-NLS-1$
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- UMLModelElement umlModelElement = new UMLModelElement(elementToConfigure, editingDomain);
- ReferenceValueFactory factory = umlModelElement.getValueFactory("type");
- Object elemObject = factory.edit(Display.getDefault().getFocusControl(), elementToConfigure);
+ Object elemObject = null;
+
+ final Context context = ConfigurationManager.getInstance().getContext("UML"); //$NON-NLS-1$
+ if (null != context) {
+ Optional<DataContextRoot> umlDataContextFilter = context.getDataContexts().stream().filter(dc -> "UML".equals(dc.getName())).findFirst(); //$NON-NLS-1$
+ DataContextRoot umlDataContext = umlDataContextFilter.isPresent() ? umlDataContextFilter.get() : null;
+
+ if (null != umlDataContext) {
+ final String factoryName = umlDataContext.getModelElementFactory().getFactoryClass();
+ final ModelElementFactory modelElementFactory = ClassLoaderHelper.newInstance(factoryName, ModelElementFactory.class, EcoreUtil.getURI(context));
+
+ final ModelElement umlModelElement = modelElementFactory.createFromSource(elementToConfigure, umlDataContext);
+ final ReferenceValueFactory factory = umlModelElement.getValueFactory("type"); //$NON-NLS-1$
+ elemObject = factory.edit(Display.getDefault().getFocusControl(), elementToConfigure);
+ }
+ }
return CommandResult.newOKCommandResult(elemObject);
}
};
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
index 0fed91180c7..5135caf81cc 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
@@ -37,10 +37,11 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)";v
org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)",
org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)",
org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)"
+ org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.papyrus.uml.types.core;bundle-version="[4.0.0,5.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.papyrus.uml.properties.constraints"
-Bundle-Version: 3.3.0.qualifier
+Bundle-Version: 3.4.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.papyrus.uml.properties.Activator
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
index 5181fba14ce..5f7e46e4ce1 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.properties</artifactId>
- <version>3.3.0-SNAPSHOT</version>
+ <version>3.4.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/src/org/eclipse/papyrus/uml/properties/databinding/StereotypePropertyObservableList.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypePropertyObservableList.java
new file mode 100644
index 00000000000..e4de9cd961e
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypePropertyObservableList.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2019 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
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.properties.databinding;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList;
+import org.eclipse.papyrus.uml.types.core.requests.SetStereotypeValueRequest;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * The observable list for the stereotype property.
+ */
+public class StereotypePropertyObservableList extends GMFObservableList {
+
+ /**
+ * The stereotype of the stereotype application to edit.
+ */
+ private Stereotype stereotype;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param wrappedList
+ * The list to be edited when #commit() is called
+ * @param domain
+ * The editing domain on which the commands will be executed
+ * @param source
+ * The EObject from which the list will be retrieved
+ * @param feature
+ * The feature from which the list will be retrieved
+ * @param stereotype
+ * The stereotype to manage.
+ */
+ public StereotypePropertyObservableList(final List<?> wrappedList, final EditingDomain domain, final EObject source, final EStructuralFeature feature, final Stereotype stereotype) {
+ super(wrappedList, domain, source, feature);
+ this.stereotype = stereotype;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.services.edit.ui.databinding.PapyrusObservableList#getRequests(java.util.List, java.util.Collection)
+ */
+ @Override
+ protected Collection<? extends IEditCommandRequest> getRequests(List<Object> newValues, Collection<?> removedValues) {
+ LinkedList<IEditCommandRequest> requests = new LinkedList<>();
+
+ if (feature instanceof EReference && ((EReference) feature).isContainment() && removedValues != null) {
+ for (Object o : removedValues) {
+ if (o instanceof EObject) {
+ requests.add(new DestroyElementRequest((TransactionalEditingDomain) editingDomain, (EObject) o, false));
+ }
+ }
+ }
+
+ if (source instanceof Element) {
+ requests.add(new SetStereotypeValueRequest((TransactionalEditingDomain) editingDomain, stereotype, (Element) source, feature.getName(), newValues));
+ } else {
+ requests.add(new SetRequest((TransactionalEditingDomain) editingDomain, source, feature, newValues));
+ }
+ return requests;
+ }
+
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypePropertyObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypePropertyObservableValue.java
new file mode 100644
index 00000000000..a368ae209ed
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/StereotypePropertyObservableValue.java
@@ -0,0 +1,129 @@
+/*****************************************************************************
+ * Copyright (c) 2019 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
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.properties.databinding;
+
+import org.eclipse.core.databinding.observable.Realm;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue;
+import org.eclipse.papyrus.uml.types.core.requests.SetStereotypeValueRequest;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * The observable value for the stereotype property.
+ */
+public class StereotypePropertyObservableValue extends GMFObservableValue {
+
+ /**
+ * The stereotype of the stereotype application to edit.
+ */
+ private Stereotype stereotype;
+
+ /**
+ * Boolean to determinate if the command is managed by a SetStereotypeRequest or not.
+ */
+ private boolean isSetStereotypeRequest;
+
+ /**
+ * Constructor.
+ *
+ * @param eObject
+ * The EObject to edit.
+ * @param eStructuralFeature
+ * The structural feature to edit.
+ * @param domain
+ * The editing domain on which the commands will be executed.
+ * @param stereotype
+ * The stereotype applied to edit.
+ */
+ public StereotypePropertyObservableValue(final EObject eObject, final EStructuralFeature eStructuralFeature, final EditingDomain domain, final Stereotype stereotype) {
+ super(eObject, eStructuralFeature, domain);
+ this.stereotype = stereotype;
+ this.isSetStereotypeRequest = false;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param realm
+ * The realm.
+ * @param eObject
+ * The EObject to edit.
+ * @param eStructuralFeature
+ * The structural feature to edit.
+ * @param domain
+ * The editing domain on which the commands will be executed.
+ * @param stereotype
+ * The stereotype applied to edit.
+ */
+ public StereotypePropertyObservableValue(final Realm realm, final EObject eObject, final EStructuralFeature eStructuralFeature, final EditingDomain domain, final Stereotype stereotype) {
+ super(realm, eObject, eStructuralFeature, domain);
+ this.stereotype = stereotype;
+ this.isSetStereotypeRequest = false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.services.edit.ui.databinding.PapyrusObservableValue#createSetRequest(org.eclipse.emf.transaction.TransactionalEditingDomain, org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EStructuralFeature, java.lang.Object)
+ */
+ @Override
+ protected IEditCommandRequest createSetRequest(final TransactionalEditingDomain domain, final EObject owner, final EStructuralFeature feature, final Object value) {
+ if (owner instanceof Element) {
+ this.isSetStereotypeRequest = true;
+ return new SetStereotypeValueRequest(domain, stereotype, (Element) owner, feature.getName(), value);
+ }
+ return super.createSetRequest(domain, owner, feature, value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.services.edit.ui.databinding.PapyrusObservableValue#doSetValue(java.lang.Object)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void doSetValue(final Object value) {
+ this.isSetStereotypeRequest = false;
+ super.doSetValue(value);
+ if (isSetStereotypeRequest) {
+ // If the SetStereotypeRequest is used, the command to set value is not set by emf eSet method, so the listener is not managed
+ fireValueChange(null);
+ this.isSetStereotypeRequest = false;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.databinding.EObjectObservableValue#doGetValue()
+ */
+ @Override
+ protected Object doGetValue() {
+ if (eObject instanceof Element) {
+ final EObject stereotypeApplication = ((Element) eObject).getStereotypeApplication(stereotype);
+ if (null != stereotypeApplication) {
+ return stereotypeApplication.eGet(eStructuralFeature);
+ }
+ }
+ return super.doGetValue();
+ }
+
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
index edba9b48437..b0569621aed 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2017 CEA LIST.
+ * Copyright (c) 2013, 2017, 2019 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -13,6 +13,7 @@
* Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation
* Pierre GAUTIER (CEA LIST) - bug 521865
* Vincent LORENZO (CEA LIST) - bug 521861
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 549705
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -92,7 +93,7 @@ public class EObjectContentsEditor extends Composite {
/**
* listener to be be able to move the scrollbar with the mouse wheel
- *
+ *
*/
private final MouseWheelListener mouseWheelListener = new MouseWheelListener() {
@@ -150,6 +151,7 @@ public class EObjectContentsEditor extends Composite {
valueListener = new IChangeListener() {
+ @Override
public void handleChange(ChangeEvent event) {
updateContents();
}
@@ -157,6 +159,7 @@ public class EObjectContentsEditor extends Composite {
parent.addDisposeListener(new DisposeListener() {
+ @Override
public void widgetDisposed(DisposeEvent e) {
dispose();
}
@@ -216,12 +219,12 @@ public class EObjectContentsEditor extends Composite {
} else {
propertyEditor.setProviders(new UMLContentProvider(dataTypeInstance, feature), labelProvider);
}
-
+
if (feature instanceof EReference) {
propertyEditor.setValueFactory(getUMLPropertyEditorFactory(dataTypeInstance, (EReference) feature));
}
- propertyEditor.setFeatureToEdit(feature.getName(), feature, dataTypeInstance);
+ propertyEditor.setFeatureToEdit(feature.getName(), feature, null, dataTypeInstance);
}
}
@@ -235,7 +238,7 @@ public class EObjectContentsEditor extends Composite {
/**
* Register the mouse wheel listener for the control and its children
- *
+ *
* @param control
* a control
*/
@@ -250,7 +253,7 @@ public class EObjectContentsEditor extends Composite {
/**
* Unregister the mouse wheel listener for the control and its children
- *
+ *
* @param control
* a control
*/
@@ -278,10 +281,12 @@ public class EObjectContentsEditor extends Composite {
addButton.addSelectionListener(new SelectionListener() {
+ @Override
public void widgetSelected(SelectionEvent e) {
addAction();
}
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {
// Nothing
}
@@ -310,10 +315,12 @@ public class EObjectContentsEditor extends Composite {
deleteButton.addSelectionListener(new SelectionListener() {
+ @Override
public void widgetSelected(SelectionEvent e) {
deleteAction();
}
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {
//
}
@@ -337,19 +344,19 @@ public class EObjectContentsEditor extends Composite {
final Resource res = null != dataTypeInstance.eResource() ? dataTypeInstance.eResource() : null;
ResourceSet resourceSet = null != res ? res.getResourceSet() : null;
-
+
// the datatype is not always in a resource (when it just comes to be created, nevertheless, its EClass is always in a resource loaded in the ResourceSet
- if (null == resourceSet && null!=dataTypeInstance.eClass().eResource()) {
+ if (null == resourceSet && null != dataTypeInstance.eClass().eResource()) {
resourceSet = dataTypeInstance.eClass().eResource().getResourceSet();
}
-
+
final ITreeContentProvider contentProvider;
if (null != dataTypeInstance.eResource()) {
contentProvider = new UMLContainerContentProvider(dataTypeInstance, reference);
} else {
contentProvider = new UMLContainerContentProvider(dataTypeInstance, reference, resourceSet);
}
-
+
EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, resourceSet, HistoryUtil.getHistoryID(dataTypeInstance, reference, "container")); //$NON-NLS-1$
factory.setContainerContentProvider(provider);
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
index d8f66672ce5..b82c49dcaab 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012, 2014, 2017 Atos, CEA, and others.
+ * Copyright (c) 2012, 2014, 2017, 2019 Atos, CEA, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,6 +15,7 @@
* Pierre GAUTIER (CEA LIST) - bug 521857
* Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 521902, Bug 526304
* Vincent LORENZO (CEA LIST) - bug 526900
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 549705
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -27,6 +28,7 @@ import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.list.IListChangeListener;
import org.eclipse.core.databinding.observable.list.ListChangeEvent;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.emf.ecore.EAttribute;
@@ -65,6 +67,7 @@ import org.eclipse.papyrus.uml.tools.utils.DataTypeUtil;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.PageBook;
+import org.eclipse.uml2.uml.Element;
/**
* A structural feature editor
@@ -159,7 +162,36 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
return new Composite(pageBook, style);
}
+ /**
+ * This allows to set the feature to edit to the current editor.
+ *
+ * @param title
+ * The title corresponding to the property.
+ * @param feature
+ * The feature to manage.
+ * @param element
+ * The stereotype application.
+ * @deprecated Use {@link #setFeatureToEdit(String, EStructuralFeature, Element, EObject)} instead.
+ */
+ @Deprecated
public void setFeatureToEdit(final String title, final EStructuralFeature feature, final EObject element) {
+ setFeatureToEdit(title, feature, null, element);
+ }
+
+ /**
+ * This allows to set the feature to edit to the current editor.
+ *
+ * @param title
+ * The title corresponding to the property.
+ * @param feature
+ * The feature to manage.
+ * @param owner
+ * The owner element.
+ * @param stereotypeApplication
+ * The stereotype application.
+ * @since 3.4
+ */
+ public void setFeatureToEdit(final String title, final EStructuralFeature feature, final Element owner, final EObject stereotypeApplication) {
Composite previousPage = this.currentPage;
if (currentPage != null) {
currentPage = null;
@@ -168,19 +200,19 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
if (feature instanceof EReference) {
if (feature.isMany()) {
final MultipleReferenceEditor editor = new MultipleReferenceEditor(pageBook, style);
- setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, title, feature);
+ setMultipleValueEditorProperties(editor, (List<?>) stereotypeApplication.eGet(feature), stereotypeApplication, owner, title, feature);
editor.setProviders(contentProvider, labelProvider);
editor.setFactory(valueFactory);
currentPage = editor;
} else {
final EClassifier featureType = feature.getEType();
- if (featureType instanceof EClass && DataTypeUtil.isDataTypeDefinition((EClass) featureType, element)) {
+ if (featureType instanceof EClass && DataTypeUtil.isDataTypeDefinition((EClass) featureType, stereotypeApplication)) {
final EObjectContentsEditor editor = new EObjectContentsEditor(pageBook, style, (EReference) feature);
- editor.setValue(new GMFObservableValue(element, feature, EMFHelper.resolveEditingDomain(element)));
+ editor.setValue(getReferenceObservableValue((EReference) feature, stereotypeApplication, owner));
currentPage = editor;
} else {
final ReferenceDialog editor = new ReferenceDialog(pageBook, style);
- setValueEditorProperties(editor, element, title, feature);
+ setValueEditorProperties(editor, stereotypeApplication, owner, title, feature);
editor.setContentProvider(contentProvider);
editor.setLabelProvider(labelProvider);
editor.setValueFactory(valueFactory);
@@ -195,13 +227,13 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
if (featureType instanceof EEnum) {
if (feature.isMany()) {
final MultipleReferenceEditor editor = new MultipleReferenceEditor(pageBook, style);
- setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, title, feature);
+ setMultipleValueEditorProperties(editor, (List<?>) stereotypeApplication.eGet(feature), stereotypeApplication, owner, title, feature);
editor.setProviders(contentProvider, labelProvider);
editor.setFactory(valueFactory);
currentPage = editor;
} else {
final EnumCombo editor = new EnumCombo(pageBook, style);
- setValueEditorProperties(editor, element, title, feature);
+ setValueEditorProperties(editor, stereotypeApplication, owner, title, feature);
editor.setContentProvider(new EMFEnumeratorContentProvider(feature));
currentPage = editor;
}
@@ -212,9 +244,9 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
throw new IllegalArgumentException("No clazz has been found for aliasedInstanceClassName '" + aliasedInstanceClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (feature.isMany()) {
- createMultipleEditor(clazz, element, title, feature);
+ createMultipleEditor(clazz, stereotypeApplication, owner, title, feature);
} else {
- createSingleEditor(clazz, element, title, feature);
+ createSingleEditor(clazz, stereotypeApplication, owner, title, feature);
}
}
}
@@ -227,7 +259,56 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
previousPage = null;
}
+ /**
+ * Get the observable value for a reference property.
+ *
+ * @param feature
+ * the reference feature.
+ * @param stereotypeApplication
+ * The stereotype application.
+ * @param owner
+ * The owner element.
+ * @return The observable value.
+ * @since 3.4
+ */
+ protected IObservableValue<?> getReferenceObservableValue(final EReference feature, final EObject stereotypeApplication, final Element owner) {
+ return new GMFObservableValue(stereotypeApplication, feature, EMFHelper.resolveEditingDomain(stereotypeApplication));
+ }
+
+ /**
+ * This allows to set the observable value for the editor.
+ *
+ * @param editor
+ * The value editor to manage.
+ * @param stereotypeApplication
+ * The stereotype application
+ * @param title
+ * The title corresponding to the property.
+ * @param feature
+ * The feature to manage.
+ * @deprecated Use {@link #setValueEditorProperties(AbstractValueEditor, EObject, Element, String, EStructuralFeature)} instead.
+ */
+ @Deprecated
protected void setValueEditorProperties(final AbstractValueEditor editor, final EObject stereotypeApplication, final String title, final EStructuralFeature feature) {
+ setValueEditorProperties(editor, stereotypeApplication, null, title, feature);
+ }
+
+ /**
+ * This allows to set the observable value for the editor.
+ *
+ * @param editor
+ * The value editor to manage.
+ * @param stereotypeApplication
+ * The stereotype application
+ * @param owner
+ * The owner element.
+ * @param title
+ * The title corresponding to the property.
+ * @param feature
+ * The feature to manage.
+ * @since 3.4
+ */
+ protected void setValueEditorProperties(final AbstractValueEditor editor, final EObject stereotypeApplication, final Element owner, final String title, final EStructuralFeature feature) {
final GMFObservableValue observable = new GMFObservableValue(stereotypeApplication, feature, EMFHelper.resolveEditingDomain(stereotypeApplication));
observable.addValueChangeListener(this);
editor.setLabel(title);
@@ -235,7 +316,42 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
editor.setModelObservable(observable);
}
+ /**
+ * This allows to set the observable list for the editor.
+ *
+ * @param editor
+ * The multiple value editor to manage.
+ * @param initialList
+ * The initial list to manage.
+ * @param stereotypeApplication
+ * The stereotype application
+ * @param title
+ * The title corresponding to the property.
+ * @param feature
+ * The feature to manage.
+ * @deprecated Use {@link #setMultipleValueEditorProperties(MultipleValueEditor, List, EObject, Element, String, EStructuralFeature)} instead.
+ */
+ @Deprecated
protected void setMultipleValueEditorProperties(final MultipleValueEditor<?> editor, final List<?> initialList, final EObject stereotypeApplication, final String title, final EStructuralFeature feature) {
+ setMultipleValueEditorProperties(editor, initialList, stereotypeApplication, null, title, feature);
+ }
+
+ /**
+ * This allows to set the observable list for the editor.
+ *
+ * @param editor
+ * The multiple value editor to manage.
+ * @param initialList
+ * The initial list to manage.
+ * @param stereotypeApplication
+ * The stereotype application
+ * @param title
+ * The title corresponding to the property.
+ * @param feature
+ * The feature to manage.
+ * @since 3.4
+ */
+ protected void setMultipleValueEditorProperties(final MultipleValueEditor<?> editor, final List<?> initialList, final EObject stereotypeApplication, final Element owner, final String title, final EStructuralFeature feature) {
final GMFObservableList observable = new GMFObservableList(initialList, EMFHelper.resolveEditingDomain(stereotypeApplication), stereotypeApplication, feature);
observable.addListChangeListener(this);
editor.setLabel(title);
@@ -250,7 +366,21 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
editor.addCommitListener(observable);
}
- private void createMultipleEditor(final Class<?> typeClass, final EObject element, final String title, final EStructuralFeature feature) {
+ /**
+ * This allows to create the multiple value editor to manage lists (it also create the correct observable list).
+ *
+ * @param typeClass
+ * The type of class to manage.
+ * @param stereotypeApplication
+ * The stereotype application.
+ * @param owner
+ * The owner element.
+ * @param title
+ * The title corresponding to the property.
+ * @param feature
+ * The feature to manage.
+ */
+ private void createMultipleEditor(final Class<?> typeClass, final EObject stereotypeApplication, final Element owner, final String title, final EStructuralFeature feature) {
final Class<? extends MultipleStringEditor<?>> editorClazz = EStructuralFeatureEditor.TYPE_TO_MULTI_EDITOR_CLASS.get(typeClass);
if (editorClazz == null) {
throw new IllegalArgumentException("No multiple editor has been found for class '" + typeClass + "'"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -258,14 +388,28 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
try {
final Constructor<? extends MultipleStringEditor<?>> constructor = editorClazz.getConstructor(Composite.class, boolean.class, boolean.class, int.class);
final MultipleStringEditor<?> editor = constructor.newInstance(pageBook, true, true, style);
- setMultipleValueEditorProperties(editor, (List<?>) element.eGet(feature), element, title, feature);
+ setMultipleValueEditorProperties(editor, (List<?>) stereotypeApplication.eGet(feature), stereotypeApplication, owner, title, feature);
currentPage = editor;
} catch (final Exception e) {
Activator.log.error(e);
}
}
- private void createSingleEditor(final Class<?> typeClass, final EObject element, final String title, final EStructuralFeature feature) {
+ /**
+ * This allows to create the single value editor to manage lists (it also create the correct observable list).
+ *
+ * @param typeClass
+ * The type of class to manage.
+ * @param stereotypeApplication
+ * The stereotype application.
+ * @param owner
+ * The owner element.
+ * @param title
+ * The title corresponding to the property.
+ * @param feature
+ * The feature to manage.
+ */
+ private void createSingleEditor(final Class<?> typeClass, final EObject stereotypeApplication, final Element owner, final String title, final EStructuralFeature feature) {
final Class<? extends AbstractValueEditor> clazz = EStructuralFeatureEditor.TYPE_TO_SINGLE_EDITOR_CLASS.get(typeClass);
if (clazz == null) {
throw new IllegalArgumentException("No single editor has been found for class '" + typeClass + "'"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -273,7 +417,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I
try {
final Constructor<? extends AbstractValueEditor> constructor = clazz.getConstructor(Composite.class, int.class);
final AbstractValueEditor editor = constructor.newInstance(pageBook, style);
- setValueEditorProperties(editor, element, title, feature);
+ setValueEditorProperties(editor, stereotypeApplication, owner, title, feature);
currentPage = editor;
} catch (final Exception e) {
Activator.log.error(e);
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java
index 2041b2930cb..b443377fd40 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/GenericUMLDatatypeEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2017 CEA LIST.
+ * Copyright (c) 2013, 2017, 2019 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -12,6 +12,7 @@
* Contributors:
* Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation
* Vincent Lorenzo (CEA LIST) - bug 521861
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 549705
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -123,13 +124,13 @@ public class GenericUMLDatatypeEditor extends AbstractPropertyEditor {
} else {
propertyEditor.setProviders(new UMLContentProvider(dataTypeInstance, feature), labelProvider);
}
-
+
if (feature instanceof EReference) {
propertyEditor.setValueFactory(getUMLPropertyEditorFactory(dataTypeInstance, (EReference) feature));
}
- propertyEditor.setFeatureToEdit(feature.getName(), feature, dataTypeInstance);
+ propertyEditor.setFeatureToEdit(feature.getName(), feature, null, dataTypeInstance);
}
}
}
@@ -143,12 +144,12 @@ public class GenericUMLDatatypeEditor extends AbstractPropertyEditor {
final Resource res = null != dataTypeInstance.eResource() ? dataTypeInstance.eResource() : null;
ResourceSet resourceSet = null != res ? res.getResourceSet() : null;
-
+
// the datatype is not always in a resource (when it just comes to be created, nevertheless, its EClass is always in a resource loaded in the ResourceSet
- if (null == resourceSet && null!=dataTypeInstance.eClass().eResource()) {
+ if (null == resourceSet && null != dataTypeInstance.eClass().eResource()) {
resourceSet = dataTypeInstance.eClass().eResource().getResourceSet();
}
-
+
final ITreeContentProvider contentProvider;
if (null != dataTypeInstance.eResource()) {
contentProvider = new UMLContainerContentProvider(dataTypeInstance, reference);
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeEStructuralFeatureEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeEStructuralFeatureEditor.java
new file mode 100644
index 00000000000..95e1833633e
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeEStructuralFeatureEditor.java
@@ -0,0 +1,110 @@
+/*****************************************************************************
+ * Copyright (c) 2019 CEA LIST.
+ *
+ * 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:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.widgets;
+
+import java.util.List;
+
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor;
+import org.eclipse.papyrus.infra.widgets.editors.MultipleValueEditor;
+import org.eclipse.papyrus.uml.properties.databinding.StereotypePropertyObservableList;
+import org.eclipse.papyrus.uml.properties.databinding.StereotypePropertyObservableValue;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * A structural feature editor for stereotype properties.
+ */
+@SuppressWarnings("unchecked")
+public class StereotypeEStructuralFeatureEditor extends EStructuralFeatureEditor {
+
+ /**
+ * Store the stereotype to edit.
+ */
+ private Stereotype stereotype;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * The parent composite.
+ * @param style
+ * The editor style.
+ */
+ public StereotypeEStructuralFeatureEditor(final Composite parent, final int style) {
+ super(parent, style);
+ }
+
+ /**
+ * Set the stereotype to manage.
+ *
+ * @param stereotype
+ * The stereotype to manage.
+ */
+ public void setStereotype(final Stereotype stereotype) {
+ this.stereotype = stereotype;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.properties.widgets.EStructuralFeatureEditor#getReferenceObservableValue(org.eclipse.emf.ecore.EReference, org.eclipse.emf.ecore.EObject, org.eclipse.uml2.uml.Element)
+ */
+ @Override
+ protected IObservableValue<?> getReferenceObservableValue(EReference feature, EObject stereotypeApplication, Element owner) {
+ return new StereotypePropertyObservableValue(owner, feature, EMFHelper.resolveEditingDomain(stereotypeApplication), stereotype);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.properties.widgets.EStructuralFeatureEditor#setValueEditorProperties(org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor, org.eclipse.emf.ecore.EObject, java.lang.String, org.eclipse.emf.ecore.EStructuralFeature)
+ */
+ @Override
+ protected void setValueEditorProperties(final AbstractValueEditor editor, final EObject stereotypeApplication, final Element owner, final String title, final EStructuralFeature feature) {
+ final StereotypePropertyObservableValue observable = new StereotypePropertyObservableValue(owner, feature, EMFHelper.resolveEditingDomain(stereotypeApplication), stereotype);
+ observable.addValueChangeListener(this);
+ editor.setLabel(title);
+ editor.setReadOnly(!isEditable(stereotypeApplication, feature));
+ editor.setModelObservable(observable);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.properties.widgets.EStructuralFeatureEditor#setMultipleValueEditorProperties(org.eclipse.papyrus.infra.widgets.editors.MultipleValueEditor, java.util.List, org.eclipse.emf.ecore.EObject, org.eclipse.uml2.uml.Element,
+ * java.lang.String, org.eclipse.emf.ecore.EStructuralFeature)
+ */
+ @Override
+ protected void setMultipleValueEditorProperties(final MultipleValueEditor<?> editor, final List<?> initialList, final EObject stereotypeApplication, final Element owner, final String title, final EStructuralFeature feature) {
+ final StereotypePropertyObservableList observable = new StereotypePropertyObservableList(initialList, EMFHelper.resolveEditingDomain(stereotypeApplication), owner, feature, stereotype);
+ observable.addListChangeListener(this);
+ editor.setLabel(title);
+ editor.setUnique(feature.isUnique());
+ editor.setOrdered(feature.isOrdered());
+ editor.setUpperBound(feature.getUpperBound());
+ editor.setModelObservable(observable);
+ editor.setReadOnly(!isEditable(stereotypeApplication, feature));
+ if (feature instanceof EReference) {
+ editor.setDirectCreation(((EReference) feature).isContainment());
+ }
+ editor.addCommitListener(observable);
+ }
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java
index 5dd3e96eb71..fde60db0616 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypePropertyEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012, 2014 Atos, CEA, and others.
+ * Copyright (c) 2012, 2014, 2019 Atos, CEA, 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,7 +11,8 @@
* Contributors:
* Mathieu Velten (Atos) mathieu.velten@atos.net - Initial API and implementation
* Christian W. Damus (CEA) - bug 448139
- *
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 549705
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -42,11 +43,12 @@ import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
public class StereotypePropertyEditor implements ISelectionChangedListener, IChangeListener {
- protected EStructuralFeatureEditor eStructuralFeatureEditor;
+ protected StereotypeEStructuralFeatureEditor eStructuralFeatureEditor;
protected AppliedStereotypeCompositeWithView stereotypeComposite;
@@ -54,10 +56,11 @@ public class StereotypePropertyEditor implements ISelectionChangedListener, ICha
public StereotypePropertyEditor(Composite parent, int style, AppliedStereotypeCompositeWithView stereotypeComposite) {
this.stereotypeComposite = stereotypeComposite;
- eStructuralFeatureEditor = new EStructuralFeatureEditor(parent, style);
+ eStructuralFeatureEditor = new StereotypeEStructuralFeatureEditor(parent, style);
eStructuralFeatureEditor.setChangeListener(this);
}
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
if (event != null) {
IStructuredSelection structSelection = (IStructuredSelection) event.getSelection();
@@ -67,6 +70,7 @@ public class StereotypePropertyEditor implements ISelectionChangedListener, ICha
AppliedStereotypePropertyTreeObject pTO = (AppliedStereotypePropertyTreeObject) selection;
EObject stereotypeApplication = pTO.getStereotypeApplication();
+ Element owner = pTO.getElement();
EStructuralFeature feature = pTO.getFeature();
Stereotype stereotype = pTO.getStereotype();
@@ -77,14 +81,15 @@ public class StereotypePropertyEditor implements ISelectionChangedListener, ICha
labelProvider = new UMLLabelProvider();
}
+ eStructuralFeatureEditor.setStereotype(stereotype);
eStructuralFeatureEditor.setProviders(new UMLContentProvider(stereotypeApplication, feature, stereotype), labelProvider);
if (feature instanceof EReference) {
eStructuralFeatureEditor.setValueFactory(getUMLPropertyEditorFactory(stereotypeApplication, (EReference) feature));
}
- eStructuralFeatureEditor.setFeatureToEdit(pTO.getProperty().getName(), feature, stereotypeApplication);
+ eStructuralFeatureEditor.setFeatureToEdit(pTO.getProperty().getName(), feature, owner, stereotypeApplication);
} else {
- eStructuralFeatureEditor.setFeatureToEdit(null, null, null);
+ eStructuralFeatureEditor.setFeatureToEdit(null, null, null, null);
}
}
}
@@ -110,6 +115,7 @@ public class StereotypePropertyEditor implements ISelectionChangedListener, ICha
eStructuralFeatureEditor.setLayoutData(data);
}
+ @Override
public void handleChange(ChangeEvent event) {
if (!stereotypeComposite.isDisposed()) {
stereotypeComposite.refreshTreeViewer();

Back to the top