Search in sources :

Example 1 with GuiStack

use of org.olat.core.gui.control.guistack.GuiStack in project openolat by klemens.

the class BaseFullWebappController method popTheTabState.

private void popTheTabState(UserRequest ureq) {
    if (siteAndTabs.isEmpty() && sites != null) {
        SiteInstance firstSite = sites.get(0);
        BornSiteInstance bs = siteToBornSite.get(firstSite);
        if (bs == null) {
            activateSite(firstSite, ureq, null, false);
        } else {
            doActivateSite(firstSite, bs.getGuiStackHandle());
        }
    } else if (!siteAndTabs.isEmpty()) {
        TabState state = siteAndTabs.remove(siteAndTabs.size() - 1);
        if (state.getSite() != null) {
            // latest selected static tab
            // activate previous chosen static site -> this site has already been
            // constructed and is thus in the cache
            SiteInstance si = state.getSite();
            BornSiteInstance bs = siteToBornSite.get(si);
            // bs != null since clicked previously
            GuiStack gsh = bs.getGuiStackHandle();
            doActivateSite(si, gsh);
            if (siteToBusinessPath.containsValue(si)) {
                ureq.getUserSession().addToHistory(ureq, siteToBusinessPath.get(si));
            }
        } else if (state.getDtab() != null && !state.getDtab().getController().isDisposed()) {
            DTab tab = state.getDtab();
            doActivateDTab(tab);
            if (dtabToBusinessPath.containsKey(tab)) {
                ureq.getUserSession().addToHistory(ureq, dtabToBusinessPath.get(tab));
            }
        } else {
            popTheTabState(ureq);
        }
    }
}
Also used : BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) SiteInstance(org.olat.core.gui.control.navigation.SiteInstance) DTab(org.olat.core.gui.control.generic.dtabs.DTab) BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) GuiStack(org.olat.core.gui.control.guistack.GuiStack)

Example 2 with GuiStack

use of org.olat.core.gui.control.guistack.GuiStack in project openolat by klemens.

the class BaseFullWebappController method activateSite.

/**
 * Activate a site if not locked
 *
 * @param s
 * @param ureq
 * @param entries
 * @param forceReload
 */
private void activateSite(SiteInstance s, UserRequest ureq, List<ContextEntry> entries, boolean forceReload) {
    if (lockResource != null)
        return;
    BornSiteInstance bs = siteToBornSite.get(s);
    GuiStack gs;
    Controller resC;
    // PB//WindowControl site_wControl;
    if (bs != null && s != curSite) {
        // single - click -> fetch guistack from cache
        gs = bs.getGuiStackHandle();
        resC = bs.getController();
    } else if (bs != null && s == curSite && !forceReload) {
        // via activate, don't force the reload
        gs = bs.getGuiStackHandle();
        resC = bs.getController();
    } else {
        // dispose old controller
        if (bs != null) {
            // already in cache -> dispose old
            bs.getController().dispose();
        }
        // reset site and create new controller
        s.reset();
        resC = s.createController(ureq, getWindowControl());
        gs = getWindowControl().getWindowBackOffice().createGuiStack(resC.getInitialComponent());
        // PB//site_wControl = bwControl;
        // PB//siteToBornSite.put(s, new BornSiteInstance(gs, resC, bwControl));
        siteToBornSite.put(s, new BornSiteInstance(gs, resC));
    }
    doActivateSite(s, gs);
    if (resC instanceof Activateable2) {
        ((Activateable2) resC).activate(ureq, entries, null);
    }
    // perhaps has activation changed the gui stack and it need to be updated
    setGuiStack(gs);
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) GuiStack(org.olat.core.gui.control.guistack.GuiStack) ResumeSessionController(org.olat.core.commons.controllers.resume.ResumeSessionController) AssessmentModeGuardController(org.olat.course.assessment.ui.mode.AssessmentModeGuardController) BasicController(org.olat.core.gui.control.controller.BasicController) ChiefController(org.olat.core.gui.control.ChiefController) BaseChiefController(org.olat.core.commons.chiefcontrollers.BaseChiefController) VetoableCloseController(org.olat.core.gui.control.VetoableCloseController) Controller(org.olat.core.gui.control.Controller) UserToolsMenuController(org.olat.gui.control.UserToolsMenuController)

Example 3 with GuiStack

use of org.olat.core.gui.control.guistack.GuiStack in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method initialize.

