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
2 files changed, 36 insertions, 7 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.

Back to the top