Search in sources :

Example 11 with DTab

use of org.olat.core.gui.control.generic.dtabs.DTab in project openolat by klemens.

the class CourseRuntimeController method launchGlossary.

private void launchGlossary(UserRequest ureq) {
    // start glossary in window
    ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
    // do not cache cc, not save
    final CourseConfig cc = course.getCourseConfig();
    final boolean allowGlossaryEditing = reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GLOSSARY);
    // if glossary had been opened from LR as Tab before, warn user:
    DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
    RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
    DTab dt = dts.getDTab(repoEntry.getOlatResource());
    if (dt != null) {
        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
        dts.activate(ureq, dt, entries);
    } else {
        ControllerCreator ctrlCreator = new ControllerCreator() {

            public Controller createController(UserRequest lureq, WindowControl lwControl) {
                GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController(lwControl, lureq, cc, allowGlossaryEditing);
                listenTo(glossaryController);
                if (glossaryController == null) {
                    // happens in the unlikely event of a user who is in a course and
                    // now
                    // tries to access the glossary
                    String text = translate("error.noglossary");
                    return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
                } else {
                    // use a one-column main layout
                    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController);
                    // dispose glossary on layout dispose
                    layoutCtr.addDisposableChildController(glossaryController);
                    return layoutCtr;
                }
            }
        };
        ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
        // open in new browser window
        openInNewBrowserWindow(ureq, layoutCtrlr);
        // immediate return after opening new browser window!
        return;
    }
}
Also used : GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CourseConfig(org.olat.course.config.CourseConfig) DTab(org.olat.core.gui.control.generic.dtabs.DTab) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) UserRequest(org.olat.core.gui.UserRequest)

Example 12 with DTab

use of org.olat.core.gui.control.generic.dtabs.DTab in project OpenOLAT by OpenOLAT.

the class CourseRuntimeController method launchGlossary.

private void launchGlossary(UserRequest ureq) {
    // start glossary in window
    ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
    // do not cache cc, not save
    final CourseConfig cc = course.getCourseConfig();
    final boolean allowGlossaryEditing = reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GLOSSARY);
    // if glossary had been opened from LR as Tab before, warn user:
    DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
    RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
    DTab dt = dts.getDTab(repoEntry.getOlatResource());
    if (dt != null) {
        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
        dts.activate(ureq, dt, entries);
    } else {
        ControllerCreator ctrlCreator = new ControllerCreator() {

            public Controller createController(UserRequest lureq, WindowControl lwControl) {
                GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController(lwControl, lureq, cc, allowGlossaryEditing);
                listenTo(glossaryController);
                if (glossaryController == null) {
                    // happens in the unlikely event of a user who is in a course and
                    // now
                    // tries to access the glossary
                    String text = translate("error.noglossary");
                    return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
                } else {
                    // use a one-column main layout
                    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController);
                    // dispose glossary on layout dispose
                    layoutCtr.addDisposableChildController(glossaryController);
                    return layoutCtr;
                }
            }
        };
        ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
        // open in new browser window
        openInNewBrowserWindow(ureq, layoutCtrlr);
        // immediate return after opening new browser window!
        return;
    }
}
Also used : GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CourseConfig(org.olat.course.config.CourseConfig) DTab(org.olat.core.gui.control.generic.dtabs.DTab) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) UserRequest(org.olat.core.gui.UserRequest)

Example 13 with DTab

use of org.olat.core.gui.control.generic.dtabs.DTab in project OpenOLAT by OpenOLAT.

the class NewControllerFactory method launch.

/**
 * Launch a controller in a tab or site in the given window from a user
 * request url
 *
 * @param ureq
 * @param wControl
 */
