Search in sources :

Example 16 with Window

use of org.olat.core.gui.components.Window 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 17 with Window

use of org.olat.core.gui.components.Window in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method addCurrentCustomCSSToView.

/**
 * Add a custom css to the view and mark it as the current custom CSS.
 *
 * @param customCSS
 */
@Override
public void addCurrentCustomCSSToView(CustomCSS customCSS) {
    if (customCSS == null)
        return;
    // The current CSS is stored as a window attribute so that is can be
    // accessed by the IFrameDisplayController
    Window myWindow = getWindowControl().getWindowBackOffice().getWindow();
    myWindow.setCustomCSS(customCSS);
    // add css component to view
    cssHolder.setContent(customCSS.getJSAndCSSComponent());
}
Also used : Window(org.olat.core.gui.components.Window)

Example 18 with Window

use of org.olat.core.gui.components.Window in project OpenOLAT by OpenOLAT.

the class DefaultMinimalTopNavController 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 == closeLink) {
        // close window (a html page which calls Window.close onLoad
        ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(StaticMediaDispatcher.createStaticURIFor("closewindow.html")));
        // release all resources and close window
        WindowBackOffice wbo = getWindowControl().getWindowBackOffice();
        Window w = wbo.getWindow();
        Windows.getWindows(ureq).deregisterWindow(w);
        wbo.dispose();
    }
}
Also used : Window(org.olat.core.gui.components.Window) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) WindowBackOffice(org.olat.core.gui.control.WindowBackOffice)

Example 19 with Window

use of org.olat.core.gui.components.Window in project OpenOLAT by OpenOLAT.

the class UserSessionInformationsController method getUsersSessionAsString.

private String getUsersSessionAsString() {
    StringBuilder sb = new StringBuilder(50000);
    int ucCnt = sessionManager.getUserSessionsCnt();
    Set<UserSession> usesss = sessionManager.getAuthenticatedUserSessions();
    int contcnt = DefaultController.getControllerCount();
    sb.append("total usersessions (auth and non auth): " + ucCnt + "<br />auth usersessions: " + usesss.size() + "<br />Total Controllers (active, not disposed) of all users:" + contcnt + "<br /><br />");
    for (Iterator<UserSession> iter = usesss.iterator(); iter.hasNext(); ) {
        UserSession usess = iter.next();
        Identity iden = usess.getIdentity();
        sb.append("authusersession (").append(usess.hashCode()).append(") of ");
        if (iden != null) {
            sb.append(iden.getName()).append(" ").append(iden.getKey());
        } else {
            sb.append(" - ");
        }
        sb.append("<br />");
        Windows ws = Windows.getWindows(usess);
        for (Iterator<Window> iterator = ws.getWindowIterator(); iterator.hasNext(); ) {
            Window window = iterator.next();
            sb.append("- window ").append(window.getDispatchID()).append(" ").append(window.getLatestDispatchComponentInfo()).append("<br />");
        }
        sb.append("<br />");
    }
    return sb.toString();
}
Also used : Window(org.olat.core.gui.components.Window) UserSession(org.olat.core.util.UserSession) Windows(org.olat.core.gui.Windows) Identity(org.olat.core.id.Identity)

Example 20 with Window

use of org.olat.core.gui.components.Window in project OpenOLAT by OpenOLAT.

the class DevelopmentController method updateComponentTree.

private void updateComponentTree() {
    Window win = wboImpl.getWindow();
    StringOutput sb = new StringOutput();
    renderDebugInfo(win.getContentPane(), sb);
    myContent.contextPut("compdump", sb.toString());
}
Also used : Window(org.olat.core.gui.components.Window) StringOutput(org.olat.core.gui.render.StringOutput)

Aggregations

Window (org.olat.core.gui.components.Window)30 UserSession (org.olat.core.util.UserSession)10 Windows (org.olat.core.gui.Windows)8 ChiefController (org.olat.core.gui.control.ChiefController)8 StringOutput (org.olat.core.gui.render.StringOutput)8 WindowBackOffice (org.olat.core.gui.control.WindowBackOffice)6 RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)6 URLBuilder (org.olat.core.gui.render.URLBuilder)6 Identity (org.olat.core.id.Identity)6 BusinessControl (org.olat.core.id.context.BusinessControl)6 IOException (java.io.IOException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 UserRequest (org.olat.core.gui.UserRequest)4 UserRequestImpl (org.olat.core.gui.UserRequestImpl)4 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)4 WindowControl (org.olat.core.gui.control.WindowControl)4 ContextEntry (org.olat.core.id.context.ContextEntry)4 UserSessionManager (org.olat.core.util.session.UserSessionManager)4 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2