Search in sources :

Example 1 with FileNameAndCommitMessage

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

the class FormEditorPresenterTest method testRenameCommand.

@Test
public void testRenameCommand() {
    loadContent();
    FormEditorPresenter presenterSpy = spy(presenter);
    FileNameAndCommitMessage details = mock(FileNameAndCommitMessage.class);
    when(renamePopUpPresenter.getView()).thenReturn(mock(RenamePopUpPresenter.View.class));
    doNothing().when(presenterSpy).doLoadContent(any(FormModelerContent.class));
    presenterSpy.renameCommand(details, true);
    verify(view).showBusyIndicator(anyString());
    verify(presenterSpy).getRenameErrorCallback(any(RenamePopUpPresenter.View.class));
    verify(presenterSpy).getRenameSuccessCallback(any(RenamePopUpPresenter.View.class));
}
Also used : FileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) Test(org.junit.Test)

Example 2 with FileNameAndCommitMessage

use of org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage 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 3 with FileNameAndCommitMessage

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

the class BaseViewPresenterTest method renamePopUpPresenterShowMock.

private void renamePopUpPresenterShowMock() {
    final ArgumentCaptor<CommandWithFileNameAndCommitMessage> commandCaptor = ArgumentCaptor.forClass(CommandWithFileNameAndCommitMessage.class);
    doAnswer(invocation -> {
        commandCaptor.getValue().execute(new FileNameAndCommitMessage("fileName", "message"));
        return null;
    }).when(renamePopUpPresenterMock).show(any(Path.class), any(Validator.class), commandCaptor.capture());
}
Also used : FileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) Path(org.uberfire.backend.vfs.Path) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) Validator(org.uberfire.ext.editor.commons.client.validation.Validator)

Example 4 with FileNameAndCommitMessage

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

the class BaseViewPresenterTest method copyPopUpPresenterShowMock.

private void copyPopUpPresenterShowMock() {
    final ArgumentCaptor<CommandWithFileNameAndCommitMessage> commandCaptor = ArgumentCaptor.forClass(CommandWithFileNameAndCommitMessage.class);
    doAnswer(invocation -> {
        commandCaptor.getValue().execute(new FileNameAndCommitMessage("fileName", "message"));
        return null;
    }).when(copyPopUpPresenterMock).show(any(Path.class), any(Validator.class), commandCaptor.capture());
}
Also used : FileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) Path(org.uberfire.backend.vfs.Path) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) Validator(org.uberfire.ext.editor.commons.client.validation.Validator)

Example 5 with FileNameAndCommitMessage

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

the class DataModelerScreenPresenter method rename.

private void rename(final boolean saveCurrentChanges) {
    final DataObject[] modifiedDataObject = new DataObject[1];
    if (saveCurrentChanges) {
        if (isDirty()) {
            if (context.isEditorChanged()) {
                // at save time the source has always priority over the model.
                // If the source was properly parsed and the editor has changes, we need to send the DataObject
                // to the server in order to let the source to be updated prior to save.
                modifiedDataObject[0] = context.getDataObject();
            } else {
                // if the source has changes, no update form the UI to the source will be performed.
                // instead the parsed DataObject must be returned from the server.
                modifiedDataObject[0] = null;
            }
        }
    }
    renamePopUpPresenter.show(versionRecordManager.getPathToLatest(), javaAssetUpdateValidator, new CommandWithFileNameAndCommitMessage() {

        @Override
        public void execute(final FileNameAndCommitMessage details) {
            view.showBusyIndicator(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE.Renaming());
            modelerService.call(getRenameSuccessCallback(renamePopUpPresenter.getView()), getRenameErrorCallback(renamePopUpPresenter.getView())).rename(versionRecordManager.getPathToLatest(), details.getNewFileName(), details.getCommitMessage(), true, saveCurrentChanges, getSource(), modifiedDataObject[0], metadata);
        }
    });
}
Also used : FileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage)

Aggregations

CommandWithFileNameAndCommitMessage (org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage)6 FileNameAndCommitMessage (org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage)6 Path (org.uberfire.backend.vfs.Path)3 Validator (org.uberfire.ext.editor.commons.client.validation.Validator)3 Test (org.junit.Test)2 FormModelerContent (org.kie.workbench.common.forms.editor.model.FormModelerContent)1 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)1 CopyPopUpView (org.uberfire.ext.editor.commons.client.file.popups.CopyPopUpView)1 ValidatorCallback (org.uberfire.ext.editor.commons.client.validation.ValidatorCallback)1