use of org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage 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.CommandWithFileNameAndCommitMessage 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.CommandWithFileNameAndCommitMessage 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.CommandWithFileNameAndCommitMessage 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);
}
});
}
use of org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage in project kie-wb-common by kiegroup.
the class ProjectScreen method getDuplicateCommand.
CommandWithFileNameAndCommitMessage getDuplicateCommand() {
return details -> {
copyPopUpPresenter.getView().hide();
view.showBusyIndicator(view.getLoadingMessage());
promises.promisify(projectScreenService, s -> {
s.copy(workspaceProject, details.getNewFileName());
}).then(i -> {
view.hideBusyIndicator();
notificationEvent.fire(new NotificationEvent(view.getItemSuccessfullyDuplicatedMessage(), NotificationEvent.NotificationType.SUCCESS));
return promises.resolve();
}).catch_(this::onError);
};
}
Aggregations