Search in sources :

Example 1 with ValOperation

use of org.eclipse.wst.validation.internal.ValOperation 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 ValOperation

use of org.eclipse.wst.validation.internal.ValOperation in project webtools.sourceediting by eclipse.

the class XMLValidator method executeMarkupValidator.

private IReporter executeMarkupValidator(String uri) {
    Path path = new Path(uri);
    // $NON-NLS-1$
    String fileProtocol = "file://";
    int index = uri.indexOf(fileProtocol);
    IFile resource = null;
    if (index == 0) {
        String transformedUri = uri.substring(fileProtocol.length());
        Path transformedPath = new Path(transformedUri);
        resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(transformedPath);
    } else {
        resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    }
    IReporter reporter = null;
    if (resource != null) {
        reporter = val.validate(resource, 0, new ValOperation().getState());
    }
    return reporter;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) ValOperation(org.eclipse.wst.validation.internal.ValOperation)

Example 3 with ValOperation

use of org.eclipse.wst.validation.internal.ValOperation in project webtools.sourceediting by eclipse.

the class JSONValidator method executeMarkupValidator.

private IReporter executeMarkupValidator(String uri) {
    Path path = new Path(uri);
    // $NON-NLS-1$
    String fileProtocol = "file://";
    int index = uri.indexOf(fileProtocol);
    IFile resource = null;
    if (index == 0) {
        String transformedUri = uri.substring(fileProtocol.length());
        Path transformedPath = new Path(transformedUri);
        resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(transformedPath);
    } else {
        resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    }
    IReporter reporter = null;
    if (resource != null) {
        reporter = val.validate(resource, 0, new ValOperation().getState());
    }
    return reporter;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) ValOperation(org.eclipse.wst.validation.internal.ValOperation)

Example 4 with ValOperation

use of org.eclipse.wst.validation.internal.ValOperation 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)4 IFile (org.eclipse.core.resources.IFile)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 ValidationResultSummary (org.eclipse.wst.validation.internal.ValidationResultSummary)2 IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)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