Search in sources :

Example 6 with ValidatorCallback

use of org.uberfire.ext.editor.commons.client.validation.ValidatorCallback in project kie-wb-common by kiegroup.

the class DriverDefEditorHelper method onArtifactIdChange.

public void onArtifactIdChange() {
    final String newValue = mainPanel.getArtifactId().trim();
    validationService.isValidArtifactId(newValue, new ValidatorCallback() {

        @Override
        public void onSuccess() {
            onArtifactIdChange(newValue, true);
        }

        @Override
        public void onFailure() {
            onArtifactIdChange(newValue, false);
        }
    });
}
Also used : ValidatorCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorCallback)

Example 7 with ValidatorCallback

use of org.uberfire.ext.editor.commons.client.validation.ValidatorCallback in project kie-wb-common by kiegroup.

the class DriverDefEditorHelper method onGroupIdChange.

public void onGroupIdChange() {
    final String newValue = mainPanel.getGroupId().trim();
    validationService.isValidGroupId(newValue, new ValidatorCallback() {

        @Override
        public void onSuccess() {
            onGroupIdChange(newValue, true);
        }

        @Override
        public void onFailure() {
            onGroupIdChange(newValue, false);
        }
    });
}
Also used : ValidatorCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorCallback)

Example 8 with ValidatorCallback

use of org.uberfire.ext.editor.commons.client.validation.ValidatorCallback in project kie-wb-common by kiegroup.

the class DataObjectBrowser method onCreateNewProperty.

private void onCreateNewProperty(final DataObject dataObject, final String propertyName, final String propertyLabel, final String propertyType, final Boolean isMultiple, final boolean closePopup) {
    if (dataObject != null) {
        validatorService.isValidIdentifier(propertyName, new ValidatorCallback() {

            @Override
            public void onFailure() {
                newFieldPopup.setErrorMessage(Constants.INSTANCE.validation_error_invalid_object_attribute_identifier(propertyName));
            }

            @Override
            public void onSuccess() {
                validatorService.isUniqueAttributeName(propertyName, dataObject, new ValidatorWithReasonCallback() {

                    @Override
                    public void onFailure() {
                        showFailure(ValidatorService.MANAGED_PROPERTY_EXISTS);
                    }

                    @Override
                    public void onFailure(String reason) {
                        showFailure(reason);
                    }

                    private void showFailure(String reason) {
                        if (ValidatorService.UN_MANAGED_PROPERTY_EXISTS.equals(reason)) {
                            ObjectProperty unmanagedProperty = getDataObject().getUnManagedProperty(propertyName);
                            newFieldPopup.setErrorMessage(Constants.INSTANCE.validation_error_object_un_managed_attribute_already_exists(unmanagedProperty.getName(), unmanagedProperty.getClassName()));
                        } else {
                            newFieldPopup.setErrorMessage(Constants.INSTANCE.validation_error_object_attribute_already_exists(propertyName));
                        }
                    }

                    @Override
                    public void onSuccess() {
                        if (propertyType != null && !"".equals(propertyType) && !UIUtil.NOT_SELECTED.equals(propertyType)) {
                            // extra check
                            boolean multiple = isMultiple && !getContext().getHelper().isPrimitiveType(propertyType);
                            addNewProperty(getDataObject(), propertyName, propertyLabel, propertyType, multiple);
                            if (closePopup) {
                                newFieldPopup.hide();
                            } else {
                                newFieldPopup.resetInput();
                            }
                        } else {
                            newFieldPopup.setErrorMessage(Constants.INSTANCE.validation_error_missing_object_attribute_type());
                        }
                    }
                });
            }
        });
    }
}
Also used : ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) ValidatorCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorCallback) ValidatorWithReasonCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorWithReasonCallback)

Example 9 with ValidatorCallback

use of org.uberfire.ext.editor.commons.client.validation.ValidatorCallback in project kie-wb-common by kiegroup.

the class MainDataObjectEditor method doClassNameChange.

private void doClassNameChange(final String packageName, final String oldValue, final String newValue) {
    final Command afterCloseCommand = new Command() {

        @Override
        public void execute() {
            view.setNameOnError(true);
            view.setAllNameNameText();
        }
    };
    // In case an invalid name (entered before), was corrected to the original value, don't do anything but reset the label style
    if (oldValue.equals(newValue)) {
        view.setNameOnError(false);
        return;
    }
    // Otherwise validate
    validatorService.isValidIdentifier(newValue, new ValidatorCallback() {

        @Override
        public void onFailure() {
            view.showErrorPopup(Constants.INSTANCE.validation_error_invalid_object_identifier(newValue), null, afterCloseCommand);
        }

        @Override
        public void onSuccess() {
            validatorService.isUniqueEntityName(packageName, newValue, getDataModel(), new ValidatorCallback() {

                @Override
                public void onFailure() {
                    view.showErrorPopup(Constants.INSTANCE.validation_error_object_already_exists(newValue, packageName), null, afterCloseCommand);
                }

                @Override
                public void onSuccess() {
                    view.setNameOnError(false);
                    commandBuilder.buildDataObjectNameChangeCommand(getContext(), getName(), getDataObject(), newValue).execute();
                }
            });
        }
    });
}
Also used : ValidatorCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorCallback) Command(com.google.gwt.user.client.Command) DataModelCommand(org.kie.workbench.common.screens.datamodeller.client.command.DataModelCommand)

Example 10 with ValidatorCallback

use of org.uberfire.ext.editor.commons.client.validation.ValidatorCallback in project kie-wb-common by kiegroup.

the class DataSourceDefEditorHelper method onConnectionURLChange.

public void onConnectionURLChange() {
    final String newValue = mainPanel.getConnectionURL().trim();
    validationService.isValidConnectionURL(newValue, new ValidatorCallback() {

        @Override
        public void onSuccess() {
            onConnectionURLChange(newValue, true);
        }

        @Override
        public void onFailure() {
            onConnectionURLChange(newValue, false);
        }
    });
}
Also used : ValidatorCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorCallback)

Aggregations

ValidatorCallback (org.uberfire.ext.editor.commons.client.validation.ValidatorCallback)17 DataModelCommand (org.kie.workbench.common.screens.datamodeller.client.command.DataModelCommand)3 Command (com.google.gwt.user.client.Command)2 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)2 ValidatorWithReasonCallback (org.uberfire.ext.editor.commons.client.validation.ValidatorWithReasonCallback)2 Command (org.uberfire.mvp.Command)2 Path (org.uberfire.backend.vfs.Path)1 CommandWithFileNameAndCommitMessage (org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage)1 FileNameAndCommitMessage (org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage)1 Validator (org.uberfire.ext.editor.commons.client.validation.Validator)1