Search in sources :

Example 1 with ValidationResult

use of org.talend.daikon.properties.ValidationResult in project tdi-studio-se by Talend.

the class DynamicComposite method updateValidationStatus.

private void updateValidationStatus(ValidationResult validationResult) {
    String validationMessage = validationResult.getMessage();
    Result validationStatus = validationResult.getStatus();
    if (validationMessage == null) {
        if (validationStatus == Result.OK) {
            checker.updateStatus(IStatus.OK, null);
            return;
        } else if (validationStatus == Result.ERROR) {
            //$NON-NLS-1$
            validationMessage = Messages.getString("DynamicComposite.defaultErrorMessage");
        } else {
            // skip every empty messages
            return;
        }
    }
    String message = validationMessage;
    switch(validationStatus) {
        case WARNING:
            checker.updateStatus(IStatus.WARNING, null);
            DisplayUtils.getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    MessageDialog.openWarning(getShell(), elem.getElementName(), message);
                }
            });
            break;
        case ERROR:
            checker.updateStatus(IStatus.ERROR, null);
            DisplayUtils.getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    MessageDialog.openError(getShell(), elem.getElementName(), message);
                }
            });
            break;
        default:
            checker.updateStatus(IStatus.OK, null);
            DisplayUtils.getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    MessageDialog.openInformation(getShell(), elem.getElementName(), message);
                }
            });
            break;
    }
}
Also used : Result(org.talend.daikon.properties.ValidationResult.Result) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 2 with ValidationResult

use of org.talend.daikon.properties.ValidationResult in project tdi-studio-se by Talend.

the class DynamicComposite method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent event) {
    String propertyName = event.getPropertyName();
    if (IElementParameterEventProperties.EVENT_PROPERTY_VALUE_CHANGED.equals(propertyName)) {
        reset(true);
    } else if (IElementParameterEventProperties.EVENT_VALIDATE_RESULT_UPDATE.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof ValidationResult) {
            updateValidationStatus((ValidationResult) newValue);
        }
    } else if (IElementParameterEventProperties.EVENT_SHOW_DIALOG.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof Form) {
            GenericDialog genericDialog = new GenericDialog(getShell(), (Form) newValue);
            genericDialog.setConnectionItem(connectionItem);
            genericDialog.open();
        }
    } else if (IContextEventProperties.EVENT_PROPERTY_EXPORT_CONTEXT.equals(propertyName)) {
        resetComponentProperties();
    } else if (IContextEventProperties.EVENT_PROPERTY_REFRESH_UI.equals(propertyName)) {
        Object newValue = event.getNewValue();
        if (newValue instanceof ComponentProperties) {
            ComponentProperties newComponentProperties = (ComponentProperties) newValue;
            form.getProperties().copyValuesFrom(newComponentProperties);
            reset(true);
        }
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form) ValidationResult(org.talend.daikon.properties.ValidationResult)

Aggregations

ValidationResult (org.talend.daikon.properties.ValidationResult)2 ComponentProperties (org.talend.components.api.properties.ComponentProperties)1 Result (org.talend.daikon.properties.ValidationResult.Result)1 Form (org.talend.daikon.properties.presentation.Form)1