use of org.ovirt.engine.ui.common.widget.uicommon.tasks.ToastNotification in project ovirt-engine by oVirt.
the class TasksPresenterWidget method onBind.
@SuppressWarnings("unchecked")
@Override
public void onBind() {
super.onBind();
taskModelProvider.getModel().getItemsChangedEvent().addListener(new IEventListener<EventArgs>() {
@Override
public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
getView().updateTaskStatus(taskModelProvider.getModel());
Collection<Job> jobs = taskModelProvider.getModel().getItems();
jobs.forEach(job -> {
String id = job.getCorrelationId().startsWith(TaskListModel.WEBADMIN) ? job.getCorrelationId() : job.getId().toString();
if (JobExecutionStatus.STARTED.equals(job.getStatus())) {
// Since its a set, it will be replaced when its a duplicate.
runningTasks.add(id);
} else if (JobExecutionStatus.FINISHED.equals(job.getStatus()) || JobExecutionStatus.FAILED.equals(job.getStatus()) || JobExecutionStatus.ABORTED.equals(job.getStatus())) {
if (runningTasks.contains(id) || (ACTION_TYPE_WHITELIST.contains(job.getActionType()) && job.getEndTime().after(lastNotificationDate))) {
ToastNotification notification = ToastNotification.createNotification(// $NON-NLS-1$
getPrefixText(job.getStatus()) + " " + job.getDescription());
notification.setStatus(getNotificationStatus(job.getStatus()));
}
runningTasks.remove(id);
}
lastNotificationDate = new Date();
});
}
});
}
Aggregations