Search in sources :

Example 1 with ClientContainerRuntimeOperation

use of org.kie.workbench.common.screens.server.management.client.util.ClientContainerRuntimeOperation 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)

Aggregations

ClientContainerRuntimeOperation (org.kie.workbench.common.screens.server.management.client.util.ClientContainerRuntimeOperation)1 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)1