Search in sources :

Example 46 with GenericTreeModel

use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.

the class UserAdminMainController method initComponentFromMenuCommand.

private Component initComponentFromMenuCommand(Object uobject, UserRequest ureq) {
    // in any case release delete user gui lock (reaquired if user deletion is again clicked)
    releaseDeleteUserLock();
    if (uobject instanceof GenericActionExtension) {
        GenericActionExtension ae = (GenericActionExtension) uobject;
        TreeNode node = ((GenericTreeModel) olatMenuTree.getTreeModel()).findNodeByUserObject(uobject);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance("AE", new Long(node.getPosition()));
        WindowControl bwControl = addToHistory(ureq, ores, null);
        contentCtr = ae.createController(ureq, bwControl, null);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(uobject.toString(), 0l);
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
    // first check if it is node which opens a subtree with further uobject.tree.commands
    if (uobject.equals("menuroles")) {
        if (rolesVC == null) {
            rolesVC = createVelocityContainer("systemroles");
        }
        addToHistory(ureq, bwControl);
        return rolesVC;
    } else if (uobject.equals("menuqueries")) {
        if (queriesVC == null) {
            queriesVC = createVelocityContainer("predefinedqueries");
        }
        addToHistory(ureq, bwControl);
        return queriesVC;
    } else if (uobject.equals("menuaccess")) {
        if (queriesVC == null) {
            queriesVC = createVelocityContainer("systemroles");
        }
        addToHistory(ureq, bwControl);
        return queriesVC;
    } else if (uobject.equals("userdelete")) {
        // creates the user deletin controller
        // if locking fails -> a contentCtrl is created
        // -> hence removeAsListenerAndDispose(contentCtr) is delegated to the method called!
        addToHistory(ureq, bwControl);
        return createAndLockUserDeleteController(ureq, bwControl);
    } else if (uobject.equals("userdelete_direct")) {
        // creates the user deletin controller
        // if locking fails -> a contentCtrl is created
        // -> hence removeAsListenerAndDispose(contentCtr) is delegated to the method called!
        addToHistory(ureq, bwControl);
        return createAndLockDirectUserDeleteController(ureq, bwControl);
    }
    if (uobject.equals("usearch") || uobject.equals("useradmin")) {
        if (contentCtr != userSearchCtrl) {
            activatePaneInDetailView = null;
            contentCtr = userSearchCtrl = new UsermanagerUserSearchController(ureq, bwControl);
            listenTo(contentCtr);
        }
        addToHistory(ureq, bwControl);
        return contentCtr.getInitialComponent();
    }
    // these nodes re-create (not stateful) content Controller (contentCtrl)
    removeAsListenerAndDispose(contentCtr);
    if (uobject.equals("ucreate")) {
        activatePaneInDetailView = null;
        boolean canCreateOLATPassword = false;
        if (ureq.getUserSession().getRoles().isOLATAdmin()) {
            // admin will override configuration
            canCreateOLATPassword = true;
        } else {
            Boolean canCreatePwdByConfig = BaseSecurityModule.USERMANAGER_CAN_CREATE_PWD;
            canCreateOLATPassword = canCreatePwdByConfig.booleanValue();
        }
        contentCtr = new UserCreateController(ureq, bwControl, canCreateOLATPassword);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usersimport")) {
        activatePaneInDetailView = null;
        boolean canCreateOLATPassword = false;
        if (ureq.getUserSession().getRoles().isOLATAdmin()) {
            // admin will override configuration
            canCreateOLATPassword = true;
        } else {
            Boolean canCreatePwdByConfig = BaseSecurityModule.USERMANAGER_CAN_CREATE_PWD;
            canCreateOLATPassword = canCreatePwdByConfig.booleanValue();
        }
        contentCtr = new UserImportController(ureq, bwControl, canCreateOLATPassword);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("admingroup")) {
        activatePaneInDetailView = null;
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("authorgroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("coauthors")) {
        activatePaneInDetailView = "edit.uroles";
        // special case: use user search controller and search for all users that have author rights
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.owner.name());
        UsermanagerUserSearchController myCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        // now subtract users that are in the author group to get the co-authors
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        List<Identity> identitiesFromAuthorGroup = securityManager.getVisibleIdentitiesByPowerSearch(null, null, true, secGroup, null, null, null, null);
        myCtr.removeIdentitiesFromSearchResult(ureq, identitiesFromAuthorGroup);
        contentCtr = myCtr;
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("resourceowners")) {
        activatePaneInDetailView = "edit.uroles";
        // First get all resource owners (co-authors) ...
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.owner.name());
        UsermanagerUserSearchController myCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        // ... now add users that are in the author group but don't own a resource yet
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS) };
        List<Identity> identitiesFromAuthorGroup = securityManager.getVisibleIdentitiesByPowerSearch(null, null, true, secGroup, null, null, null, null);
        myCtr.addIdentitiesToSearchResult(ureq, identitiesFromAuthorGroup);
        contentCtr = myCtr;
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("courseparticipants")) {
        activatePaneInDetailView = "edit.courses";
        List<Identity> resourceOwners = repositoryService.getIdentitiesWithRole(GroupRoles.participant.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, resourceOwners, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("groupmanagergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    if (uobject.equals("coursecoach")) {
        activatePaneInDetailView = "edit.uroles";
        List<Identity> coaches = repositoryService.getIdentitiesWithRole(GroupRoles.coach.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, coaches, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    }
    if (uobject.equals("groupcoach")) {
        activatePaneInDetailView = "edit.uroles";
        List<Identity> coaches = businessGroupService.getIdentitiesWithRole(GroupRoles.coach.name());
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, coaches, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usermanagergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_USERMANAGERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usergroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("anonymousgroup")) {
        activatePaneInDetailView = "edit.uroles";
        SecurityGroup[] secGroup = { securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS) };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, secGroup, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("userswithoutgroup")) {
        activatePaneInDetailView = "edit.withoutgroup";
        List<Identity> usersWithoutGroup = securityManager.findIdentitiesWithoutBusinessGroup(Identity.STATUS_VISIBLE_LIMIT);
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersWithoutGroup, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("userswithoutemail")) {
        activatePaneInDetailView = "userswithoutemail";
        List<Identity> usersWithoutEmail = userManager.findVisibleIdentitiesWithoutEmail();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersWithoutEmail, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("usersemailduplicates")) {
        activatePaneInDetailView = "users.email.duplicate";
        List<Identity> usersEmailDuplicates = userManager.findVisibleIdentitiesWithEmailDuplicates();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, usersEmailDuplicates, null, true, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("logondeniedgroup")) {
        activatePaneInDetailView = "edit.uroles";
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("deletedusers")) {
        activatePaneInDetailView = "list.deletedusers";
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, null, null, Identity.STATUS_DELETED, false);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.lastweek")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, -7);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.lastmonth")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, -1);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.sixmonth")) {
        activatePaneInDetailView = null;
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, -6);
        Date time = cal.getTime();
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, null, time, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("created.newUsersNotification")) {
        activatePaneInDetailView = null;
        bwControl = addToHistory(ureq, ores, null);
        contentCtr = new NewUsersNotificationsController(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else if (uobject.equals("noauthentication")) {
        activatePaneInDetailView = null;
        String[] auth = { null };
        contentCtr = new UsermanagerUserSearchController(ureq, bwControl, null, null, auth, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
        addToHistory(ureq, bwControl);
        listenTo(contentCtr);
        return contentCtr.getInitialComponent();
    } else {
        // to be removed
        throw new AssertException("did not expect to land here in UserAdminMainController this is because uboject is " + uobject.toString());
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) Calendar(java.util.Calendar) UserCreateController(org.olat.admin.user.UserCreateController) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) WindowControl(org.olat.core.gui.control.WindowControl) SecurityGroup(org.olat.basesecurity.SecurityGroup) UserImportController(org.olat.admin.user.imp.UserImportController) Date(java.util.Date) UsermanagerUserSearchController(org.olat.admin.user.UsermanagerUserSearchController) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) List(java.util.List) Identity(org.olat.core.id.Identity) NewUsersNotificationsController(org.olat.admin.user.NewUsersNotificationsController)

Example 47 with GenericTreeModel

use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.

the class UserAdminMainController method buildTreeModel.

private TreeModel buildTreeModel(UserRequest ureq) {
    boolean isOlatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
    GenericTreeNode gtnChild, admin;
    Translator translator = getTranslator();
    GenericTreeModel gtm = new GenericTreeModel();
    admin = new GenericTreeNode();
    admin.setTitle(translator.translate("menu.useradmin"));
    admin.setUserObject("useradmin");
    admin.setCssClass("o_sel_useradmin");
    admin.setAltText(translator.translate("menu.useradmin.alt"));
    gtm.setRootNode(admin);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.usearch"));
    gtnChild.setUserObject("usearch");
    gtnChild.setCssClass("o_sel_useradmin_search");
    gtnChild.setAltText(translator.translate("menu.usearch.alt"));
    admin.setDelegate(gtnChild);
    admin.addChild(gtnChild);
    Boolean canCreate = BaseSecurityModule.USERMANAGER_CAN_CREATE_USER;
    if (canCreate.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.ucreate"));
        gtnChild.setUserObject("ucreate");
        gtnChild.setCssClass("o_sel_useradmin_create");
        gtnChild.setAltText(translator.translate("menu.ucreate.alt"));
        admin.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.usersimport"));
        gtnChild.setUserObject("usersimport");
        gtnChild.setCssClass("o_sel_useradmin_import");
        gtnChild.setAltText(translator.translate("menu.usersimport.alt"));
        admin.addChild(gtnChild);
    }
    Boolean canDelete = BaseSecurityModule.USERMANAGER_CAN_DELETE_USER;
    if (canDelete.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.userdelete"));
        gtnChild.setUserObject("userdelete");
        gtnChild.setCssClass("o_sel_useradmin_delete");
        gtnChild.setAltText(translator.translate("menu.userdelete.alt"));
        admin.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.userdelete.direct"));
        gtnChild.setUserObject("userdelete_direct");
        gtnChild.setCssClass("o_sel_useradmin_direct_delete");
        gtnChild.setAltText(translator.translate("menu.userdelete.direct.alt"));
        admin.addChild(gtnChild);
    }
    // START submenu access and rights
    GenericTreeNode gtn3 = new GenericTreeNode();
    gtn3.setTitle(translator.translate("menu.menuaccess"));
    gtn3.setUserObject("menuaccess");
    gtn3.setAltText(translator.translate("menu.menuaccess.alt"));
    admin.addChild(gtn3);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.usergroup"));
    gtnChild.setUserObject("usergroup");
    gtnChild.setAltText(translator.translate("menu.usergroup.alt"));
    gtn3.addChild(gtnChild);
    Boolean canAuthors = BaseSecurityModule.USERMANAGER_CAN_MANAGE_AUTHORS;
    if (canAuthors.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.authorgroup"));
        gtnChild.setUserObject("authorgroup");
        gtnChild.setAltText(translator.translate("menu.authorgroup.alt"));
        gtn3.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.coauthors"));
        gtnChild.setUserObject("coauthors");
        gtnChild.setAltText(translator.translate("menu.coauthors.alt"));
        gtn3.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.resourceowners"));
        gtnChild.setUserObject("resourceowners");
        gtnChild.setAltText(translator.translate("menu.resourceowners.alt"));
        gtn3.addChild(gtnChild);
    }
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.coursecoach"));
    gtnChild.setUserObject("coursecoach");
    gtnChild.setAltText(translator.translate("menu.coursecoach.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.courseparticipants"));
    gtnChild.setUserObject("courseparticipants");
    gtnChild.setAltText(translator.translate("menu.courseparticipants.alt"));
    gtn3.addChild(gtnChild);
    Boolean canGroupmanagers = BaseSecurityModule.USERMANAGER_CAN_MANAGE_GROUPMANAGERS;
    if (canGroupmanagers.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.groupmanagergroup"));
        gtnChild.setUserObject("groupmanagergroup");
        gtnChild.setAltText(translator.translate("menu.groupmanagergroup.alt"));
        gtn3.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.groupcoach"));
        gtnChild.setUserObject("groupcoach");
        gtnChild.setAltText(translator.translate("menu.groupcoach.alt"));
        gtn3.addChild(gtnChild);
    }
    // admin group and user manager group always restricted to admins
    if (isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.usermanagergroup"));
        gtnChild.setUserObject("usermanagergroup");
        gtnChild.setAltText(translator.translate("menu.usermanagergroup.alt"));
        gtn3.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.admingroup"));
        gtnChild.setUserObject("admingroup");
        gtnChild.setAltText(translator.translate("menu.admingroup.alt"));
        gtn3.addChild(gtnChild);
    }
    Boolean canGuests = BaseSecurityModule.USERMANAGER_CAN_MANAGE_GUESTS;
    if (canGuests.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.anonymousgroup"));
        gtnChild.setUserObject("anonymousgroup");
        gtnChild.setAltText(translator.translate("menu.anonymousgroup.alt"));
        gtn3.addChild(gtnChild);
    }
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.noauthentication"));
    gtnChild.setUserObject("noauthentication");
    gtnChild.setAltText(translator.translate("menu.noauthentication.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.logondeniedgroup"));
    gtnChild.setUserObject("logondeniedgroup");
    gtnChild.setAltText(translator.translate("menu.logondeniedgroup.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.deletedusers"));
    gtnChild.setUserObject("deletedusers");
    gtnChild.setAltText(translator.translate("menu.deletedusers.alt"));
    gtn3.addChild(gtnChild);
    // END submenu access and rights
    // START other queries
    gtn3 = new GenericTreeNode();
    gtn3.setTitle(translator.translate("menu.menuqueries"));
    gtn3.setUserObject("menuqueries");
    gtn3.setAltText(translator.translate("menu.menuqueries.alt"));
    admin.addChild(gtn3);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.userswithoutgroup"));
    gtnChild.setUserObject("userswithoutgroup");
    gtnChild.setAltText(translator.translate("menu.userswithoutgroup.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.users.without.email"));
    gtnChild.setUserObject("userswithoutemail");
    gtnChild.setAltText(translator.translate("menu.users.without.email.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.users.email.duplicate"));
    gtnChild.setUserObject("usersemailduplicates");
    gtnChild.setAltText(translator.translate("menu.users.email.duplicate.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.created.lastweek"));
    gtnChild.setUserObject("created.lastweek");
    gtnChild.setAltText(translator.translate("menu.created.lastweek.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.created.lastmonth"));
    gtnChild.setUserObject("created.lastmonth");
    gtnChild.setAltText(translator.translate("menu.created.lastmonth.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.created.sixmonth"));
    gtnChild.setUserObject("created.sixmonth");
    gtnChild.setAltText(translator.translate("menu.created.sixmonth.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.created.newUsersNotification"));
    gtnChild.setUserObject("created.newUsersNotification");
    gtnChild.setAltText(translator.translate("menu.created.newUsersNotification.alt"));
    gtn3.addChild(gtnChild);
    // add extension menues as child items
    ExtManager extm = ExtManager.getInstance();
    int cnt = extm.getExtensionCnt();
    for (int i = 0; i < cnt; i++) {
        Extension anExt = extm.getExtension(i);
        // 1) general menu extensions
        ExtensionElement ee = anExt.getExtensionFor(UserAdminMainController.class.getName() + EXTENSIONPOINT_MENU_MENUQUERIES, ureq);
        if (ee instanceof GenericActionExtension && anExt.isEnabled()) {
            GenericActionExtension ae = (GenericActionExtension) ee;
            gtnChild = new GenericTreeNode();
            String menuText = ae.getActionText(getLocale());
            gtnChild.setTitle(menuText);
            gtnChild.setUserObject(ae);
            gtnChild.setAltText(ae.getDescription(getLocale()));
            gtn3.addChild(gtnChild);
            // inform only once
            if (!extensionLogged) {
                logInfo("added menu entry for locale " + getLocale().toString() + " '" + menuText + "'", null);
            }
        }
    }
    extensionLogged = true;
    // END other queries
    return gtm;
}
Also used : Extension(org.olat.core.extensions.Extension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) Translator(org.olat.core.gui.translator.Translator) ExtManager(org.olat.core.extensions.ExtManager) ExtensionElement(org.olat.core.extensions.ExtensionElement) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension)