private void initialize(UserRequest ureq) {
    mainVc = createVelocityContainer("fullwebapplayout");
    mainVc.contextPut("screenMode", screenMode);
    LayoutModule layoutModule = CoreSpringFactory.getImpl(LayoutModule.class);
    LandingPagesModule landingPagesModule = CoreSpringFactory.getImpl(LandingPagesModule.class);
    LogoInformations logoInfos = new LogoInformations(ureq, layoutModule, landingPagesModule);
    mainVc.contextPut("logoInfos", logoInfos);
    // use separate container for navigation to prevent full page refresh in ajax mode on site change
    // nav is not a controller part because it is a fundamental part of the BaseFullWebAppConroller.
    navSitesVc = createVelocityContainer("nav_sites");
    navSitesVc.setDomReplacementWrapperRequired(false);
    navSitesVc.contextPut("visible", Boolean.TRUE);
    mainVc.put("sitesComponent", navSitesVc);
    navTabsVc = createVelocityContainer("nav_tabs");
    navTabsVc.setDomReplacementWrapperRequired(false);
    mainVc.put("tabsComponent", navTabsVc);
    // GUI messages
    guimsgVc = createVelocityContainer("guimsg");
    guimsgVc.contextPut("guiMessage", guiMessage);
    guimsgHolder = new Panel("guimsgholder");
    guimsgHolder.setContent(guimsgPanel);
    currentMsgHolder = guimsgHolder;
    mainVc.put("guimessage", guimsgHolder);
    // CSS panel
    cssHolder = new Panel("customCss");
    mainVc.put("customCssHolder", cssHolder);
    // sticky maintenance message
    stickyMessageCmp = new StickyMessageComponent("stickymsg", screenMode);
    mainVc.put("stickymsg", stickyMessageCmp);
    updateStickyMessage();
    dtabs = new ArrayList<>();
    dtabsLinkNames = new ArrayList<>();
    dtabsControllers = new ArrayList<>();
    // -- sites -- by definition the first site is activated at the beginning
    userTools = new HomeSite(null);
    sites = baseFullWebappControllerParts.getSiteInstances(ureq, getWindowControl());
    if (sites != null && sites.size() == 0) {
        sites = null;
    }
    List<String> siteLinks = new ArrayList<>();
    // either sites is null or contains at least one SiteInstance.
    if (sites != null) {
        // create the links for the sites
        for (Iterator<SiteInstance> iterator = sites.iterator(); iterator.hasNext(); ) {
            SiteInstance si = iterator.next();
            NavElement navEl = si.getNavElement();
            if (navEl != null) {
                String linkName = "t" + CodeHelper.getRAMUniqueID();
                siteLinks.add(linkName);
                Link link = LinkFactory.createCustomLink(linkName, "t", "", Link.NONTRANSLATED, navSitesVc, this);
                link.setCustomDisplayText(navEl.getTitle());
                link.setTitle(navEl.getDescription());
                link.setUserObject(si);
                Character accessKey = navEl.getAccessKey();
                if (accessKey != null && StringHelper.containsNonWhitespace(accessKey.toString())) {
                    link.setAccessKey(accessKey.toString());
                }
            }
        }
    }
    navSitesVc.contextPut("sites", siteLinks);
    navSitesVc.contextPut("tabhelper", this);
    navTabsVc.contextPut("dtabs", dtabs);
    navTabsVc.contextPut("dtabsLinkNames", dtabsLinkNames);
    navTabsVc.contextPut("tabhelper", this);
    // header, optional (e.g. for logo, advertising )
    Controller headerCtr = baseFullWebappControllerParts.createHeaderController(ureq, getWindowControl());
    if (headerCtr != null) {
        // cleanup on dispose
        listenTo(headerCtr);
        Component headerCmp = headerCtr.getInitialComponent();
        mainVc.put("headerComponent", headerCmp);
    }
    // topnav, optional (e.g. for imprint, logout)
    topnavCtr = baseFullWebappControllerParts.createTopNavController(ureq, getWindowControl());
    if (topnavCtr != null) {
        // cleanup on dispose
        listenTo(topnavCtr);
        mainVc.put("topnavComponent", topnavCtr.getInitialComponent());
        userToolsMenuCtrl = new UserToolsMenuController(ureq, getWindowControl());
        listenTo(userToolsMenuCtrl);
        mainVc.put("menuComponent", userToolsMenuCtrl.getInitialComponent());
    }
    // panel for modal overlays, placed right after the olat-header-div
    modalPanel = new Panel("ccmodalpanel");
    mainVc.put("modalpanel", modalPanel);
    // main, mandatory (e.g. a LayoutMain3ColsController)
    main = new Panel("mainContent");
    mainVc.put("main", main);
    // footer, optional (e.g. for copyright, powered by)
    footerCtr = baseFullWebappControllerParts.createFooterController(ureq, getWindowControl());
    if (footerCtr != null) {
        // cleanup on dispose
        listenTo(footerCtr);
        Component footerCmp = footerCtr.getInitialComponent();
        mainVc.put("footerComponent", footerCmp);
    }
    contentCtrl = baseFullWebappControllerParts.getContentController(ureq, getWindowControl());
    if (contentCtrl != null) {
        listenTo(contentCtrl);
        GuiStack gs = getWindowControl().getWindowBackOffice().createGuiStack(contentCtrl.getInitialComponent());
        setGuiStack(gs);
        main.setContent(contentCtrl.getInitialComponent());
    } else {
        main.setContent(TextFactory.createTextComponentFromString("empty", "", null, false, null));
        // set a guistack for the after login interceptor
        GuiStack gs = getWindowControl().getWindowBackOffice().createGuiStack(new Panel("dummy"));
        setGuiStack(gs);
    }
    setWindowSettings(getWindowControl().getWindowBackOffice().getWindowSettings());
}
Also used : BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) SiteInstance(org.olat.core.gui.control.navigation.SiteInstance) LayoutModule(org.olat.admin.layout.LayoutModule) ArrayList(java.util.ArrayList) LandingPagesModule(org.olat.admin.landingpages.LandingPagesModule) ResumeSessionController(org.olat.core.commons.controllers.resume.ResumeSessionController) AssessmentModeGuardController(org.olat.course.assessment.ui.mode.AssessmentModeGuardController) BasicController(org.olat.core.gui.control.controller.BasicController) ChiefController(org.olat.core.gui.control.ChiefController) BaseChiefController(org.olat.core.commons.chiefcontrollers.BaseChiefController) VetoableCloseController(org.olat.core.gui.control.VetoableCloseController) Controller(org.olat.core.gui.control.Controller) UserToolsMenuController(org.olat.gui.control.UserToolsMenuController) GuiStack(org.olat.core.gui.control.guistack.GuiStack) NavElement(org.olat.core.gui.control.navigation.NavElement) OncePanel(org.olat.core.gui.components.panel.OncePanel) Panel(org.olat.core.gui.components.panel.Panel) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) LogoInformations(org.olat.admin.layout.LogoInformations) HomeSite(org.olat.home.HomeSite) UserToolsMenuController(org.olat.gui.control.UserToolsMenuController) Component(org.olat.core.gui.components.Component) CustomJSComponent(org.olat.core.gui.components.htmlheader.jscss.CustomJSComponent) CountDownComponent(org.olat.core.gui.components.countdown.CountDownComponent) Link(org.olat.core.gui.components.link.Link)

