Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFanch BONNABESSE2016-09-15 10:18:30 -0400
committerGerrit Code Review @ Eclipse.org2016-09-30 06:54:28 -0400
commitd0d15ba0b89d384a0a1937799da0cdacb8e37aa6 (patch)
tree95b6622578f20b90cf5fccce65e5cf856d5ad43e /plugins
parent76cf97689ddc3334970178550d90655cc402701f (diff)
downloadorg.eclipse.papyrus-d0d15ba0b89d384a0a1937799da0cdacb8e37aa6.tar.gz
org.eclipse.papyrus-d0d15ba0b89d384a0a1937799da0cdacb8e37aa6.tar.xz
org.eclipse.papyrus-d0d15ba0b89d384a0a1937799da0cdacb8e37aa6.zip
Bug 500642: [Class Diagram] Property views shall be updated after a
semantic move https://bugs.eclipse.org/bugs/show_bug.cgi?id=500642 Delete inconsistent views during a move of a Property on the ModelExplorer view. Same treatment for Operations and NestClassifiers. Add of JUnit tests. Change-Id: I63767c7f51f075972bbfa9142dd77673445da8e1 Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ClassifierHelperAdvice.java41
1 files changed, 37 insertions, 4 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ClassifierHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ClassifierHelperAdvice.java
index 4ff53bcde22..73671629247 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ClassifierHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ClassifierHelperAdvice.java
@@ -9,7 +9,7 @@
* Contributors:
*
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 476873, 481317
+ * Fanch Bonnabesse (ALL4TEC) fanch.bonnabesse@alltec.net - Bug 476873, 481317, 500642
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;
@@ -45,6 +45,7 @@ import org.eclipse.papyrus.uml.service.types.utils.RequestParameterConstants;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.ConnectorEnd;
+import org.eclipse.uml2.uml.Feature;
import org.eclipse.uml2.uml.Generalization;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Port;
@@ -246,8 +247,10 @@ public class ClassifierHelperAdvice extends AbstractEditHelperAdvice {
final EObject eObject = it.next();
if (eObject instanceof Generalization) {
- viewsToDestroy.addAll(getViewsToDestroy((Generalization) eObject));
+ viewsToDestroy.addAll(getViewsToDestroy(eObject));
viewsToDestroy.addAll(getViewsAccordingToGeneralization((Generalization) eObject));
+ } else if (eObject instanceof Feature || eObject instanceof Classifier) {
+ viewsToDestroy.addAll(getViewsAccordingToEObject(eObject, request.getTargetContainer()));
}
}
@@ -265,11 +268,11 @@ public class ClassifierHelperAdvice extends AbstractEditHelperAdvice {
* This methods looks for inconsistent views to delete in case the Classifier or a child is deleted or
* re-oriented.
*
- * @param object
+ * @param movedObject
* the modified Classifier
* @return the list of {@link View} to delete
*/
- private Set<View> getViewsToDestroy(final Generalization movedObject) {
+ private Set<View> getViewsToDestroy(final EObject movedObject) {
Set<View> viewsToDestroy = new HashSet<View>();
final Iterator<View> viewIt = CrossReferencerUtil.getCrossReferencingViews(movedObject, null).iterator();
@@ -318,4 +321,34 @@ public class ClassifierHelperAdvice extends AbstractEditHelperAdvice {
return viewsToDestroy;
}
+
+ /**
+ * This method returns a list of views to be deleted after a move of a Property.
+ *
+ * @param property
+ * The Property
+ * @param targetContainer
+ * The target container of the move.
+ * @return The list of view to delete.
+ */
+ protected Set<View> getViewsAccordingToEObject(final EObject property, final EObject targetContainer) {
+ Set<View> viewsToDestroy = new HashSet<View>();
+ if (targetContainer instanceof Classifier) {
+ for (View view : getViewsToDestroy(property)) {
+ View containerView = ViewUtil.getContainerView(view);
+ if (null != containerView) {
+ EObject containerSemanticElement = ViewUtil.resolveSemanticElement(containerView);
+ if (containerSemanticElement instanceof Classifier) {
+ if (!containerSemanticElement.equals(targetContainer)) {
+ EList<Classifier> allParents = ((Classifier) containerSemanticElement).allParents();
+ if (!allParents.contains(targetContainer)) {
+ viewsToDestroy.add(view);
+ }
+ }
+ }
+ }
+ }
+ }
+ return viewsToDestroy;
+ }
}

Back to the top