Search in sources :

Example 1 with DTab

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

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 2 with DTab

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

the class DisposedCourseRestartController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == restartLink) {
        OLATResourceable ores = OLATResourceManager.getInstance().findResourceable(courseRepositoryEntry.getOlatResource().getResourceableId(), courseRepositoryEntry.getOlatResource().getResourceableTypeName());
        if (ores == null) {
            // course was deleted!
            MessageController msgController = MessageUIFactory.createInfoMessage(ureq, getWindowControl(), translate("course.deleted.title"), translate("course.deleted.text"));
            panel.setContent(msgController.getInitialComponent());
        } else {
            OLATResourceable reOres = OresHelper.clone(courseRepositoryEntry);
            DTabs dtabs = getWindowControl().getWindowBackOffice().getWindow().getDTabs();
            if (dtabs != null) {
                DTab dt = dtabs.getDTab(reOres);
                if (dt != null) {
                    dtabs.removeDTab(ureq, dt);
                }
            }
            List<ContextEntry> entries = null;
            List<HistoryPoint> stacks = ureq.getUserSession().getHistoryStack();
            for (int i = stacks.size(); i-- > 0; ) {
                HistoryPoint point = stacks.get(i);
                if (point != null && point.getEntries() != null && point.getEntries().size() > 0) {
                    ContextEntry entry = point.getEntries().get(0);
                    if (reOres.equals(entry.getOLATResourceable())) {
                        entries = point.getEntries();
                        break;
                    }
                }
            }
            WindowControl bwControl;
            if (entries == null) {
                bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(getWindowControl(), reOres);
            } else {
                BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(entries);
                bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
            }
            NewControllerFactory.getInstance().launch(ureq, bwControl);
            dispose();
        }
    }
}
Also used : DTab(org.olat.core.gui.control.generic.dtabs.DTab) MessageController(org.olat.core.gui.control.generic.messages.MessageController) OLATResourceable(org.olat.core.id.OLATResourceable) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) HistoryPoint(org.olat.core.id.context.HistoryPoint) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 3 with DTab

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

the class BaseFullWebappController method doDispose.

@Override
protected void doDispose() {
    // deregister for chief global sticky messages events
    GlobalStickyMessage.deregisterForGlobalStickyMessage(this);
    if (dtabs != null) {
        for (DTab tab : dtabs) {
            tab.dispose();
        }
        for (BornSiteInstance bornSite : siteToBornSite.values()) {
            bornSite.dispose();
        }
        dtabs = null;
        dtabsControllers = null;
        sites = null;
        siteToBornSite = null;
        siteToBusinessPath = null;
        dtabToBusinessPath = null;
    }
    // clear the DTabs Service
    WindowBackOffice wbackOffice = getWindowControl().getWindowBackOffice();
    wbackOffice.getWindow().setDTabs(null);
    wbackOffice.removeCycleListener(this);
    if (jsServerC != null) {
        jsServerC.dispose();
        jsServerC = null;
    }
    if (debugC != null) {
        debugC.dispose();
        debugC = null;
    }
    if (inlineTranslationC != null) {
        inlineTranslationC.dispose();
        inlineTranslationC = null;
    }
    if (developmentC != null) {
        developmentC.dispose();
        developmentC = null;
    }
    // deregister for assessment mode
    CoordinatorManager.getInstance().getCoordinator().getEventBus().deregisterFor(this, AssessmentModeNotificationEvent.ASSESSMENT_MODE_NOTIFICATION);
}
Also used : DTab(org.olat.core.gui.control.generic.dtabs.DTab) BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) WindowBackOffice(org.olat.core.gui.control.WindowBackOffice)

Example 4 with DTab

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

the class BaseFullWebappController method addDTab.

@Override
public boolean addDTab(UserRequest ureq, DTab dt) {
    if (isDisposed()) {
        return false;
    }
    DTab old = getDTab(dt.getOLATResourceable());
    if (old != null) {
        return true;
    }
    // add to tabs list
    synchronized (dtabs) {
        // make dtabs and dtabsControllers access synchronized
        dtabs.add(dt);
        dtabsLinkNames.add(dtabCreateCounter);
        Link link = LinkFactory.createCustomLink("a" + dtabCreateCounter, "a" + dtabCreateCounter, "", Link.NONTRANSLATED, navTabsVc, this);
        link.setCustomDisplayText(StringHelper.escapeHtml(dt.getNavElement().getTitle()));
        link.setIconLeftCSS("o_icon o_icon-fw " + dt.getNavElement().getIconCSSClass());
        link.setTitle(dt.getTitle());
        link.setUserObject(dt);
        // Set accessibility access key using the 's' key. You can loop through all opened tabs by
        // pressing s repetitively (works only in IE/FF which is normally used by blind people)
        link.setAccessKey("s");
        // add close links
        Link calink = LinkFactory.createCustomLink("c" + dtabCreateCounter, "c" + dtabCreateCounter, "", Link.NONTRANSLATED, navTabsVc, this);
        calink.setCustomEnabledLinkCSS("o_navbar_tab_close");
        calink.setIconLeftCSS("o_icon o_icon_close_tab");
        calink.setTitle(translate("close"));
        calink.setUserObject(dt);
        Controller dtabCtr = dt.getController();
        dtabCtr.addControllerListener(this);
        updateBusinessPath(ureq, dt);
        // add to tabs controller lookup table for later event dispatching
        dtabsControllers.add(dtabCtr);
        // increase DTab added counter.
        dtabCreateCounter++;
    }
    return true;
}
Also used : DTab(org.olat.core.gui.control.generic.dtabs.DTab) 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) Link(org.olat.core.gui.components.link.Link)

Example 5 with DTab

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

the class BaseFullWebappController method lockGUI.

private void lockGUI() {
    if (topnavCtr != null) {
        topnavCtr.lock();
    }
    if (footerCtr != null) {
        footerCtr.lock();
    }
    if (userToolsMenuCtrl != null) {
        userToolsMenuCtrl.lock();
    }
    if (dtabsControllers != null) {
        for (int i = dtabsControllers.size(); i-- > 0; ) {
            DTab tab = dtabs.get(i);
            if (lockResource == null || !lockResource.getResourceableId().equals(tab.getOLATResourceable().getResourceableId())) {
                removeDTab(null, tab);
            } else if (lockResource != null && lockResource.getResourceableId().equals(tab.getOLATResourceable().getResourceableId()) && lockStatus != LockStatus.locked) {
                removeDTab(null, tab);
            }
        }
    }
    navSitesVc.contextPut("visible", Boolean.FALSE);
    navSitesVc.setDirty(true);
    navTabsVc.setDirty(true);
    main.setContent(new Panel("empty-mode"));
}
Also used : DTab(org.olat.core.gui.control.generic.dtabs.DTab) OncePanel(org.olat.core.gui.components.panel.OncePanel) Panel(org.olat.core.gui.components.panel.Panel) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) HistoryPoint(org.olat.core.id.context.HistoryPoint)

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