use of org.eclipse.emf.validation.service.IBatchValidator 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;
}
use of org.eclipse.emf.validation.service.IBatchValidator in project Palladio-Editors-Sirius by PalladioSimulator.
the class SemanticElementsValidateAction method createBatchValidator.
private static IBatchValidator createBatchValidator() {
IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
validator.setIncludeLiveConstraints(true);
return validator;
}
use of org.eclipse.emf.validation.service.IBatchValidator in project Palladio-Editors-Sirius by PalladioSimulator.
the class SemanticElementsValidateAction method validate.
/**
* @was-generated NOT it is not necessary to call the createMarkers operation since the markers are automatically added
* for EMF validation. <br/>
* Validation is run on view elements and its children.<br/>
*/
private static void validate(DiagramEditPart diagramEditPart, View view) {
IFile target = getFileToMark(diagramEditPart, view);
if (target != null) {
SiriusMarkerNavigationProvider.deleteMarkers(target);
}
if (view.isSetElement()) {
final EObject element = view.getElement();
if (element != null) {
IBatchValidator validator = createBatchValidator();
IStatus status = validator.validate(element);
createMarkers(target, status, diagramEditPart);
if (element instanceof DSemanticDecorator) {
List<EObject> elementsToValidate = new ArrayList<>();
final EObject semanticElement = ((DSemanticDecorator) element).getTarget();
elementsToValidate.add(semanticElement);
createMarkers(target, runEMFValidator(semanticElement), diagramEditPart);
for (final EObject representationElement : AllContents.of(view.getElement(), ViewpointPackage.eINSTANCE.getDRepresentationElement())) {
elementsToValidate.addAll(((DRepresentationElement) representationElement).getSemanticElements());
}
validator.setTraversalStrategy(new ITraversalStrategy.Flat());
IStatus status2 = validator.validate(elementsToValidate);
createMarkers(target, status2, diagramEditPart);
}
}
}
}
Aggregations