Search in sources :

Example 1 with ValidationException

use of org.eclipse.scanning.api.ValidationException in project gda-core by openGDA.

the class TimeSeriesScanView method displayValidationResult.

private void displayValidationResult(Object result, boolean initialValidation) {
    if (malcolmModelEditor == null)
        return;
    final IMalcolmModel malcolmModel = malcolmModelEditor.getModel();
    Display.getDefault().asyncExec(() -> {
        // note getShell().getDisplay() can throw NPE initially
        if (result instanceof ValidationException) {
            MessageDialog.openError(getShell(), "Validation Error", "The given configuration is invalid: " + ((Exception) result).getMessage());
        } else if (result instanceof Exception) {
            logger.error("Error getting malcolm device '{}', {}", malcolmModel.getName(), result);
            MessageDialog.openError(getShell(), "Error", "Could not get malcolm device " + malcolmModel.getName());
        } else if (!initialValidation) {
            // only show message for ok if button pressed
            MessageDialog.openInformation(getShell(), "Validation Successful", "The given configuration is valid.");
        }
        malcolmModelEditor.updateValidatedModel(result instanceof IMalcolmModel ? (IMalcolmModel) result : null);
    });
}
Also used : ValidationException(org.eclipse.scanning.api.ValidationException) IMalcolmModel(org.eclipse.scanning.api.device.models.IMalcolmModel) URISyntaxException(java.net.URISyntaxException) ScanningException(org.eclipse.scanning.api.scan.ScanningException) ValidationException(org.eclipse.scanning.api.ValidationException) EventException(org.eclipse.scanning.api.event.EventException)

Aggregations

URISyntaxException (java.net.URISyntaxException)1 ValidationException (org.eclipse.scanning.api.ValidationException)1 IMalcolmModel (org.eclipse.scanning.api.device.models.IMalcolmModel)1 EventException (org.eclipse.scanning.api.event.EventException)1 ScanningException (org.eclipse.scanning.api.scan.ScanningException)1