Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java36
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java7
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java71
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java84
4 files changed, 121 insertions, 77 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
index ffc8e2fa89a..04bcb5ebcf2 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
* Christian W. Damus (CEA) - Target EObject must be the diagnostic's first data element
- *
+ * Benoit Maggi (CEA LIST) - Add an unique id as source for diagnostic
*****************************************************************************/
@@ -29,7 +29,9 @@ import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.validation.model.EvaluationMode;
import org.eclipse.emf.validation.model.IConstraintStatus;
+import org.eclipse.emf.validation.model.IModelConstraint;
import org.eclipse.emf.validation.service.IBatchValidator;
+import org.eclipse.emf.validation.service.IConstraintDescriptor;
import org.eclipse.emf.validation.service.ModelValidationService;
import org.eclipse.uml2.uml.util.UMLValidator;
@@ -181,16 +183,36 @@ public class EValidatorAdapter
}
} else if (status instanceof IConstraintStatus) {
IConstraintStatus constraintStatus = (IConstraintStatus) status;
- diagnostics.add(new BasicDiagnostic(
- status.getSeverity(),
- status.getPlugin(),
- status.getCode(),
- status.getMessage(),
- toArray(constraintStatus.getResultLocus(), constraintStatus.getTarget())));
+ diagnostics.add(createBasicDiagnostic(status, constraintStatus));
}
}
/**
+ * Create a basic diagnostic with an unique id as source
+ * @param status
+ * @param constraintStatus
+ * @return
+ */
+ protected BasicDiagnostic createBasicDiagnostic(IStatus status,
+ IConstraintStatus constraintStatus) {
+ String source = status.getPlugin();
+ IModelConstraint constraint = constraintStatus.getConstraint();
+ if (constraint != null){
+ IConstraintDescriptor descriptor = constraint.getDescriptor();
+ if (descriptor != null) {
+ source = descriptor.getId();
+ }
+ }
+
+ return new BasicDiagnostic(
+ status.getSeverity(),
+ source,
+ status.getCode(),
+ status.getMessage(),
+ toArray(constraintStatus.getResultLocus(), constraintStatus.getTarget()));
+ }
+
+ /**
* Converts a possibly unordered collection to a list that has a designated
* {@code first} element.
*
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
index 34df185abac..628dee777d1 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
@@ -109,6 +109,13 @@ abstract public class AbstractValidateCommand extends AbstractTransactionalComma
public void disableUIFeedback() {
this.showUIfeedback = false;
}
+
+ /**
+ * @return
+ */
+ public Diagnostic getDiagnostic() {
+ return diagnostic;
+ }
/**
* @return The resource on which markers should be applied.
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java
index c6bd8c158bb..a4ca22a391f 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java
@@ -62,75 +62,10 @@ public class ActivityNodeHelper extends ElementEditHelper {
}
@Override
- protected ICommand getMoveCommand(MoveRequest req) {
- if (req != null) {
- if (req.getTargetContainer() instanceof ActivityPartition) {
- ActivityPartition partition = (ActivityPartition)req.getTargetContainer();
- CompositeCommand result = new CompositeCommand("Move elements in Partition");
- MoveElementsCommand moveCommand = new NotContainmentMoveCommand(createMoveToPartitionRequest(req));
- result.add(moveCommand);
- for (Object o: req.getElementsToMove().keySet()) {
- result.add(new SetValueCommand(new SetRequest(partition, UMLPackage.eINSTANCE.getActivityPartition_Node(), o)));
- }
- return result;
- }
- }
- return super.getMoveCommand(req);
- }
-
- /**
- * @param base move request in which target container is ActivityPartition
- * @return MoveRequest in which replaced Partition container on Activity and replaced containment features for it.
- */
- private MoveRequest createMoveToPartitionRequest(MoveRequest baseReq) {
- if (baseReq == null) {
- return null;
- }
- MoveRequest result = new MoveRequest(baseReq.getEditingDomain(), findActivity(baseReq.getTargetContainer()), baseReq.getElementsToMove());
- for (Object o : baseReq.getElementsToMove().keySet()) {
- if (o instanceof ActivityNode) {
- ActivityNode node = (ActivityNode)o;
- result.setTargetFeature(node ,findActivityFeature(node.eClass()));
- }
- }
- return result;
- }
-
- /**
- * Find parent Activity.
- *
- * @param editElement ActivitiyPartition element
- * @return null if Activity not found.
- */
- protected Activity findActivity(EObject editElement) {
- if (editElement instanceof ActivityPartition) {
- ActivityPartition partition = (ActivityPartition) editElement;
- if (partition.eContainer() instanceof Activity) {
- return (Activity)partition.eContainer();
- } else {
- return findActivity(partition.eContainer());
- }
- }
- return null;
- }
-
- /**
- * Find Activity feature appropriate to ActivityPartition feature.
- *
- * @return Appropriate feature. If feature not found return partitionFeature param
- */
- protected EReference findActivityFeature(EClass eClass) {
- if (UMLPackage.eINSTANCE.getActivityPartition().isSuperTypeOf(eClass)) {
- return UMLPackage.eINSTANCE.getActivity_StructuredNode();
- }
- if (UMLPackage.eINSTANCE.getStructuredActivityNode().isSuperTypeOf(eClass)) {
- return UMLPackage.eINSTANCE.getActivity_StructuredNode();
- }
- return UMLPackage.eINSTANCE.getActivity_OwnedNode();
- }
-
- @Override
protected ICommand getConfigureCommand(ConfigureRequest req) {
+ if (req.getParameter(IN_PARTITION) != null) {
+ return new SetValueCommand(new SetRequest((EObject)req.getParameter(IN_PARTITION),UMLPackage.eINSTANCE.getActivityPartition_Node(), req.getElementToConfigure()));
+ }
if (req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION) != null) {
return new SetValueCommand(new SetRequest((EObject)req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION),UMLPackage.eINSTANCE.getInterruptibleActivityRegion_Node(), req.getElementToConfigure()));
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java
index 0d10c304bc5..2b725ce76fb 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java
@@ -1,10 +1,22 @@
package org.eclipse.papyrus.uml.service.types.helper;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.uml.service.types.command.NotContainmentMoveCommand;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.ActivityNode;
import org.eclipse.uml2.uml.ActivityPartition;
+import org.eclipse.uml2.uml.UMLPackage;
-public class ActivityPartitionEditHelper extends ActivityNodeHelper {
+public class ActivityPartitionEditHelper extends ActivityGroupHelper {
@Override
protected ICommand getCreateCommand(CreateElementRequest req) {
@@ -23,8 +35,76 @@ public class ActivityPartitionEditHelper extends ActivityNodeHelper {
return null;
}
CreateElementRequest result = new CreateElementRequest(req.getEditingDomain(), findActivity(req.getContainer()), req.getElementType());
- result.setParameter(IN_PARTITION, (ActivityPartition)req.getContainer());
+ result.setParameter(ActivityNodeHelper.IN_PARTITION, (ActivityPartition)req.getContainer());
result.setContainmentFeature(findActivityFeature(req.getElementType().getEClass()));
return result;
}
+
+ @Override
+ protected ICommand getMoveCommand(MoveRequest req) {
+ if (req != null) {
+ if (req.getTargetContainer() instanceof ActivityPartition) {
+ ActivityPartition partition = (ActivityPartition)req.getTargetContainer();
+ CompositeCommand result = new CompositeCommand("Move elements in Partition");
+ MoveElementsCommand moveCommand = new NotContainmentMoveCommand(createMoveToPartitionRequest(req));
+ result.add(moveCommand);
+ for (Object o: req.getElementsToMove().keySet()) {
+ result.add(new SetValueCommand(new SetRequest(partition, UMLPackage.eINSTANCE.getActivityPartition_Node(), o)));
+ }
+ return result;
+ }
+ }
+ return super.getMoveCommand(req);
+ }
+
+ /**
+ * @param base move request in which target container is ActivityPartition
+ * @return MoveRequest in which replaced Partition container on Activity and replaced containment features for it.
+ */
+ private MoveRequest createMoveToPartitionRequest(MoveRequest baseReq) {
+ if (baseReq == null) {
+ return null;
+ }
+ MoveRequest result = new MoveRequest(baseReq.getEditingDomain(), findActivity(baseReq.getTargetContainer()), baseReq.getElementsToMove());
+ for (Object o : baseReq.getElementsToMove().keySet()) {
+ if (o instanceof ActivityNode) {
+ ActivityNode node = (ActivityNode)o;
+ result.setTargetFeature(node ,findActivityFeature(node.eClass()));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Find parent Activity.
+ *
+ * @param editElement ActivitiyPartition element
+ * @return null if Activity not found.
+ */
+ protected Activity findActivity(EObject editElement) {
+ if (editElement instanceof ActivityPartition) {
+ ActivityPartition partition = (ActivityPartition) editElement;
+ if (partition.eContainer() instanceof Activity) {
+ return (Activity)partition.eContainer();
+ } else {
+ return findActivity(partition.eContainer());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Find Activity feature appropriate to ActivityPartition feature.
+ *
+ * @return Appropriate feature. If feature not found return partitionFeature param
+ */
+ protected EReference findActivityFeature(EClass eClass) {
+ if (UMLPackage.eINSTANCE.getActivityPartition().isSuperTypeOf(eClass)) {
+ return UMLPackage.eINSTANCE.getActivity_StructuredNode();
+ }
+ if (UMLPackage.eINSTANCE.getStructuredActivityNode().isSuperTypeOf(eClass)) {
+ return UMLPackage.eINSTANCE.getActivity_StructuredNode();
+ }
+ return UMLPackage.eINSTANCE.getActivity_OwnedNode();
+ }
} \ No newline at end of file

Back to the top