Search in sources :

Example 1 with Timer

use of io.jmix.ui.component.Timer in project jmix by jmix-framework.

the class DashboardImpl method initTimer.

private void initTimer(Component frame) {
    Window parentWindow = findWindow(frame);
    int timerDelay = getTimerDelay() == 0 ? dashboardModel.getTimerDelay() : getTimerDelay();
    if (timerDelay > 0 && parentWindow != null) {
        Timer dashboardUpdatedTimer = facets.create(Timer.class);
        dashboardUpdatedTimer.setOwner(getFrame());
        dashboardUpdatedTimer.setDelay(timerDelay * 1000);
        dashboardUpdatedTimer.setRepeating(true);
        dashboardUpdatedTimer.addTimerActionListener(timer -> uiEventPublisher.publishEvent(new DashboardUpdatedEvent(dashboardModel)));
        dashboardUpdatedTimer.start();
    }
}
Also used : Timer(io.jmix.ui.component.Timer) DashboardUpdatedEvent(io.jmix.dashboardsui.event.DashboardUpdatedEvent)

Aggregations

DashboardUpdatedEvent (io.jmix.dashboardsui.event.DashboardUpdatedEvent)1 Timer (io.jmix.ui.component.Timer)1