Search in sources :

Example 36 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class AddProjectPopUpPresenterTest method createProjectCallbackAfterProjectIndexedEventTest.

@Test
public void createProjectCallbackAfterProjectIndexedEventTest() {
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Path projectRootPath = mock(Path.class);
    doReturn(projectRootPath).when(project).getRootPath();
    doReturn(project).when(projectService).resolveProject(any(Path.class));
    doReturn(project).when(libraryService).createProject(any(), any(), any(), Mockito.<String>any());
    doReturn("test").when(view).getName();
    doReturn("description").when(view).getDescription();
    presenter.onProjectIndexingFinishedEvent(new IndexingFinishedEvent("kClusterId", projectRootPath));
    presenter.add();
    verify(view).setAddButtonEnabled(false);
    verify(view).showBusyIndicator(Mockito.<String>any());
    verify(view).setAddButtonEnabled(true);
    verify(view).hide();
    verify(notificationEvent).fire(any(NotificationEvent.class));
    verify(libraryPlaces).goToProject(project);
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) IndexingFinishedEvent(org.kie.workbench.common.services.refactoring.model.index.events.IndexingFinishedEvent) Test(org.junit.Test)

Example 37 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class BPMNProjectBaseSessionDiagramHandlerTest method verifySaveOrUpdateWithErrors.

protected void verifySaveOrUpdateWithErrors() {
    verify(selectionControl).clearSelection();
    when(translationService.getValue(EditorGenerateSvgFileError)).thenReturn(EditorGenerateSvgFileError);
    verify(diagramService).saveOrUpdateSvg(eq(path), eq(SVG), serviceCallbackCaptor.capture());
    serviceCallbackCaptor.getValue().onError(new ClientRuntimeError("some error"));
    verify(notificationEvent).fire(new NotificationEvent(EditorGenerateSvgFileError, NotificationEvent.NotificationType.ERROR));
}
Also used : ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Example 38 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class VariableListItemWidgetViewImpl method init.

@PostConstruct
public void init() {
    name.setRegExp(StringUtils.ALPHA_NUM_REGEXP, StunnerFormsClientFieldsConstants.CONSTANTS.Removed_invalid_characters_from_name(), StunnerFormsClientFieldsConstants.CONSTANTS.Invalid_character_in_name());
    name.addChangeHandler(event -> {
        String value = name.getText();
        if (isDuplicateName(value)) {
            notification.fire(new NotificationEvent(StunnerFormsClientFieldsConstants.CONSTANTS.DuplicatedVariableNameError(value), NotificationEvent.NotificationType.ERROR));
            name.setValue(currentName);
            ValueChangeEvent.fire(name, currentName);
        } else if (isBoundToNodes(currentName)) {
            errorPopupPresenter.showMessage(StunnerFormsClientFieldsConstants.CONSTANTS.RenameDiagramVariableError());
            name.setValue(currentName);
            ValueChangeEvent.fire(name, currentName);
        }
        notifyModelChanged();
    });
    dataTypeComboBox.init(this, true, dataType, customDataType, false, true, CUSTOM_PROMPT, ENTER_TYPE_PROMPT);
    customDataType.setRegExp(StringUtils.ALPHA_NUM_UNDERSCORE_DOT_REGEXP, StunnerFormsClientFieldsConstants.CONSTANTS.Removed_invalid_characters_from_name(), StunnerFormsClientFieldsConstants.CONSTANTS.Invalid_character_in_name());
    customDataType.addKeyDownHandler(this::preventSpaces);
    PopOver.jQuery(variableTagsSettings).popovers();
    setTagTittle("Tags: ");
    variableTagsSettings.onclick = e -> {
        e.preventDefault();
        openOverlayActions();
        return null;
    };
    customTagName.addFocusHandler(focusEvent -> setPreviousCustomValue(customTagName.getValue()));
    customTagName.addKeyDownHandler(this::preventSpaces);
    loadDefaultTagNames();
    setTagsListItems();
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) PostConstruct(javax.annotation.PostConstruct)

Example 39 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class ContributorsListItemPresenter method save.

public void save() {
    final Contributor contributor = new Contributor(view.getName(), view.getRole());
    contributorsListService.getContributors(currentContributors -> {
        isValid(contributor, currentContributors).then(isValid -> {
            if (isValid) {
                final List<Contributor> updatedContributors = new ArrayList<>();
                if (persistedContributor == null) {
                    updatedContributors.addAll(currentContributors);
                } else {
                    updatedContributors.addAll(currentContributors.stream().filter(c -> !c.equals(persistedContributor)).collect(Collectors.toList()));
                }
                updatedContributors.add(contributor);
                view.showBusyIndicator(view.getSavingMessage());
                contributorsListService.saveContributors(updatedContributors, () -> {
                    persistedContributor = contributor;
                    view.setupViewMode(contributor);
                    parentPresenter.itemIsNotBeingEdited();
                    view.hideBusyIndicator();
                    notificationEvent.fire(new NotificationEvent(view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
                    parentPresenter.refresh();
                }, new HasBusyIndicatorDefaultErrorCallback(view));
            }
            return promises.resolve();
        });
    });
}
Also used : ArrayList(java.util.ArrayList) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) Contributor(org.uberfire.security.Contributor) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Example 40 with NotificationEvent

use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.

the class ContributorsListItemPresenter method remove.

public void remove() {
    canRemoveContributor().then(canRemoveContributor -> {
        if (canRemoveContributor) {
            contributorsListService.getContributors(contributors -> {
                if (isLastOwner(persistedContributor, contributors)) {
                    notificationEvent.fire(new NotificationEvent(view.getSingleOwnerIsMandatoryMessage(), NotificationEvent.NotificationType.ERROR));
                } else {
                    contributors.remove(persistedContributor);
                    view.showBusyIndicator(view.getSavingMessage());
                    contributorsListService.saveContributors(contributors, () -> {
                        view.hideBusyIndicator();
                        notificationEvent.fire(new NotificationEvent(view.getRemoveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
                        view.removeContributor();
                        parentPresenter.refresh();
                    }, new HasBusyIndicatorDefaultErrorCallback(view));
                }
            });
        }
        return promises.resolve();
    });
}
Also used : HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Aggregations

NotificationEvent (org.uberfire.workbench.events.NotificationEvent)151 Test (org.junit.Test)65 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)34 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)28 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)22 ServerTemplateList (org.kie.server.controller.api.model.spec.ServerTemplateList)21 List (java.util.List)17 Path (org.uberfire.backend.vfs.Path)17 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)16 ArrayList (java.util.ArrayList)14 Event (javax.enterprise.event.Event)14 Inject (javax.inject.Inject)12 ObservablePath (org.uberfire.backend.vfs.ObservablePath)12 PostConstruct (javax.annotation.PostConstruct)9 Observes (javax.enterprise.event.Observes)9 Caller (org.jboss.errai.common.client.api.Caller)9 Map (java.util.Map)8 Promise (elemental2.promise.Promise)7 Arrays (java.util.Arrays)7 Dependent (javax.enterprise.context.Dependent)7