Example 4 with GuiStack

use of org.olat.core.gui.control.guistack.GuiStack in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method popTheTabState.

private void popTheTabState(UserRequest ureq) {
    if (siteAndTabs.isEmpty() && sites != null) {
        SiteInstance firstSite = sites.get(0);
        BornSiteInstance bs = siteToBornSite.get(firstSite);
        if (bs == null) {
            activateSite(firstSite, ureq, null, false);
        } else {
            doActivateSite(firstSite, bs.getGuiStackHandle());
        }
    } else if (!siteAndTabs.isEmpty()) {
        TabState state = siteAndTabs.remove(siteAndTabs.size() - 1);
        if (state.getSite() != null) {
            // latest selected static tab
            // activate previous chosen static site -> this site has already been
            // constructed and is thus in the cache
            SiteInstance si = state.getSite();
            BornSiteInstance bs = siteToBornSite.get(si);
            // bs != null since clicked previously
            GuiStack gsh = bs.getGuiStackHandle();
            doActivateSite(si, gsh);
            if (siteToBusinessPath.containsValue(si)) {
                ureq.getUserSession().addToHistory(ureq, siteToBusinessPath.get(si));
            }
        } else if (state.getDtab() != null && !state.getDtab().getController().isDisposed()) {
            DTab tab = state.getDtab();
            doActivateDTab(tab);
            if (dtabToBusinessPath.containsKey(tab)) {
                ureq.getUserSession().addToHistory(ureq, dtabToBusinessPath.get(tab));
            }
        } else {
            popTheTabState(ureq);
        }
    }
}
Also used : BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) SiteInstance(org.olat.core.gui.control.navigation.SiteInstance) DTab(org.olat.core.gui.control.generic.dtabs.DTab) BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) GuiStack(org.olat.core.gui.control.guistack.GuiStack)

