Search in sources :

Example 11 with ActionExtension

use of org.olat.core.extensions.action.ActionExtension in project openolat by klemens.

the class GenericMainController method getContentCtr.

private Controller getContentCtr(Object uobject, UserRequest ureq) {
    Controller contentCtr1Tmp = null;
    if (uobject instanceof ActionExtension) {
        ActionExtension ae = (ActionExtension) uobject;
        contentCtr1Tmp = createController(ae, ureq);
    } else {
        contentCtr1Tmp = handleOwnMenuTreeEvent(uobject, ureq);
    }
    if (contentCtr1Tmp == null) {
        throw new AssertException("Node must either be an ActionExtension or implementation must handle this MenuTreeEvent: " + (uobject == null ? "NULL" : uobject.toString()));
    }
    return contentCtr1Tmp;
}
Also used : AssertException(org.olat.core.logging.AssertException) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController)

Example 12 with ActionExtension

use of org.olat.core.extensions.action.ActionExtension in project openolat by klemens.

the class GenericMainController method activate.

// fxdiff BAKS-7 Resume function
private void activate(UserRequest ureq, String viewIdentifier) {
    ActionExtension ae;
    if (viewIdentifier != null && viewIdentifier.startsWith(GMCMT)) {
        Long extensionID = Long.parseLong(viewIdentifier.substring(viewIdentifier.indexOf(':') + 1));
        Extension ee = ExtManager.getInstance().getExtensionByID(extensionID);
        if (ee == null) {
            logWarn("ExtManager did not find an Extension for extensionID '" + extensionID + "'. Activate canceled...", null);
            return;
        }
        ae = (ActionExtension) ee.getExtensionFor(className, ureq);
    } else {
        int vwindex = viewIdentifier.lastIndexOf(":");
        String naviKey = viewIdentifier;
        if (vwindex >= 0) {
            naviKey = viewIdentifier.substring(0, viewIdentifier.indexOf(':'));
        }
        ae = ExtManager.getInstance().getActionExtensioByNavigationKey(className, naviKey);
        if (ae == null) {
            // this happens, if someone uses a navigation key, that no actionExtension uses...
            logWarn("couldn't find an ActionExtension for  navigationKey '" + naviKey + "' . I suggest adjusting spring configuration for GenericMainController..", null);
        }
    }
    if (ae == null) {
        // no action extension to activate...
        return;
    }
    try {
        if (olatMenuTree.getTreeModel() instanceof GenericTreeModel) {
            activateTreeNodeByActionExtension(ureq, ae);
        } else {
            // just for precaution (treenode selection won't work, but correct
            // content is displayed)
            contentCtr = getContentCtr(ae, ureq);
            listenTo(contentCtr);
            Component resComp = contentCtr.getInitialComponent();
            content.setContent(resComp);
            // fxdiff BAKS-7 Resume function
            addToHistory(ureq, contentCtr);
        }
    } catch (Exception e) {
        logWarn("", e);
    }
}
Also used : Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) Component(org.olat.core.gui.components.Component) AssertException(org.olat.core.logging.AssertException)

Example 13 with ActionExtension

use of org.olat.core.extensions.action.ActionExtension in project openolat by klemens.

the class ArchiverMainController method buildTreeModel.

/**
 * Generates the archiver menu
 * @return The generated menu tree model
 */
