Search in sources :

Example 1 with ValidationResultDialog

use of org.talend.mdm.repository.ui.dialogs.ValidationResultDialog 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)

Aggregations

IResource (org.eclipse.core.resources.IResource)1 Shell (org.eclipse.swt.widgets.Shell)1 ValOperation (org.eclipse.wst.validation.internal.ValOperation)1 ValidationResultSummary (org.eclipse.wst.validation.internal.ValidationResultSummary)1 IModelValidateResult (org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult)1 ValidationResultDialog (org.talend.mdm.repository.ui.dialogs.ValidationResultDialog)1