public boolean launch(UserRequest ureq, WindowControl wControl) {
    BusinessControl bc = wControl.getBusinessControl();
    ContextEntry mainCe = bc.popLauncherContextEntry();
    if (mainCe == null) {
        // nothing to launch
        return false;
    }
    OLATResourceable ores = mainCe.getOLATResourceable();
    // Check for RepositoryEntry resource
    RepositoryEntry re = null;
    if (ores.getResourceableTypeName().equals(OresHelper.calculateTypeName(RepositoryEntry.class))) {
        if (ores instanceof RepositoryEntry) {
            re = (RepositoryEntry) ores;
            ores = re.getOlatResource();
        } else {
            // It is a repository-entry => get OLATResourceable from RepositoryEntry
            RepositoryManager repom = RepositoryManager.getInstance();
            re = repom.lookupRepositoryEntry(ores.getResourceableId());
            if (re != null) {
                ores = re.getOlatResource();
                mainCe.upgradeOLATResourceable(re);
            }
        }
    }
    // was brasato:: DTabs dts = wControl.getDTabs();
    UserSession usess = ureq.getUserSession();
    Window window = Windows.getWindows(usess).getWindow(ureq);
    if (window == null) {
        log.debug("Found no window for jumpin => take WindowBackOffice", null);
        window = wControl.getWindowBackOffice().getWindow();
    }
    DTabs dts = window.getDTabs();
    String firstType = mainCe.getOLATResourceable().getResourceableTypeName();
    // String firstTypeId = ClassToId.getInstance().lookup() BusinessGroup
    ContextEntryControllerCreator typeHandler = getContextEntryControllerCreator(firstType);
    if (typeHandler == null) {
        log.warn("Cannot found an handler for context entry: " + mainCe, null);
        // simply return and don't throw a red screen
        return false;
    }
    if (!typeHandler.validateContextEntryAndShowError(mainCe, ureq, wControl)) {
        // simply return and don't throw a red screen
        return false;
    }
    List<ContextEntry> entries = new ArrayList<ContextEntry>(5);
    while (bc.hasContextEntry()) {
        entries.add(bc.popLauncherContextEntry());
    }
    List<ContextEntry> ces = new ArrayList<ContextEntry>(entries.size() + 1);
    ces.add(mainCe);
    if (entries.size() > 0) {
        ces.addAll(entries);
    }
    TabContext context = typeHandler.getTabContext(ureq, ores, mainCe, entries);
    String siteClassName = typeHandler.getSiteClassName(ces, ureq);
    // open in existing site
    boolean launched = false;
    boolean assessmentMode = usess.isInAssessmentModeProcess();
    if (siteClassName != null) {
        if (!assessmentMode) {
            dts.activateStatic(ureq, siteClassName, context.getContext());
            launched = true;
        }
    } else if (!assessmentMode || usess.matchLockResource(ores)) {
        // get current tab or create new tab
        DTab dt = dts.getDTab(ores);
        if (dt == null) {
            WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, dts.getWindowControl());
            usess.addToHistory(ureq, bc);
            Controller launchC = typeHandler.createController(ces, ureq, bwControl);
            if (launchC != null) {
                dt = dts.createDTab(context.getTabResource(), re, launchC, context.getName());
                if (dt == null) {
                    launched = false;
                } else if (dts.addDTab(ureq, dt)) {
                    dts.activate(ureq, dt, context.getContext());
                    launched = true;
                }
            }
        } else {
            dts.activate(ureq, dt, context.getContext());
            launched = true;
        }
    }
    return launched;
}
Also used : Window(org.olat.core.gui.components.Window) OLATResourceable(org.olat.core.id.OLATResourceable) ContextEntryControllerCreator(org.olat.core.id.context.ContextEntryControllerCreator) BusinessControl(org.olat.core.id.context.BusinessControl) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) BaseChiefController(org.olat.core.commons.chiefcontrollers.BaseChiefController) Controller(org.olat.core.gui.control.Controller) ContextEntry(org.olat.core.id.context.ContextEntry) TabContext(org.olat.core.id.context.TabContext) DTab(org.olat.core.gui.control.generic.dtabs.DTab) UserSession(org.olat.core.util.UserSession) RepositoryManager(org.olat.repository.RepositoryManager)

Example 14 with DTab