Example 48 with GenericTreeModel

use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.

the class CatalogHelper method createCatalogTree.

/**
 * Map the OLAT catalog structure to a new tree model.
 *
 * @param rootEntry root catalog entry
 * @return tree model with catalog structure
 */
public static final TreeModel createCatalogTree(final CatalogEntry rootEntry) {
    final GenericTreeModel tm = new GenericTreeModel();
    tm.setRootNode(buildCatalogNode(rootEntry));
    return tm;
}
Also used : GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 49 with GenericTreeModel

use of org.olat.core.gui.components.tree.GenericTreeModel 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)

Example 50 with GenericTreeModel

use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.

the class GenericMainController method activateTreeNodeByActionExtension.

/**
 * activates the correct treenode for a given ActionExtension
 * @param ureq
 * @param ae
 */
private void activateTreeNodeByActionExtension(UserRequest ureq, ActionExtension ae) {
    TreeNode node = ((GenericTreeModel) olatMenuTree.getTreeModel()).findNodeByUserObject(ae);
    if (node != null) {
        olatMenuTree.setSelectedNodeId(node.getIdent());
        TreeEvent te = new TreeEvent(MenuTree.COMMAND_TREENODE_CLICKED, node.getIdent());
        event(ureq, olatMenuTree, te);
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Aggregations

GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)62 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)42 TreeNode (org.olat.core.gui.components.tree.TreeNode)20 CourseNode (org.olat.course.nodes.CourseNode)12 Extension (org.olat.core.extensions.Extension)10 GenericActionExtension (org.olat.core.extensions.action.GenericActionExtension)10 AssertException (org.olat.core.logging.AssertException)10 ArrayList (java.util.ArrayList)8 ActionExtension (org.olat.core.extensions.action.ActionExtension)8 Controller (org.olat.core.gui.control.Controller)8 WindowControl (org.olat.core.gui.control.WindowControl)8 Identity (org.olat.core.id.Identity)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 STCourseNode (org.olat.course.nodes.STCourseNode)8 NodeEvaluation (org.olat.course.run.userview.NodeEvaluation)8 List (java.util.List)6 ExtManager (org.olat.core.extensions.ExtManager)6 TreeModel (org.olat.core.gui.components.tree.TreeModel)6 ControllerEventListener (org.olat.core.gui.control.ControllerEventListener)6 TitledWrapperController (org.olat.core.gui.control.generic.title.TitledWrapperController)6