Search in sources :

Example 41 with NotificationEvent

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

the class SettingsScreenPresenter method setupUsingCurrentSection.

public Promise<Void> setupUsingCurrentSection() {
    this.view.init(this);
    showBusyIndicator(ts.getTranslation(LibraryConstants.Loading));
    view.enableActions(canUpdate());
    return setupSections(new SpaceScreenModel()).then(o -> {
        hideBusyIndicator();
        if (sectionManager.manages(sectionManager.getCurrentSection())) {
            return sectionManager.goToCurrentSection();
        } else {
            return sectionManager.goToFirstAvailable();
        }
    }).catch_(o -> promises.catchOrExecute(o, e -> {
        hideBusyIndicator();
        return promises.reject(e);
    }, i -> {
        notificationEvent.fire(new NotificationEvent(ts.getTranslation(LibraryConstants.SettingsLoadError), ERROR));
        hideBusyIndicator();
        return promises.resolve();
    }));
}
Also used : HasBusyIndicator(org.uberfire.ext.widgets.common.client.common.HasBusyIndicator) SectionManager(org.kie.workbench.common.screens.library.client.settings.util.sections.SectionManager) Promises(org.uberfire.client.promise.Promises) SpaceSettings(org.kie.workbench.common.screens.library.client.screens.organizationalunit.settings.annotation.SpaceSettings) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Promise(elemental2.promise.Promise) Supplier(java.util.function.Supplier) SettingsSectionChange(org.kie.workbench.common.screens.library.client.settings.SettingsSectionChange) ArrayList(java.util.ArrayList) SettingsSectionChangeType(org.kie.workbench.common.screens.library.client.settings.SettingsSectionChangeType) Inject(javax.inject.Inject) ERROR(org.uberfire.workbench.events.NotificationEvent.NotificationType.ERROR) HTMLElement(elemental2.dom.HTMLElement) Observes(javax.enterprise.event.Observes) SettingsSections(org.kie.workbench.common.screens.library.client.settings.sections.SettingsSections) OrganizationalUnitController(org.guvnor.structure.client.security.OrganizationalUnitController) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) LibraryConstants(org.kie.workbench.common.screens.library.client.resources.i18n.LibraryConstants) BusyIndicatorView(org.uberfire.ext.widgets.common.client.common.BusyIndicatorView) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) WARNING(org.uberfire.workbench.events.NotificationEvent.NotificationType.WARNING) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) SpaceScreenModel(org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) Dependent(javax.enterprise.context.Dependent) SUCCESS(org.uberfire.workbench.events.NotificationEvent.NotificationType.SUCCESS) PostConstruct(javax.annotation.PostConstruct) Section(org.kie.workbench.common.screens.library.client.settings.util.sections.Section) UberElement(org.uberfire.client.mvp.UberElement) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) SpaceScreenModel(org.kie.workbench.common.screens.library.api.settings.SpaceScreenModel)

Example 42 with NotificationEvent

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

the class LibraryScreen method setDescriptionChanged.

private void setDescriptionChanged(OrganizationalUnit organizationalUnit) {
    view.setDescription(organizationalUnit.getDescription());
    notificationEvent.fire(new NotificationEvent(translationService.format(LibraryConstants.SpaceDescriptionChanged, organizationalUnit.getName()), NotificationEvent.NotificationType.SUCCESS));
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Example 43 with NotificationEvent

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

the class ServerManagementBrowserPresenter method onContainerUpdate.

public void onContainerUpdate(@Observes final ContainerUpdateEvent containerUpdateEvent) {
    if (containerUpdateEvent != null && containerUpdateEvent.getContainerRuntimeOperation() != null && containerUpdateEvent.getContainerRuntimeState() != null && containerUpdateEvent.getFailedServerInstances().size() > 0) {
        final ClientContainerRuntimeOperation containerRuntimeOperation = ClientContainerRuntimeOperation.convert(containerUpdateEvent.getContainerRuntimeOperation());
        final String message;
        final NotificationEvent.NotificationType notificationType;
        switch(containerUpdateEvent.getContainerRuntimeState()) {
            case OFFLINE:
                message = view.getErrorMessage(containerRuntimeOperation, containerUpdateEvent.getFailedServerInstances().size());
                notificationType = NotificationEvent.NotificationType.ERROR;
                break;
            case PARTIAL_ONLINE:
                message = view.getWarnMessage(containerRuntimeOperation, containerUpdateEvent.getFailedServerInstances().size());
                notificationType = NotificationEvent.NotificationType.WARNING;
                break;
            case ONLINE:
                message = view.getSuccessMessage(containerRuntimeOperation, containerUpdateEvent.getFailedServerInstances().size());
                notificationType = NotificationEvent.NotificationType.SUCCESS;
                break;
            default:
                message = null;
                notificationType = null;
                break;
        }
        if (message != null) {
            notification.fire(new NotificationEvent(message, notificationType));
        }
    } else {
        logger.warn("Illegal event argument.");
    }
}
Also used : NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ClientContainerRuntimeOperation(org.kie.workbench.common.screens.server.management.client.util.ClientContainerRuntimeOperation)

Example 44 with NotificationEvent

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

the class ContainerPresenter method toggleActivationContainer.

public void toggleActivationContainer() {
    if (containerSpec.getStatus().equals(KieContainerStatus.DEACTIVATED)) {
        specManagementService.call(new RemoteCallback<Void>() {

            @Override
            public void callback(final Void response) {
                refresh();
            }
        }, new ErrorCallback<Object>() {

            @Override
            public boolean error(final Object o, final Throwable throwable) {
                notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR));
                refresh();
                return false;
            }
        }).activateContainer(containerSpec);
    } else if (containerSpec.getStatus().equals(KieContainerStatus.STARTED)) {
        specManagementService.call(new RemoteCallback<Void>() {

            @Override
            public void callback(final Void response) {
                refresh();
            }
        }, new ErrorCallback<Object>() {

            @Override
            public boolean error(final Object o, final Throwable throwable) {
                notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR));
                refresh();
                return false;
            }
        }).deactivateContainer(containerSpec);
    }
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 45 with NotificationEvent

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

the class ContainerPresenter method startContainer.

public void startContainer() {
    specManagementService.call(new RemoteCallback<Void>() {

        @Override
        public void callback(final Void response) {
            refresh();
        }
    }, new ErrorCallback<Object>() {

        @Override
        public boolean error(final Object o, final Throwable throwable) {
            notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR));
            refresh();
            return false;
        }
    }).startContainer(containerSpec);
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

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