private TreeModel buildTreeModel(UserRequest ureq) {
    GenericTreeNode root, gtn;
    GenericTreeModel gtm = new GenericTreeModel();
    root = new GenericTreeNode();
    root.setTitle(translate("menu.index"));
    root.setUserObject(CMD_INDEX);
    root.setAltText(translate("menu.index.alt"));
    gtm.setRootNode(root);
    if (archiverCallback.mayArchiveQtiResults()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.qtiresults"));
        gtn.setUserObject(CMD_QTISURVRESULTS);
        gtn.setAltText(translate("menu.qtiresults.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveQtiTestResults()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.qtitestresults"));
        gtn.setUserObject(CMD_QTITESTRESULTS);
        gtn.setAltText("menu.qtitestresults.alt");
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveProperties()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.scoreaccounting"));
        gtn.setUserObject(CMD_SCOREACCOUNTING);
        gtn.setAltText(translate("menu.scoreaccounting.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveHandedInTasks()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.handedintasks"));
        gtn.setUserObject(CMD_HANDEDINTASKS);
        gtn.setAltText(translate("menu.handedintasks.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveHandedInTasks()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.grouptasks"));
        gtn.setUserObject(CMD_GROUPTASKS);
        gtn.setAltText(translate("menu.grouptasks.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveProjectBroker()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.projectbroker"));
        gtn.setUserObject(CMD_PROJECTBROKER);
        gtn.setAltText(translate("menu.projectbroker.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveLogfiles()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.archivelogfiles"));
        gtn.setUserObject(CMD_ARCHIVELOGFILES);
        gtn.setAltText(translate("menu.archivelogfiles.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveForums()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.forums"));
        gtn.setUserObject(CMD_FORUMS);
        gtn.setAltText(translate("menu.forums.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveDialogs()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.dialogs"));
        gtn.setUserObject(CMD_DIALOGS);
        gtn.setAltText(translate("menu.dialogs.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveParticipantFolder()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.participantfolder"));
        gtn.setUserObject(CMD_PARTICIPANTFOLDER);
        gtn.setAltText("menu.participantfolder.alt");
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveWikis()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.wikis"));
        gtn.setUserObject(CMD_WIKIS);
        gtn.setAltText(translate("menu.wikis.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveScorm()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.scorm"));
        gtn.setUserObject(CMD_SCORM);
        gtn.setAltText(translate("menu.scorm.alt"));
        root.addChild(gtn);
    }
    if (archiverCallback.mayArchiveChecklist()) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.checklist"));
        gtn.setUserObject(CMD_CHECKLIST);
        gtn.setAltText(translate("menu.checklist.alt"));
        root.addChild(gtn);
    }
    // add extension menues
    ExtManager extm = ExtManager.getInstance();
    Class extensionPointMenu = this.getClass();
    int cnt = extm.getExtensionCnt();
    for (int i = 0; i < cnt; i++) {
        Extension anExt = extm.getExtension(i);
        // check for sites
        ActionExtension ae = (ActionExtension) anExt.getExtensionFor(extensionPointMenu.getName(), ureq);
        if (ae != null && anExt.isEnabled()) {
            gtn = new GenericTreeNode();
            String menuText = ae.getActionText(locale);
            gtn.setTitle(menuText);
            gtn.setUserObject(ae);
            gtn.setAltText(ae.getDescription(locale));
            root.addChild(gtn);
            // inform only once
            if (!extensionLogged) {
                extensionLogged = true;
            }
        }
    }
    return gtm;
}
Also used : Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ExtManager(org.olat.core.extensions.ExtManager) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 14 with ActionExtension

use of org.olat.core.extensions.action.ActionExtension in project openolat by klemens.

the class ArchiverMainController method launchExtensionController.

/**
 * TODO:gs:a add this extension point also to the doku!
 *
 * @param ureq
 * @param cmd
 */
private void launchExtensionController(UserRequest ureq, Object cmd) {
    ActionExtension ae = (ActionExtension) cmd;
    removeAsListenerAndDispose(resC);
    ICourse course = CourseFactory.loadCourse(ores);
    this.resC = ae.createController(ureq, getWindowControl(), course);
    listenTo(resC);
    main.setContent(this.resC.getInitialComponent());
}
Also used : ActionExtension(org.olat.core.extensions.action.ActionExtension) ICourse(org.olat.course.ICourse)

Aggregations

ActionExtension (org.olat.core.extensions.action.ActionExtension)14 Extension (org.olat.core.extensions.Extension)8 GenericActionExtension (org.olat.core.extensions.action.GenericActionExtension)8 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)6 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)4 ExtManager (org.olat.core.extensions.ExtManager)4 Controller (org.olat.core.gui.control.Controller)4 MainLayoutBasicController (org.olat.core.gui.control.controller.MainLayoutBasicController)4 AssertException (org.olat.core.logging.AssertException)4 LinkedHashMap (java.util.LinkedHashMap)2 Component (org.olat.core.gui.components.Component)2 BreadcrumbPanelAware (org.olat.core.gui.components.stack.BreadcrumbPanelAware)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 WindowControl (org.olat.core.gui.control.WindowControl)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 ICourse (org.olat.course.ICourse)2