Search in sources :

Example 1 with EventListModel

use of org.ovirt.engine.ui.uicommonweb.models.events.EventListModel in project ovirt-engine by oVirt.

the class HeaderPresenterWidget method onBind.

@SuppressWarnings("unchecked")
@Override
protected void onBind() {
    super.onBind();
    registerHandler(getView().getLogoutLink().addClickHandler(event -> user.logout()));
    registerHandler(getView().getGuideLink().addClickHandler(event -> WebUtils.openUrlInNewWindow(windowName, guideUrl)));
    registerHandler(getView().getOptionsLink().addClickHandler(event -> {
        OptionsModel model = optionsProvider.getModel();
        model.executeCommand(model.getEditCommand());
    }));
    registerHandler(getView().getAboutLink().addClickHandler(event -> RevealRootPopupContentEvent.fire(HeaderPresenterWidget.this, aboutPopupProvider.get())));
    registerHandler(getView().getTasksWidget().addClickHandler(event -> toggleOverlayPresenter(tasksPresenter)));
    registerHandler(getView().getBookmarkLink().addClickHandler(event -> toggleOverlayPresenter(bookmarksPresenter)));
    registerHandler(getView().getTagsLink().addClickHandler(event -> toggleOverlayPresenter(tagsPresenter)));
    getView().getAlertActionWidget().addAction(constants.dismissAlert(), this.alertModelProvider.getModel().getDismissCommand(), (command, log) -> {
        AlertListModel model = alertModelProvider.getModel();
        if (log != null) {
            model.setSelectedItem(log);
            model.executeCommand(command);
        }
    });
    getView().getAlertActionWidget().addClearAllAction(constants.clearAllDismissedAlerts(), this.alertModelProvider.getModel().getClearAllCommand(), (command, log) -> alertModelProvider.getModel().executeCommand(command));
    getView().getAlertActionWidget().addRestoreAllAction(constants.displayAllDismissedAlerts(), this.alertModelProvider.getModel().getDisplayAllCommand(), (command, log) -> alertModelProvider.getModel().executeCommand(command));
    getView().getEventActionWidget().addAction(constants.dismissEvent(), this.eventModelProvider.getModel().getDismissCommand(), (command, log) -> {
        EventListModel<?> model = eventModelProvider.getModel();
        if (log != null) {
            model.setSelectedItem(log);
            model.executeCommand(command);
        }
    });
    getView().getEventActionWidget().addClearAllAction(constants.clearAllDismissedEvents(), this.eventModelProvider.getModel().getClearAllCommand(), (command, log) -> eventModelProvider.getModel().executeCommand(command));
    getView().getEventActionWidget().addRestoreAllAction(constants.displayAllDismissedEvents(), this.eventModelProvider.getModel().getDisplayAllCommand(), (command, log) -> eventModelProvider.getModel().executeCommand(command));
    taskModelProvider.getModel().getItemsChangedEvent().addListener(new IEventListener<EventArgs>() {

        @Override
        public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
            Collection<Job> jobs = taskModelProvider.getModel().getItems();
            long count = jobs.stream().filter(job -> JobExecutionStatus.STARTED.equals(job.getStatus())).count();
            // I know I will never have more than 100 items, so I can cast to int.
            getView().setRunningTaskCount((int) count);
        }
    });
    alertModelProvider.getModel().getItemsChangedEvent().addListener(new IEventListener<EventArgs>() {

        @Override
        public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
            Collection<AuditLog> alerts = alertModelProvider.getModel().getItems();
            long count = alerts.stream().filter(alert -> AuditLogSeverity.ALERT.equals(alert.getSeverity())).count();
            // I know I will never have more than 100 items, so I can cast to int.
            getView().setAlertCount((int) count);
        }
    });
}
Also used : RevealRootPopupContentEvent(com.gwtplatform.mvp.client.proxy.RevealRootPopupContentEvent) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) Job(org.ovirt.engine.core.common.job.Job) Inject(com.google.inject.Inject) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) Event(org.ovirt.engine.ui.uicompat.Event) EventModelProvider(org.ovirt.engine.ui.webadmin.uicommon.model.EventModelProvider) EventListModel(org.ovirt.engine.ui.uicommonweb.models.events.EventListModel) AlertModelProvider(org.ovirt.engine.ui.webadmin.uicommon.model.AlertModelProvider) ActionWidget(org.ovirt.engine.ui.webadmin.widget.alert.ActionWidget) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) BookmarkPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.overlay.BookmarkPresenterWidget) OptionsModel(org.ovirt.engine.ui.uicommonweb.models.OptionsModel) TagsPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.overlay.TagsPresenterWidget) AlertListModel(org.ovirt.engine.ui.uicommonweb.models.events.AlertListModel) PresenterWidget(com.gwtplatform.mvp.client.PresenterWidget) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) TasksPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.overlay.TasksPresenterWidget) CurrentUser(org.ovirt.engine.ui.common.auth.CurrentUser) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) WebUtils(org.ovirt.engine.ui.common.utils.WebUtils) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) HasData(com.google.gwt.view.client.HasData) EventBus(com.google.gwt.event.shared.EventBus) View(com.gwtplatform.mvp.client.View) Collection(java.util.Collection) OptionsProvider(org.ovirt.engine.ui.common.uicommon.model.OptionsProvider) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) HasClickHandlers(com.google.gwt.event.dom.client.HasClickHandlers) Provider(com.google.inject.Provider) TaskModelProvider(org.ovirt.engine.ui.webadmin.uicommon.model.TaskModelProvider) AuditLogSeverity(org.ovirt.engine.core.common.AuditLogSeverity) ApplicationDynamicMessages(org.ovirt.engine.ui.webadmin.ApplicationDynamicMessages) Named(com.google.inject.name.Named) AlertListModel(org.ovirt.engine.ui.uicommonweb.models.events.AlertListModel) Collection(java.util.Collection) OptionsModel(org.ovirt.engine.ui.uicommonweb.models.OptionsModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs)

Aggregations

HasClickHandlers (com.google.gwt.event.dom.client.HasClickHandlers)1 EventBus (com.google.gwt.event.shared.EventBus)1 SafeHtmlUtils (com.google.gwt.safehtml.shared.SafeHtmlUtils)1 HasData (com.google.gwt.view.client.HasData)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Named (com.google.inject.name.Named)1 PresenterWidget (com.gwtplatform.mvp.client.PresenterWidget)1 View (com.gwtplatform.mvp.client.View)1 RevealRootPopupContentEvent (com.gwtplatform.mvp.client.proxy.RevealRootPopupContentEvent)1 Collection (java.util.Collection)1 AuditLogSeverity (org.ovirt.engine.core.common.AuditLogSeverity)1 AuditLog (org.ovirt.engine.core.common.businessentities.AuditLog)1 Job (org.ovirt.engine.core.common.job.Job)1 JobExecutionStatus (org.ovirt.engine.core.common.job.JobExecutionStatus)1 CurrentUser (org.ovirt.engine.ui.common.auth.CurrentUser)1 OptionsProvider (org.ovirt.engine.ui.common.uicommon.model.OptionsProvider)1 WebUtils (org.ovirt.engine.ui.common.utils.WebUtils)1 OptionsModel (org.ovirt.engine.ui.uicommonweb.models.OptionsModel)1 AlertListModel (org.ovirt.engine.ui.uicommonweb.models.events.AlertListModel)1