use of org.olat.core.gui.control.generic.dtabs.DTab in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source instanceof Link) {
        Link link = (Link) source;
        String mC = link.getCommand().substring(0, 1);
        if (mC.equals("t")) {
            // activate normal tab
            SiteInstance s = (SiteInstance) link.getUserObject();
            // fix the state of the last tab/site
            updateBusinessPath(ureq);
            HistoryPoint point = null;
            if (siteToBusinessPath.containsKey(s)) {
                point = siteToBusinessPath.get(s);
            }
            activateSite(s, ureq, null, true);
            if (point != null) {
                BusinessControlFactory.getInstance().addToHistory(ureq, point);
            }
            updateBusinessPath(ureq, s);
        } else if (mC.equals("a")) {
            // activate dyntab
            DTab dt = (DTab) link.getUserObject();
            // fix the state of the last tab/site
            updateBusinessPath(ureq);
            HistoryPoint point = null;
            if (dtabToBusinessPath.containsKey(dt)) {
                point = dtabToBusinessPath.get(dt);
            }
            doActivateDTab(dt);
            if (dt.getController() instanceof Activateable2) {
                ((Activateable2) dt.getController()).activate(ureq, null, new ReloadEvent());
            }
            if (point != null) {
                BusinessControlFactory.getInstance().addToHistory(ureq, point);
            }
        } else if (mC.equals("c")) {
            // close dyntab
            DTab dt = (DTab) link.getUserObject();
            requestCloseTab(ureq, dt);
        }
    } else if (source == getWindowControl().getWindowBackOffice().getWindow()) {
        if (event == Window.OLDTIMESTAMPCALL) {
            getLogger().info("RELOAD");
            HistoryPoint point = ureq.getUserSession().popLastHistoryEntry();
            if (point != null) {
                back(ureq, point);
            }
        }
    }
}
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) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) Link(org.olat.core.gui.components.link.Link) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 15 with DTab

use of org.olat.core.gui.control.generic.dtabs.DTab in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method back.

protected void back(UserRequest ureq, HistoryPoint cstate) {
    List<ContextEntry> entries = cstate.getEntries();
    if (entries.isEmpty())
        return;
    entries = new ArrayList<ContextEntry>(entries);
    ContextEntry state = entries.remove(0);
    // no red screen for this
    if (state == null)
        return;
    OLATResourceable ores = state.getOLATResourceable();
    if (ores != null && "HomeSite".equals(ores.getResourceableTypeName())) {
        activateSite(userTools, ureq, entries, false);
    } else {
        DTab dt = getDTab(ores);
        if (dt != null) {
            doActivateDTab(dt);
            if (dt.getController() instanceof Activateable2) {
                ((Activateable2) dt.getController()).activate(ureq, entries, null);
            }
            updateBusinessPath(ureq, dt);
        } else {
            StateEntry s = state.getTransientState();
            if (s instanceof StateSite && ((StateSite) s).getSite() != null && sites != null) {
                SiteInstance site = ((StateSite) s).getSite();
                for (SiteInstance savedSite : sites) {
                    if (savedSite != null && site.getClass().equals(savedSite.getClass())) {
                        activateSite(savedSite, ureq, entries, false);
                    }
                }
            }
        }
    }
}
Also used : DTab(org.olat.core.gui.control.generic.dtabs.DTab) StateEntry(org.olat.core.id.context.StateEntry) BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) SiteInstance(org.olat.core.gui.control.navigation.SiteInstance) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) OLATResourceable(org.olat.core.id.OLATResourceable) StateSite(org.olat.core.id.context.StateSite) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

DTab (org.olat.core.gui.control.generic.dtabs.DTab)20 BornSiteInstance (org.olat.core.gui.control.navigation.BornSiteInstance)8 ContextEntry (org.olat.core.id.context.ContextEntry)8 BaseChiefController (org.olat.core.commons.chiefcontrollers.BaseChiefController)6 Controller (org.olat.core.gui.control.Controller)6 WindowControl (org.olat.core.gui.control.WindowControl)6 DTabs (org.olat.core.gui.control.generic.dtabs.DTabs)6 SiteInstance (org.olat.core.gui.control.navigation.SiteInstance)6 OLATResourceable (org.olat.core.id.OLATResourceable)6 HistoryPoint (org.olat.core.id.context.HistoryPoint)6 ResumeSessionController (org.olat.core.commons.controllers.resume.ResumeSessionController)4 Link (org.olat.core.gui.components.link.Link)4 ChiefController (org.olat.core.gui.control.ChiefController)4 VetoableCloseController (org.olat.core.gui.control.VetoableCloseController)4 BasicController (org.olat.core.gui.control.controller.BasicController)4 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)4 BusinessControl (org.olat.core.id.context.BusinessControl)4 AssessmentModeGuardController (org.olat.course.assessment.ui.mode.AssessmentModeGuardController)4 UserToolsMenuController (org.olat.gui.control.UserToolsMenuController)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4