Search in sources :

Example 6 with NotificationEvent

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

the class OrganizationalUnitPopUpPresenter method saveCreation.

void saveCreation(final String name, final String defaultGroupId, final String owner) {
    final Command saveCommand = () -> {
        final Collection<Repository> repositories = new ArrayList<>();
        final List<String> contributors = contributorsManagementPresenter.getSelectedContributorsUserNames();
        final RemoteCallback<OrganizationalUnit> successCallback = (OrganizationalUnit newOrganizationalUnit) -> {
            afterCreateOrganizationalUnitEvent.fire(new AfterCreateOrganizationalUnitEvent(newOrganizationalUnit));
            view.hideBusyIndicator();
            notificationEvent.fire(new NotificationEvent(view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
            view.hide();
        };
        final HasBusyIndicatorDefaultErrorCallback errorCallback = new HasBusyIndicatorDefaultErrorCallback(view);
        organizationalUnitService.call(successCallback, errorCallback).createOrganizationalUnit(name, owner, defaultGroupId, repositories, contributors);
    };
    validateDuplicatedOrganizationalUnit(name, saveCommand);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Command(org.uberfire.mvp.Command) AfterCreateOrganizationalUnitEvent(org.guvnor.structure.events.AfterCreateOrganizationalUnitEvent) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 7 with NotificationEvent

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

the class AssignmentListItemWidgetViewImplTest method testNameBlurHandler.

@Test
public void testNameBlurHandler() {
    ActivityDataIOEditorWidget parent = mock(ActivityDataIOEditorWidget.class);
    when(parent.isDuplicateName(anyString())).thenReturn(true);
    doReturn("anyName").when(name).getText();
    view.setAllowDuplicateNames(false, "ErrorMessage");
    view.setParentWidget(parent);
    view.init();
    verify(name, times(1)).addBlurHandler(blurHandlerCaptor.capture());
    BlurHandler handler = blurHandlerCaptor.getValue();
    handler.onBlur(mock(BlurEvent.class));
    verify(parent, times(1)).isDuplicateName("anyName");
    verify(notification, times(1)).fire(new NotificationEvent("ErrorMessage", NotificationEvent.NotificationType.ERROR));
    verify(name, times(1)).setValue("");
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) Test(org.junit.Test)

Example 8 with NotificationEvent

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

the class VariableListItemWidgetViewImplTest method testNameBlurHandler.

@Test
public void testNameBlurHandler() {
    VariablesEditorWidgetView.Presenter parent = mock(VariablesEditorWidgetView.Presenter.class);
    when(parent.isDuplicateName(anyString())).thenReturn(true);
    doReturn("anyName").when(name).getText();
    view.setParentWidget(parent);
    view.init();
    verify(name, times(1)).addBlurHandler(blurHandlerCaptor.capture());
    BlurHandler handler = blurHandlerCaptor.getValue();
    handler.onBlur(mock(BlurEvent.class));
    verify(parent, times(1)).isDuplicateName("anyName");
    verify(notification, times(1)).fire(new NotificationEvent(null, NotificationEvent.NotificationType.ERROR));
    verify(name, times(1)).setValue("");
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) Test(org.junit.Test)

Example 9 with NotificationEvent

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

the class DecisionTableXLSEditorViewImplTest method testSubmit.

@Test
public void testSubmit() throws Exception {
    Path path = mock(Path.class);
    view.setupUploadWidget(type);
    view.submit(path);
    verify(attachmentFileWidget).submit(eq(path), eq(SERVLET_URL), commandCaptor.capture(), any(Command.class));
    commandCaptor.getValue().execute();
    verify(notificationEvent).fire(any(NotificationEvent.class));
    verify(presenter).onUploadSuccess();
}
Also used : Path(org.uberfire.backend.vfs.Path) Command(com.google.gwt.user.client.Command) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Test(org.junit.Test)

Example 10 with NotificationEvent

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

the class EnableProviderTypeWizard method onEnableTypesError.

private boolean onEnableTypesError() {
    notification.fire(new NotificationEvent(translationService.getTranslation(EnableProviderTypeWizard_ProviderTypeEnableErrorMessage), NotificationEvent.NotificationType.ERROR));
    start();
    return false;
}
Also used : 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