Search in sources :

Example 6 with ActionExtension

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

the class ArchiverMainController 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
public void event(UserRequest ureq, Component source, Event event) {
    if (source == menuTree) {
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            // goto node in edit mode
            TreeNode selTreeNode = menuTree.getSelectedNode();
            Object cmd = selTreeNode.getUserObject();
            if (cmd instanceof ActionExtension) {
                launchExtensionController(ureq, cmd);
            } else {
                launchArchiveControllers(ureq, (String) cmd);
            }
        }
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) ActionExtension(org.olat.core.extensions.action.ActionExtension)

Example 7 with ActionExtension

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

the class GenericMainController method createController.

/**
 * creates Controller for clicked Node, default implementation.
 *
 * @param ae
 * @param ureq
 * @return corresponding controller
 */
protected Controller createController(ActionExtension ae, UserRequest ureq) {
    // default implementation for simple case where action extension.
    WindowControl bwControl = getWindowControl();
    if (olatMenuTree.getTreeModel() instanceof GenericTreeModel) {
        if (ae instanceof Extension) {
            Extension nE = (Extension) ae;
            // get our ores for the extension
            OLATResourceable ores;
            if (ae instanceof GenericActionExtension && StringHelper.containsNonWhitespace(((GenericActionExtension) ae).getNavigationKey())) {
                // there is a navigation-key, use the nice way
                ores = OresHelper.createOLATResourceableInstance(((GenericActionExtension) ae).getNavigationKey(), 0L);
            } else {
                ores = OresHelper.createOLATResourceableInstance(GMCMT, CodeHelper.getUniqueIDFromString(nE.getUniqueExtensionID()));
            }
            ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
            bwControl = addToHistory(ureq, ores, null);
        }
    }
    Controller ctrl = ae.createController(ureq, bwControl, null);
    if (ctrl instanceof BreadcrumbPanelAware) {
        ((BreadcrumbPanelAware) ctrl).setBreadcrumbPanel(stackVC);
    }
    return ctrl;
}
Also used : Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) BreadcrumbPanelAware(org.olat.core.gui.components.stack.BreadcrumbPanelAware) OLATResourceable(org.olat.core.id.OLATResourceable) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) WindowControl(org.olat.core.gui.control.WindowControl) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController)

Example 8 with ActionExtension

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

the class GenericMainController method buildTreeModel.

