Search in sources :

Example 1 with Validator

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

the class BaseViewPresenter method renameItem.

public void renameItem(final FolderItem folderItem) {
    final Path path = getFolderItemPath(folderItem);
    renamePopUpPresenter.show(path, new Validator() {

        @Override
        public void validate(final String value, final ValidatorCallback callback) {
            validationService.call(new RemoteCallback<Object>() {

                @Override
                public void callback(Object response) {
                    if (Boolean.TRUE.equals(response)) {
                        callback.onSuccess();
                    } else {
                        callback.onFailure();
                    }
                }
            }).isFileNameValid(path, value);
        }
    }, new CommandWithFileNameAndCommitMessage() {

        @Override
        public void execute(final FileNameAndCommitMessage details) {
            baseView.showBusyIndicator(CommonConstants.INSTANCE.Renaming());
            explorerService.call(getRenameSuccessCallback(getRenameView()), getRenameErrorCallback(getRenameView())).renameItem(folderItem, details.getNewFileName(), details.getCommitMessage());
        }
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) FileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) ValidatorCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorCallback) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) Validator(org.uberfire.ext.editor.commons.client.validation.Validator)

Example 2 with Validator

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

the class KieEditorTest method testGetRenameValidator.

@Test
public void testGetRenameValidator() {
    final Validator renameValidator = presenter.getRenameValidator();
    assertEquals(assetUpdateValidator, renameValidator);
}
Also used : Validator(org.uberfire.ext.editor.commons.client.validation.Validator) AssetUpdateValidator(org.kie.workbench.common.widgets.metadata.client.validation.AssetUpdateValidator) Test(org.junit.Test)

Aggregations

Validator (org.uberfire.ext.editor.commons.client.validation.Validator)2 Test (org.junit.Test)1 AssetUpdateValidator (org.kie.workbench.common.widgets.metadata.client.validation.AssetUpdateValidator)1 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 ValidatorCallback (org.uberfire.ext.editor.commons.client.validation.ValidatorCallback)1