Example 5 with GuiStack

use of org.olat.core.gui.control.guistack.GuiStack in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method activateSite.

/**
 * Activate a site if not locked
 *
 * @param s
 * @param ureq
 * @param entries
 * @param forceReload
 */
private void activateSite(SiteInstance s, UserRequest ureq, List<ContextEntry> entries, boolean forceReload) {
    if (lockResource != null)
        return;
    BornSiteInstance bs = siteToBornSite.get(s);
    GuiStack gs;
    Controller resC;
    // PB//WindowControl site_wControl;
    if (bs != null && s != curSite) {
        // single - click -> fetch guistack from cache
        gs = bs.getGuiStackHandle();
        resC = bs.getController();
    } else if (bs != null && s == curSite && !forceReload) {
        // via activate, don't force the reload
        gs = bs.getGuiStackHandle();
        resC = bs.getController();
    } else {
        // dispose old controller
        if (bs != null) {
            // already in cache -> dispose old
            bs.getController().dispose();
        }
        // reset site and create new controller
        s.reset();
        resC = s.createController(ureq, getWindowControl());
        gs = getWindowControl().getWindowBackOffice().createGuiStack(resC.getInitialComponent());
        // PB//site_wControl = bwControl;
        // PB//siteToBornSite.put(s, new BornSiteInstance(gs, resC, bwControl));
        siteToBornSite.put(s, new BornSiteInstance(gs, resC));
    }
    doActivateSite(s, gs);
    if (resC instanceof Activateable2) {
        ((Activateable2) resC).activate(ureq, entries, null);
    }
    // perhaps has activation changed the gui stack and it need to be updated
    setGuiStack(gs);
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) GuiStack(org.olat.core.gui.control.guistack.GuiStack) ResumeSessionController(org.olat.core.commons.controllers.resume.ResumeSessionController) AssessmentModeGuardController(org.olat.course.assessment.ui.mode.AssessmentModeGuardController) BasicController(org.olat.core.gui.control.controller.BasicController) ChiefController(org.olat.core.gui.control.ChiefController) BaseChiefController(org.olat.core.commons.chiefcontrollers.BaseChiefController) VetoableCloseController(org.olat.core.gui.control.VetoableCloseController) Controller(org.olat.core.gui.control.Controller) UserToolsMenuController(org.olat.gui.control.UserToolsMenuController)

Aggregations

GuiStack (org.olat.core.gui.control.guistack.GuiStack)6 BornSiteInstance (org.olat.core.gui.control.navigation.BornSiteInstance)6 BaseChiefController (org.olat.core.commons.chiefcontrollers.BaseChiefController)4 ResumeSessionController (org.olat.core.commons.controllers.resume.ResumeSessionController)4 ChiefController (org.olat.core.gui.control.ChiefController)4 Controller (org.olat.core.gui.control.Controller)4 VetoableCloseController (org.olat.core.gui.control.VetoableCloseController)4 BasicController (org.olat.core.gui.control.controller.BasicController)4 SiteInstance (org.olat.core.gui.control.navigation.SiteInstance)4 AssessmentModeGuardController (org.olat.course.assessment.ui.mode.AssessmentModeGuardController)4 UserToolsMenuController (org.olat.gui.control.UserToolsMenuController)4 ArrayList (java.util.ArrayList)2 LandingPagesModule (org.olat.admin.landingpages.LandingPagesModule)2 LayoutModule (org.olat.admin.layout.LayoutModule)2 LogoInformations (org.olat.admin.layout.LogoInformations)2 Component (org.olat.core.gui.components.Component)2 CountDownComponent (org.olat.core.gui.components.countdown.CountDownComponent)2 CustomJSComponent (org.olat.core.gui.components.htmlheader.jscss.CustomJSComponent)2 Link (org.olat.core.gui.components.link.Link)2 OncePanel (org.olat.core.gui.components.panel.OncePanel)2