use of org.eclipse.emf.edit.ui.action.ValidateAction.EclipseResourcesUtil in project InformationSystem by ObeoNetwork.
the class ValidateRequirementsHandler method executeValidation.
private void executeValidation(Collection<EObject> selectedEObjects) {
ValidationDelegateClientSelector.running = true;
IBatchValidator validator = ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
// include live constraints, also, in batch validation
validator.setOption(IBatchValidator.OPTION_INCLUDE_LIVE_CONSTRAINTS, true);
final IStatus status = validator.validate(selectedEObjects);
ValidationDelegateClientSelector.running = false;
// Markers creation
EclipseResourcesUtil eclipseResourcesUtil = new EclipseResourcesUtil();
eclipseResourcesUtil.deleteMarkers(resourceSet);
BasicDiagnostic parentDiagnostic = new BasicDiagnostic(EObjectValidator.DIAGNOSTIC_SOURCE, 0, EMFEditUIPlugin.INSTANCE.getString("_UI_DiagnosisOfNObjects_message", new String[] { Integer.toString(selectedEObjects.size()) }), selectedEObjects.toArray());
for (IStatus childStatus : status.getChildren()) {
EObject target = (EObject) ((IConstraintStatus) childStatus).getTarget();
Diagnostic childDiagnostic = new BasicDiagnostic(// Severity
childStatus.getSeverity(), // Source
childStatus.getPlugin(), // Code
childStatus.getCode(), // Message
childStatus.getMessage(), // Data
new Object[] { ((IConstraintStatus) childStatus).getTarget() });
parentDiagnostic.add(childDiagnostic);
eclipseResourcesUtil.createMarkers(target.eResource(), childDiagnostic);
}
if (parentDiagnostic.getChildren().isEmpty()) {
MessageDialog.openInformation(shell, "No errors during validation", "No errors found when validating requirements ");
} else {
DiagnosticDialog.open(shell, "Errors during validation", "Errors have been encountered during validation", parentDiagnostic);
}
ValidationDelegateClientSelector.running = false;
}
Aggregations