Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsboyko2014-08-07 13:27:39 -0400
committerCamille Letavernier2014-08-08 09:32:59 -0400
commit63d60e51b963bd707d3de6559caa72c22becd4e4 (patch)
tree2fa4881536fa5096415e28b61a1f0e02fc130f4e /plugins
parent410531846a5da02b10a1654993c5913a5a9756b3 (diff)
downloadorg.eclipse.papyrus-63d60e51b963bd707d3de6559caa72c22becd4e4.tar.gz
org.eclipse.papyrus-63d60e51b963bd707d3de6559caa72c22becd4e4.tar.xz
org.eclipse.papyrus-63d60e51b963bd707d3de6559caa72c22becd4e4.zip
Bug 430552 - [Sequence Diagram] Dependents of occurrence specifications
not deleted Change-Id: I5fbda29bc28afd777c6812900ec9ac26ac5ecea1 Signed-off-by: sboyko <serg.boyko2011@gmail.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java32
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java56
2 files changed, 58 insertions, 30 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
index 00fb08817f0..6d1c820bbe6 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java
@@ -26,6 +26,7 @@ import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.uml.diagram.common.helper.InteractionFragmentHelper;
+import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification;
import org.eclipse.uml2.uml.ExecutionSpecification;
import org.eclipse.uml2.uml.InteractionFragment;
import org.eclipse.uml2.uml.Lifeline;
@@ -43,7 +44,7 @@ public class ExecutionSpecificationHelperAdvice extends AbstractEditHelperAdvice
* <pre>
* Add a command to associated {@link OccurrenceSpecification} and {@link Message}.
* This command is only added if the start - finish referenced {@link OccurrenceSpecification} is not
- * referenced by another element.
+ * referenced by another element or the start/finish references are of type {@link ExecutionOccurrenceSpecification}.
* </pre>
*
* @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest)
@@ -59,15 +60,14 @@ public class ExecutionSpecificationHelperAdvice extends AbstractEditHelperAdvice
ExecutionSpecification es = (ExecutionSpecification)request.getElementToDestroy();
- // Add start - finish referenced OccurrenceSpecification to the dependents list
- // if they are not used by another element.
+ // Check whether start - finish referenced OccurrenceSpecification should be added to the dependents list
OccurrenceSpecification osStart = es.getStart();
- if((osStart != null) && (EMFHelper.isOnlyUsage(osStart, es))) {
+ if(shouldDestroyOccurrenceSpecification(es, osStart)) {
dependentsToDestroy.add(osStart);
}
OccurrenceSpecification osFinish = es.getFinish();
- if((osFinish != null) && (EMFHelper.isOnlyUsage(osFinish, es))) {
+ if(shouldDestroyOccurrenceSpecification(es, osFinish)) {
dependentsToDestroy.add(osFinish);
}
@@ -107,4 +107,26 @@ public class ExecutionSpecificationHelperAdvice extends AbstractEditHelperAdvice
return null;
}
+
+ /**
+ * <pre>
+ * Check that given {@link OccurrenceSpecification} should be destroyed along with {@link ExecutionSpecification} which references it.
+ * It should be destroyed in case:
+ * It is of type {@link ExecutionOccurrenceSpecification} (since the opposite reference
+ * 'ExecutionOccurrenceSpecification::execution[1]' which designates given {@link ExecutionSpecification} is mandatory).
+ * or
+ * It is not used by another element.
+ * </pre>
+ *
+ * @param es
+ * {@link ExecutionSpecification} which references {@link OccurrenceSpecification} (by means of #start/#finish references)
+ * @param os
+ * start or finish {@link OccurrenceSpecification} which defines the duration of {@link ExecutionSpecification}
+ * @return true in case {@link OccurrenceSpecification} should be destroyed
+ */
+ private boolean shouldDestroyOccurrenceSpecification(ExecutionSpecification es, OccurrenceSpecification os) {
+ return os instanceof ExecutionOccurrenceSpecification
+ || (os != null && EMFHelper.isOnlyUsage(os, es));
+ }
+
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java
index b858c98d3d9..38201bdbad4 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/OccurrenceSpecificationHelperAdvice.java
@@ -13,9 +13,18 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
+import org.eclipse.papyrus.uml.diagram.common.helper.DurationConstraintHelper;
+import org.eclipse.papyrus.uml.diagram.common.helper.DurationObservationHelper;
+import org.eclipse.papyrus.uml.diagram.common.helper.TimeConstraintHelper;
+import org.eclipse.papyrus.uml.diagram.common.helper.TimeObservationHelper;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* Helper advice for all {@link OccurrenceSpecification} elements.
@@ -25,7 +34,6 @@ public class OccurrenceSpecificationHelperAdvice extends AbstractEditHelperAdvic
/**
* <pre>
* Add a command to destroy :
- * - {@link Event} referenced by the {@link OccurrenceSpecification} to delete if unused
* - related time elements
* - linked general ordering
* </pre>
@@ -38,30 +46,28 @@ public class OccurrenceSpecificationHelperAdvice extends AbstractEditHelperAdvic
*/
@Override
protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
- //FIXME : change for UML 2.4
-// List<EObject> dependentsToDestroy = new ArrayList<EObject>();
-//
-// OccurrenceSpecification os = (OccurrenceSpecification)request.getElementToDestroy();
-// Event event = os.getEvent();
-//
-// // Delete referenced event if it is not referenced itself by another element.
-// if((event != null) && (PapyrusEcoreUtils.isOnlyUsage(event, os))) {
-// dependentsToDestroy.add(event);
-// }
-//
-// // delete linked time elements
-// dependentsToDestroy.addAll(TimeObservationHelper.getTimeObservations(os));
-// dependentsToDestroy.addAll(TimeConstraintHelper.getTimeConstraintsOn(os));
-// dependentsToDestroy.addAll(DurationObservationHelper.getDurationObservationsOn(os));
-// dependentsToDestroy.addAll(DurationConstraintHelper.getDurationConstraintsOn(os));
-//
-// // delete linked general ordering
-// dependentsToDestroy.addAll(os.getToBefores());
-// dependentsToDestroy.addAll(os.getToAfters());
-//
-// if(!dependentsToDestroy.isEmpty()) {
-// return request.getDestroyDependentsCommand(dependentsToDestroy);
-// }
+ List<EObject> dependentsToDestroy = new ArrayList<EObject>();
+
+ OccurrenceSpecification os = (OccurrenceSpecification)request.getElementToDestroy();
+
+ // delete linked time elements
+ dependentsToDestroy.addAll(TimeObservationHelper.getTimeObservations(os));
+ dependentsToDestroy.addAll(TimeConstraintHelper.getTimeConstraintsOn(os));
+ dependentsToDestroy.addAll(DurationObservationHelper.getDurationObservationsOn(os));
+ dependentsToDestroy.addAll(DurationConstraintHelper.getDurationConstraintsOn(os));
+
+ // delete linked general ordering
+ /**
+ * Note: GeneralOrdering should be necessarily removed because the opposite
+ * references 'GeneralOrdering::before[1]' and 'GeneralOrdering::after[1]' which designate
+ * this OccurrenceSpecification are mandatory
+ */
+ dependentsToDestroy.addAll(os.getToBefores());
+ dependentsToDestroy.addAll(os.getToAfters());
+
+ if(!dependentsToDestroy.isEmpty()) {
+ return request.getDestroyDependentsCommand(dependentsToDestroy);
+ }
return null;
}

Back to the top