Search in sources :

Example 1 with ValidationResultSummary

use of org.eclipse.wst.validation.internal.ValidationResultSummary in project tmdm-studio-se by Talend.

the class MDMValidationRunner method runInWorkspace.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.core.resources.WorkspaceJob#runInWorkspace(org.eclipse.core.runtime.IProgressMonitor)
     */
@SuppressWarnings({ "restriction", "hiding" })
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
    if (UIUtil.isWorkInUI() && lockDirtyDialog.needShowDialog()) {
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                if (lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
                    setReturnCode(IDialogConstants.CANCEL_ID);
                } else {
                    lockDirtyDialog.saveDirtyObjects();
                }
            }
        });
        if (getReturnCode() == IDialogConstants.CANCEL_ID) {
            setValidateResult(new MDMValidationService.ModelValidateResult());
            return Status.CANCEL_STATUS;
        }
    }
    final ValOperation vo = ValidationRunner.validate(toValidate, ValType.Manual, monitor, false);
    if (vo.isCanceled()) {
        setValidateResult(new MDMValidationService.ModelValidateResult());
        return Status.CANCEL_STATUS;
    }
    final ValidationResultSummary result = vo.getResult();
    final IModelValidateResult validateResult = new MDMValidationService.ModelValidateResult(viewObjMap);
    if (needShowValidationResults(result)) {
        final Set<IResource> resources = toValidate.values().iterator().next();
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                ValidationResultDialog d = new ValidationResultDialog(new Shell(), result, validationPref, viewObjMap);
                int code = d.open();
                validateResult.setSelectedButton(code);
                setValidateResult(validateResult);
            }
        });
    } else {
        setValidateResult(validateResult);
        if (validateResult.hasErrOrWarning()) {
            int code = ValidationPreferenceService.getInstance().getDeployActionWhenValidateFail();
            validateResult.setSelectedButton(code);
        } else {
            validateResult.setSelectedButton(IModelValidationService.BUTTON_OK);
        }
    }
    activeProblemView(result);
    return Status.OK_STATUS;
}
Also used : ValidationResultSummary(org.eclipse.wst.validation.internal.ValidationResultSummary) IModelValidateResult(org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult) IModelValidateResult(org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult) Shell(org.eclipse.swt.widgets.Shell) ValidationResultDialog(org.talend.mdm.repository.ui.dialogs.ValidationResultDialog) ValOperation(org.eclipse.wst.validation.internal.ValOperation) IResource(org.eclipse.core.resources.IResource)

Example 2 with ValidationResultSummary

use of org.eclipse.wst.validation.internal.ValidationResultSummary in project liferay-ide by liferay.

the class KaleoUtil method checkWorkflowDefinitionForErrors.

public static String checkWorkflowDefinitionForErrors(IFile workspaceFile) {
    String retval = null;
    try {
        StringBuilder errorMsgs = new StringBuilder();
        ValOperation result = ValidationRunner.validate(workspaceFile, ValType.Manual, null, true);
        ValidationResultSummary validationResult = result.getResult();
        if (validationResult.getSeverityError() == 1) {
            ValidationResults results = result.getResults();
            for (ValidatorMessage message : results.getMessages()) {
                if (message.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR) {
                    errorMsgs.append(message.getAttribute(IMarker.MESSAGE)).append('\n');
                }
            }
        }
        retval = errorMsgs.toString();
    } catch (Exception e) {
    }
    return retval;
}
Also used : ValidationResultSummary(org.eclipse.wst.validation.internal.ValidationResultSummary) ValidationResults(org.eclipse.wst.validation.ValidationResults) ValOperation(org.eclipse.wst.validation.internal.ValOperation) ValidatorMessage(org.eclipse.wst.validation.ValidatorMessage) JSONException(org.json.JSONException) SAXParseException(org.xml.sax.SAXParseException) SAXException(org.xml.sax.SAXException)

Aggregations

ValOperation (org.eclipse.wst.validation.internal.ValOperation)2 ValidationResultSummary (org.eclipse.wst.validation.internal.ValidationResultSummary)2 IResource (org.eclipse.core.resources.IResource)1 Shell (org.eclipse.swt.widgets.Shell)1 ValidationResults (org.eclipse.wst.validation.ValidationResults)1 ValidatorMessage (org.eclipse.wst.validation.ValidatorMessage)1 JSONException (org.json.JSONException)1 IModelValidateResult (org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult)1 ValidationResultDialog (org.talend.mdm.repository.ui.dialogs.ValidationResultDialog)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1