Search in sources :

Example 1 with ContextEntry

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

the class GenericMainController method activate.

protected void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    ContextEntry entry = entries.get(0);
    TreeNode selectedNode = getMenuTree().getSelectedNode();
    String node = entry.getOLATResourceable().getResourceableTypeName();
    if (node != null && node.startsWith(GMCMT)) {
        activate(ureq, node + ":" + entries.get(0).getOLATResourceable().getResourceableId());
        if (entries.size() >= 1) {
            entries = entries.subList(1, entries.size());
        }
        if (contentCtr instanceof Activateable2) {
            ((Activateable2) contentCtr).activate(ureq, entries, entry.getTransientState());
        }
    } else {
        // maybe the node is a GAE-NavigationKey ?
        GenericActionExtension gAE = ExtManager.getInstance().getActionExtensioByNavigationKey(className, node);
        if (gAE != null) {
            // if the controller is already selected, only activate it, don't reinstanciate it
            if (selectedNode != null && selectedNode.getUserObject() != gAE) {
                activateTreeNodeByActionExtension(ureq, gAE);
            }
            if (entries.size() >= 1) {
                entries = entries.subList(1, entries.size());
            }
            if (contentCtr instanceof Activateable2) {
                ((Activateable2) contentCtr).activate(ureq, entries, entry.getTransientState());
            }
        }
    }
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 2 with ContextEntry

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

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

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

the class MailBoxExtension method getName.

@Override
public String getName(String businessPath, Locale locale) {
    if (!StringHelper.containsNonWhitespace(businessPath))
        return null;
    try {
        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromString(businessPath);
        Collections.reverse(entries);
        for (ContextEntry entry : entries) {
            String resourceTypeName = entry.getOLATResourceable().getResourceableTypeName();
            Long resourceId = entry.getOLATResourceable().getResourceableId();
            if ("BusinessGroup".equals(resourceTypeName)) {
                List<Long> ids = Collections.singletonList(resourceId);
                List<BusinessGroupShort> groups = businessGroupService.loadShortBusinessGroups(ids);
                if (groups == null || groups.isEmpty()) {
                    return null;
                }
                return groups.get(0).getName();
            } else if ("RepositoryEntry".equals(resourceTypeName)) {
                return repositoryManager.lookupDisplayName(resourceId);
            }
        }
    } catch (Exception e) {
        log.error("", e);
    }
    return null;
}
Also used : BusinessGroupShort(org.olat.group.BusinessGroupShort) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 5 with ContextEntry

use of org.olat.core.id.context.ContextEntry 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)

Aggregations

ContextEntry (org.olat.core.id.context.ContextEntry)270 OLATResourceable (org.olat.core.id.OLATResourceable)78 WindowControl (org.olat.core.gui.control.WindowControl)58 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)44 ArrayList (java.util.ArrayList)42 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 Controller (org.olat.core.gui.control.Controller)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 List (java.util.List)22 Identity (org.olat.core.id.Identity)22 BusinessControl (org.olat.core.id.context.BusinessControl)22 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)20 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)18 HistoryPoint (org.olat.core.id.context.HistoryPoint)18 CollaborationTools (org.olat.collaboration.CollaborationTools)16 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)14 UserSession (org.olat.core.util.UserSession)14 CourseNode (org.olat.course.nodes.CourseNode)14 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)12 Translator (org.olat.core.gui.translator.Translator)12