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));
}
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());
}
});
}
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());
}
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());
}
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);
}
});
}
Aggregations