Search in sources :

Example 1 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project OpenOLAT by OpenOLAT.

the class AjaxController method appendBusinessPathInfos.

private void appendBusinessPathInfos(UserRequest ureq, Writer writer) throws IOException {
    ChiefController ctrl = wboImpl.getChiefController();
    String documentTitle = ctrl == null ? "" : ctrl.getWindow().getTitle();
    writer.append(",\"documentTitle\":").append(JSONObject.quote(documentTitle));
    StringBuilder bc = new StringBuilder(128);
    HistoryPoint p = ureq.getUserSession().getLastHistoryPoint();
    if (p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) {
        List<ContextEntry> ces = p.getEntries();
        String uriPrefix = wboImpl.getWindow().getUriPrefix();
        bc.append(uriPrefix).append(BusinessControlFactory.getInstance().getAsRestPart(ces, true));
        writer.append(",\"businessPath\":").append(JSONObject.quote(bc.toString()));
        writer.append(",\"historyPointId\":").append(JSONObject.quote(p.getUuid()));
    }
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 2 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project OpenOLAT by OpenOLAT.

the class UserSession method addToHistory.

public void addToHistory(UserRequest ureq, BusinessControl businessControl) {
    List<ContextEntry> entries = businessControl.getEntries();
    String businessPath = businessControl.getAsString();
    if (StringHelper.containsNonWhitespace(businessPath)) {
        String uuid = ureq.getUuid();
        if (!history.isEmpty()) {
            // consolidate
            synchronized (history) {
                for (Iterator<HistoryPoint> it = history.iterator(); it.hasNext(); ) {
                    HistoryPoint p = it.next();
                    if (uuid.equals(p.getUuid())) {
                        it.remove();
                    }
                }
            }
        }
        // System.out.println(ureq.getUuid() + " Add business path: " + businessPath);
        history.push(new HistoryPointImpl(ureq.getUuid(), businessPath, entries));
        if (history.size() > 20) {
            history.remove(0);
        }
    }
}
Also used : HistoryPointImpl(org.olat.core.id.context.HistoryPointImpl) ContextEntry(org.olat.core.id.context.ContextEntry) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 3 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint 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 4 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method updateBusinessPath.

private void updateBusinessPath(UserRequest ureq, DTab tab) {
    // dtabToBusinessPath is null if the controller is disposed
    if (tab == null || dtabToBusinessPath == null)
        return;
    try {
        String businessPath = tab.getController().getWindowControlForDebug().getBusinessControl().getAsString();
        HistoryPoint point = ureq.getUserSession().getLastHistoryPoint();
        int index = businessPath.indexOf(']');
        if (index > 0 && point != null && point.getBusinessPath() != null) {
            String start = businessPath.substring(0, index);
            if (!point.getBusinessPath().startsWith(start)) {
                // if a controller has not set its business path, don't pollute the mapping
                List<ContextEntry> entries = tab.getController().getWindowControlForDebug().getBusinessControl().getEntries();
                dtabToBusinessPath.put(tab, new HistoryPointImpl(ureq.getUuid(), businessPath, entries));
                return;
            }
        }
        dtabToBusinessPath.put(tab, point);
    } catch (Exception e) {
        logError("", e);
    }
}
Also used : HistoryPointImpl(org.olat.core.id.context.HistoryPointImpl) HistoryPoint(org.olat.core.id.context.HistoryPoint) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) AssertException(org.olat.core.logging.AssertException)

Example 5 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method updateBusinessPath.

private String updateBusinessPath(UserRequest ureq, SiteInstance site) {
    if (site == null)
        return null;
    try {
        String businessPath = siteToBornSite.get(site).getController().getWindowControlForDebug().getBusinessControl().getAsString();
        HistoryPoint point = ureq.getUserSession().getLastHistoryPoint();
        int index = businessPath.indexOf(':');
        if (index > 0 && point != null && point.getBusinessPath() != null) {
            String start = businessPath.substring(0, index);
            if (!point.getBusinessPath().startsWith(start)) {
                // if a controller has not set its business path, don't pollute the mapping
                List<ContextEntry> entries = siteToBornSite.get(site).getController().getWindowControlForDebug().getBusinessControl().getEntries();
                siteToBusinessPath.put(site, new HistoryPointImpl(ureq.getUuid(), businessPath, entries));
                return BusinessControlFactory.getInstance().getAsRestPart(entries, true);
            }
            List<ContextEntry> entries = siteToBornSite.get(site).getController().getWindowControlForDebug().getBusinessControl().getEntries();
            businessPath = BusinessControlFactory.getInstance().getAsRestPart(entries, true);
        }
        siteToBusinessPath.put(site, point);
        return businessPath;
    } catch (Exception e) {
        logError("", e);
        return null;
    }
}
Also used : HistoryPointImpl(org.olat.core.id.context.HistoryPointImpl) HistoryPoint(org.olat.core.id.context.HistoryPoint) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) AssertException(org.olat.core.logging.AssertException)

Aggregations

HistoryPoint (org.olat.core.id.context.HistoryPoint)22 ContextEntry (org.olat.core.id.context.ContextEntry)18 WindowControl (org.olat.core.gui.control.WindowControl)6 BusinessControl (org.olat.core.id.context.BusinessControl)6 HistoryPointImpl (org.olat.core.id.context.HistoryPointImpl)6 ChiefController (org.olat.core.gui.control.ChiefController)4 DTab (org.olat.core.gui.control.generic.dtabs.DTab)4 JSCommand (org.olat.core.gui.control.winmgr.JSCommand)4 AssertException (org.olat.core.logging.AssertException)4 UserSession (org.olat.core.util.UserSession)4 Preferences (org.olat.core.util.prefs.Preferences)4 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 WindowManager (org.olat.core.gui.WindowManager)2 WindowSettings (org.olat.core.gui.WindowSettings)2 Window (org.olat.core.gui.components.Window)2 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)2 Link (org.olat.core.gui.components.link.Link)2