Search in sources :

Example 1 with CommandWithFileNameAndCommitMessage

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

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());
}
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 3 with CommandWithFileNameAndCommitMessage

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

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

Example 5 with CommandWithFileNameAndCommitMessage

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);
    };
}
Also used : DeleteProjectPopUpScreen(org.kie.workbench.common.screens.library.client.screens.project.delete.DeleteProjectPopUpScreen) UpdatedAssetsEvent(org.kie.workbench.common.screens.library.client.screens.assets.events.UpdatedAssetsEvent) Promises(org.uberfire.client.promise.Promises) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) SettingsPresenter(org.kie.workbench.common.screens.library.client.settings.SettingsPresenter) NewFileUploader(org.kie.workbench.common.screens.defaulteditor.client.editor.NewFileUploader) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Promise(elemental2.promise.Promise) ContributorsListPresenter(org.kie.workbench.common.screens.library.client.screens.organizationalunit.contributors.tab.ContributorsListPresenter) LibraryPlaces(org.kie.workbench.common.screens.library.client.util.LibraryPlaces) Inject(javax.inject.Inject) RenameProjectPopUpScreen(org.kie.workbench.common.screens.library.client.screens.project.rename.RenameProjectPopUpScreen) IsElement(org.jboss.errai.ui.client.local.api.elemental2.IsElement) EditContributorsPopUpPresenter(org.kie.workbench.common.screens.library.client.screens.organizationalunit.contributors.edit.EditContributorsPopUpPresenter) Elemental2DomUtil(org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil) WorkbenchPartTitle(org.uberfire.client.annotations.WorkbenchPartTitle) HTMLElement(elemental2.dom.HTMLElement) Observes(javax.enterprise.event.Observes) NewResourcePresenter(org.kie.workbench.common.widgets.client.handlers.NewResourcePresenter) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) OrganizationalUnitController(org.guvnor.structure.client.security.OrganizationalUnitController) WorkbenchScreen(org.uberfire.client.annotations.WorkbenchScreen) ProjectScreenService(org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService) Path(org.uberfire.backend.vfs.Path) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) ProjectNameValidator(org.kie.workbench.common.screens.projecteditor.client.validation.ProjectNameValidator) Event(javax.enterprise.event.Event) BuildExecutor(org.kie.workbench.common.screens.projecteditor.client.build.BuildExecutor) CopyPopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.CopyPopUpPresenter) AfterEditOrganizationalUnitEvent(org.guvnor.structure.events.AfterEditOrganizationalUnitEvent) ViewHideAlertsButtonPresenter(org.guvnor.messageconsole.client.console.widget.button.ViewHideAlertsButtonPresenter) LibraryService(org.kie.workbench.common.screens.library.api.LibraryService) EmptyAssetsScreen(org.kie.workbench.common.screens.library.client.screens.assets.EmptyAssetsScreen) CommandWithFileNameAndCommitMessage(org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage) NewResourceSuccessEvent(org.kie.workbench.common.widgets.client.handlers.NewResourceSuccessEvent) Callback(com.google.gwt.core.client.Callback) Message(org.jboss.errai.bus.client.api.messaging.Message) Caller(org.jboss.errai.common.client.api.Caller) AssetsScreen(org.kie.workbench.common.screens.library.client.screens.assets.AssetsScreen) PostConstruct(javax.annotation.PostConstruct) ProjectController(org.guvnor.common.services.project.client.security.ProjectController) WorkbenchPartView(org.uberfire.client.annotations.WorkbenchPartView) LibraryPerspective(org.kie.workbench.common.screens.library.client.perspective.LibraryPerspective) UberElemental(org.uberfire.client.mvp.UberElemental) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Aggregations

Path (org.uberfire.backend.vfs.Path)4 CommandWithFileNameAndCommitMessage (org.uberfire.ext.editor.commons.client.file.CommandWithFileNameAndCommitMessage)4 FileNameAndCommitMessage (org.uberfire.ext.editor.commons.client.file.FileNameAndCommitMessage)4 Validator (org.uberfire.ext.editor.commons.client.validation.Validator)3 Callback (com.google.gwt.core.client.Callback)1 HTMLElement (elemental2.dom.HTMLElement)1 Promise (elemental2.promise.Promise)1 PostConstruct (javax.annotation.PostConstruct)1 Event (javax.enterprise.event.Event)1 Observes (javax.enterprise.event.Observes)1 Inject (javax.inject.Inject)1 ProjectController (org.guvnor.common.services.project.client.security.ProjectController)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 ViewHideAlertsButtonPresenter (org.guvnor.messageconsole.client.console.widget.button.ViewHideAlertsButtonPresenter)1 OrganizationalUnitController (org.guvnor.structure.client.security.OrganizationalUnitController)1 AfterEditOrganizationalUnitEvent (org.guvnor.structure.events.AfterEditOrganizationalUnitEvent)1 Message (org.jboss.errai.bus.client.api.messaging.Message)1 Caller (org.jboss.errai.common.client.api.Caller)1 Elemental2DomUtil (org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil)1 ManagedInstance (org.jboss.errai.ioc.client.api.ManagedInstance)1