private TreeModel buildTreeModel(UserRequest ureq) {
    GenericTreeNode rootTreeNode = new GenericTreeNode();
    rootTreeNode.setTitle(getTranslator().translate("main.menu.title"));
    rootTreeNode.setAltText(getTranslator().translate("main.menu.title.alt"));
    GenericTreeModel gtm = new GenericTreeModel();
    gtm.setRootNode(rootTreeNode);
    // Prepend
    boolean rootNodeSet = false;
    if (nodesToPrepend.size() != 0) {
        for (GenericTreeNode node : nodesToPrepend) {
            rootTreeNode.addChild(node);
            if (!rootNodeSet) {
                rootTreeNode.setDelegate(node);
                rootTreeNode.setUserObject(node.getUserObject());
                rootNodeSet = true;
            }
        }
    }
    // add extension menues
    ExtManager extm = ExtManager.getInstance();
    int j = 0;
    GenericTreeNode gtnChild;
    Map<GenericTreeNode, String> subMenuNodes = new LinkedHashMap<GenericTreeNode, String>();
    for (Extension anExt : extm.getExtensions()) {
        // check for sites
        ActionExtension ae = (ActionExtension) anExt.getExtensionFor(className, ureq);
        if (ae != null && ae instanceof GenericActionExtension) {
            if (anExt.isEnabled()) {
                GenericActionExtension gAe = (GenericActionExtension) ae;
                gtnChild = gAe.createMenuNode(ureq);
                if (StringHelper.containsNonWhitespace(gAe.getNavigationKey())) {
                    gtnChild.setCssClass("o_sel_" + gAe.getNavigationKey());
                }
                if (gAe.getNodeIdentifierIfParent() != null) {
                    // it's a parent-node, set identifier
                    gtnChild.setIdent(gAe.getNodeIdentifierIfParent());
                }
                if (j == 0 && !rootNodeSet) {
                    // first node, set as delegate of rootTreenode
                    rootTreeNode.setDelegate(gtnChild);
                    rootTreeNode.setUserObject(gAe);
                    rootTreeNode.addChild(gtnChild);
                } else // navigation (submenues)
                if (gAe.getParentTreeNodeIdentifier() != null) {
                    // this is a sub-menu-node, do not add to tree-model already, since
                    // parent tree may not yet be in model
                    // (parent could be "after" child, in ActionExtensions-Collection)
                    String parentNodeID = gAe.getParentTreeNodeIdentifier();
                    subMenuNodes.put(gtnChild, parentNodeID);
                } else // "normal" menu-entry
                {
                    rootTreeNode.addChild(gtnChild);
                }
                j++;
            } else {
                logInfo("found disabled GenericActionExtension for " + className + " ", ae.toString());
            }
        }
    }
    // loop over submenuNodes and add to their parents
    for (Entry<GenericTreeNode, String> childNodeEntry : subMenuNodes.entrySet()) {
        GenericTreeNode childNode = childNodeEntry.getKey();
        GenericTreeNode parentNode = (GenericTreeNode) gtm.getNodeById(childNodeEntry.getValue());
        if (parentNode != null) {
            parentNode.addChild(childNode);
            if (parentNode.getDelegate() == null) {
                boolean addDelegate = true;
                // add delegate only if hte parent hasn't not a controller defined
                Object uo = parentNode.getUserObject();
                if (uo instanceof GenericActionExtension) {
                    GenericActionExtension gae = (GenericActionExtension) uo;
                    if (StringHelper.containsNonWhitespace(gae.getClassNameOfCorrespondingController())) {
                        addDelegate = false;
                    }
                }
                if (addDelegate) {
                    parentNode.setDelegate(childNode);
                    parentNode.setUserObject(childNode.getUserObject());
                }
            }
        } else {
            logWarn("Could not add navigation-menu (" + childNode.getTitle() + ") to parent:: " + childNodeEntry.getValue(), null);
            // make it at least appear on top level
            rootTreeNode.addChild(childNode);
        }
    }
    // Append
    if (nodesToAppend.size() != 0) {
        for (GenericTreeNode node : nodesToAppend) {
            rootTreeNode.addChild(node);
        }
    }
    return gtm;
}
Also used : ExtManager(org.olat.core.extensions.ExtManager) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) LinkedHashMap(java.util.LinkedHashMap) Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 9 with ActionExtension

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

the class ArchiverMainController 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
public void event(UserRequest ureq, Component source, Event event) {
    if (source == menuTree) {
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            // goto node in edit mode
            TreeNode selTreeNode = menuTree.getSelectedNode();
            Object cmd = selTreeNode.getUserObject();
            if (cmd instanceof ActionExtension) {
                launchExtensionController(ureq, cmd);
            } else {
                launchArchiveControllers(ureq, (String) cmd);
            }
        }
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) ActionExtension(org.olat.core.extensions.action.ActionExtension)

Example 10 with ActionExtension

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

the class GenericMainController method createController.

/**
 * creates Controller for clicked Node, default implementation.
 *
 * @param ae
 * @param ureq
 * @return corresponding controller
 */
protected Controller createController(ActionExtension ae, UserRequest ureq) {
    // default implementation for simple case where action extension.
    WindowControl bwControl = getWindowControl();
    if (olatMenuTree.getTreeModel() instanceof GenericTreeModel) {
        if (ae instanceof Extension) {
            Extension nE = (Extension) ae;
            // get our ores for the extension
            OLATResourceable ores;
            if (ae instanceof GenericActionExtension && StringHelper.containsNonWhitespace(((GenericActionExtension) ae).getNavigationKey())) {
                // there is a navigation-key, use the nice way
                ores = OresHelper.createOLATResourceableInstance(((GenericActionExtension) ae).getNavigationKey(), 0L);
            } else {
                ores = OresHelper.createOLATResourceableInstance(GMCMT, CodeHelper.getUniqueIDFromString(nE.getUniqueExtensionID()));
            }
            ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
            bwControl = addToHistory(ureq, ores, null);
        }
    }
    Controller ctrl = ae.createController(ureq, bwControl, null);
    if (ctrl instanceof BreadcrumbPanelAware) {
        ((BreadcrumbPanelAware) ctrl).setBreadcrumbPanel(stackVC);
    }
    return ctrl;
}
Also used : Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) BreadcrumbPanelAware(org.olat.core.gui.components.stack.BreadcrumbPanelAware) OLATResourceable(org.olat.core.id.OLATResourceable) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) WindowControl(org.olat.core.gui.control.WindowControl) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController)

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