use of org.ovirt.engine.ui.uicommonweb.models.events.AlertListModel 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);
}
});
}
Aggregations