Search in sources :

Example 1 with ScreenOpenedEvent

use of com.haulmont.cuba.gui.screen.event.ScreenOpenedEvent in project cuba by cuba-platform.

the class WebScreens method show.

@Override
public OperationResult show(Screen screen) {
    checkNotNullArgument(screen);
    checkNotYetOpened(screen);
    if (isMaxTabCountExceeded(screen)) {
        showTooManyOpenTabsMessage();
        return OperationResult.fail();
    }
    StopWatch uiPermissionsWatch = createStopWatch(ScreenLifeCycle.UI_PERMISSIONS, screen.getId());
    windowCreationHelper.applyUiPermissions(screen.getWindow());
    uiPermissionsWatch.stop();
    StopWatch beforeShowWatch = createStopWatch(ScreenLifeCycle.BEFORE_SHOW, screen.getId());
    applyDataLoadingSettings(screen);
    fireEvent(screen, BeforeShowEvent.class, new BeforeShowEvent(screen));
    loadDataBeforeShow(screen);
    beforeShowWatch.stop();
    LaunchMode launchMode = screen.getWindow().getContext().getLaunchMode();
    if (launchMode instanceof OpenMode) {
        OpenMode openMode = (OpenMode) launchMode;
        switch(openMode) {
            case ROOT:
                showRootWindow(screen);
                break;
            case THIS_TAB:
                showThisTabWindow(screen);
                break;
            case NEW_WINDOW:
            case NEW_TAB:
                showNewTabWindow(screen);
                break;
            case DIALOG:
                showDialogWindow(screen);
                break;
            default:
                throw new UnsupportedOperationException("Unsupported OpenMode " + openMode);
        }
    }
    userActionsLog.trace("Screen {} {} opened", screen.getId(), screen.getClass());
    afterShowWindow(screen);
    changeUrl(screen);
    StopWatch afterShowWatch = createStopWatch(ScreenLifeCycle.AFTER_SHOW, screen.getId());
    fireEvent(screen, AfterShowEvent.class, new AfterShowEvent(screen));
    afterShowWatch.stop();
    events.publish(new ScreenOpenedEvent(screen));
    screenProfiler.initProfilerMarkerForWindow(screen.getId());
    return OperationResult.success();
}
Also used : ScreenOpenedEvent(com.haulmont.cuba.gui.screen.event.ScreenOpenedEvent) UIPerformanceLogger.createStopWatch(com.haulmont.cuba.gui.logging.UIPerformanceLogger.createStopWatch) StopWatch(org.perf4j.StopWatch)

Aggregations

UIPerformanceLogger.createStopWatch (com.haulmont.cuba.gui.logging.UIPerformanceLogger.createStopWatch)1 ScreenOpenedEvent (com.haulmont.cuba.gui.screen.event.ScreenOpenedEvent)1 StopWatch (org.perf4j.StopWatch)1