use of org.olat.core.gui.components.tree.GenericTreeModel in project OpenOLAT by OpenOLAT.
the class StatisticCourseNodesController method buildTreeModel.
private TreeModel buildTreeModel(final UserRequest ureq, final UserCourseEnvironment userCourseEnv) {
final GenericTreeModel gtm = new GenericTreeModel();
final GenericTreeNode rootTreeNode = new GenericTreeNode();
rootTreeNode.setTitle("start");
gtm.setRootNode(rootTreeNode);
ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseResourceableId());
new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
CourseNode courseNode = (CourseNode) node;
StatisticResourceResult result = courseNode.createStatisticNodeResult(ureq, getWindowControl(), userCourseEnv, options, types);
if (result != null) {
StatisticResourceNode courseNodeTreeNode = new StatisticResourceNode(courseNode, result);
rootTreeNode.addChild(courseNodeTreeNode);
TreeModel subTreeModel = result.getSubTreeModel();
if (subTreeModel != null) {
TreeNode subRootNode = subTreeModel.getRootNode();
List<INode> subNodes = new ArrayList<>();
for (int i = 0; i < subRootNode.getChildCount(); i++) {
subNodes.add(subRootNode.getChildAt(i));
}
for (INode subNode : subNodes) {
courseNodeTreeNode.addChild(subNode);
}
}
}
}
}, course.getRunStructure().getRootNode(), true).visitAll();
return gtm;
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project OpenOLAT by OpenOLAT.
the class UserInfoMainController method buildTreeModel.
/**
* Generates the archiver menu
*
* @return The generated menu tree model
* @param firstLastName
*/
private GenericTreeModel buildTreeModel(String name) {
GenericTreeNode root, gtn;
GenericTreeModel gtm = new GenericTreeModel();
root = new GenericTreeNode();
root.setTitle(name);
root.setAltText(name);
root.setAccessible(false);
gtm.setRootNode(root);
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.homepage"));
gtn.setUserObject(CMD_HOMEPAGE);
gtn.setAltText(translate("menu.homepage.alt"));
root.addChild(gtn);
// following user info elements are only shown for undeleted and real
// users (not invited
// eportfolio users)
boolean isInvitee = invitationDao.isInvitee(chosenIdentity);
boolean isDeleted = chosenIdentity.getStatus().equals(Identity.STATUS_DELETED);
if (!isDeleted && !isInvitee) {
if (calendarModule.isEnablePersonalCalendar()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.calendar"));
gtn.setUserObject(CMD_CALENDAR);
gtn.setAltText(translate("menu.calendar.alt"));
gtn.setCssClass("o_visiting_card_calendar");
root.addChild(gtn);
}
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.folder"));
gtn.setUserObject(CMD_FOLDER);
gtn.setAltText(translate("menu.folder.alt"));
gtn.setCssClass("o_visiting_card_folder");
root.addChild(gtn);
}
if (!isDeleted) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.contact"));
gtn.setUserObject(CMD_CONTACT);
gtn.setAltText(translate("menu.contact.alt"));
gtn.setCssClass("o_visiting_card_contact");
root.addChild(gtn);
}
if (!isDeleted && !isInvitee) {
PortfolioModule portfolioModule = (PortfolioModule) CoreSpringFactory.getBean("portfolioModule");
if (portfolioModule.isEnabled()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.portfolio"));
gtn.setUserObject(CMD_PORTFOLIO);
gtn.setAltText(translate("menu.portfolio.alt"));
gtn.setCssClass("o_visiting_card_portfolio");
root.addChild(gtn);
}
}
return gtm;
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project OpenOLAT by OpenOLAT.
the class BusinessGroupMainRunController method buildTreeModel.
/**
* @return The menu tree model
*/
private TreeModel buildTreeModel() {
GenericTreeNode gtnChild, root;
GenericTreeModel gtm = new GenericTreeModel();
root = new GenericTreeNode(nodeIdPrefix.concat("-root"));
root.setTitle(businessGroup.getName());
root.setUserObject(ACTIVITY_MENUSELECT_OVERVIEW);
root.setAltText(translate("menutree.top.alt") + " " + businessGroup.getName());
root.setIconCssClass("o_icon o_icon_group");
gtm.setRootNode(root);
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(this.businessGroup);
if (collabTools.isToolEnabled(CollaborationTools.TOOL_NEWS)) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("new"));
gtnChild.setTitle(translate("menutree.news"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_INFORMATION);
gtnChild.setAltText(translate("menutree.news.alt"));
gtnChild.setIconCssClass("o_icon_news");
gtnChild.setCssClass("o_sel_group_news");
root.addChild(gtnChild);
nodeInformation = gtnChild;
}
if (calendarModule.isEnabled() && calendarModule.isEnableGroupCalendar() && collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("cal"));
gtnChild.setTitle(translate("menutree.calendar"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_CALENDAR);
gtnChild.setAltText(translate("menutree.calendar.alt"));
gtnChild.setIconCssClass("o_calendar_icon");
gtnChild.setCssClass("o_sel_group_calendar");
root.addChild(gtnChild);
nodeCal = gtnChild;
}
boolean hasResources = businessGroupService.hasResources(businessGroup);
if (hasResources) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("courses"));
gtnChild.setTitle(translate("menutree.resources"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_SHOW_RESOURCES);
gtnChild.setAltText(translate("menutree.resources.alt"));
gtnChild.setIconCssClass("o_CourseModule_icon");
gtnChild.setCssClass("o_sel_group_resources");
root.addChild(gtnChild);
nodeResources = gtnChild;
}
if (businessGroup.isOwnersVisibleIntern() || businessGroup.isParticipantsVisibleIntern() || businessGroup.isWaitingListVisibleIntern()) {
// either owners, participants, the waiting list or all three are visible
// otherwise the node is not visible
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("members"));
gtnChild.setTitle(translate("menutree.members"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_MEMBERSLIST);
gtnChild.setAltText(translate("menutree.members.alt"));
gtnChild.setIconCssClass("o_icon_group");
gtnChild.setCssClass("o_sel_group_members");
root.addChild(gtnChild);
nodeGroupOwners = gtnChild;
}
if (collabTools.isToolEnabled(CollaborationTools.TOOL_CONTACT)) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("contact"));
gtnChild.setTitle(translate("menutree.contactform"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_CONTACTFORM);
gtnChild.setAltText(translate("menutree.contactform.alt"));
gtnChild.setIconCssClass("o_co_icon");
gtnChild.setCssClass("o_sel_group_contact");
root.addChild(gtnChild);
nodeContact = gtnChild;
}
if (collabTools.isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("folder"));
gtnChild.setTitle(translate("menutree.folder"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_FOLDER);
gtnChild.setAltText(translate("menutree.folder.alt"));
gtnChild.setIconCssClass("o_bc_icon");
gtnChild.setCssClass("o_sel_group_folder");
root.addChild(gtnChild);
nodeFolder = gtnChild;
}
if (collabTools.isToolEnabled(CollaborationTools.TOOL_FORUM)) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("forum"));
gtnChild.setTitle(translate("menutree.forum"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_FORUM);
gtnChild.setAltText(translate("menutree.forum.alt"));
gtnChild.setIconCssClass("o_fo_icon");
gtnChild.setCssClass("o_sel_group_forum");
root.addChild(gtnChild);
nodeForum = gtnChild;
}
if (chatAvailable) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("chat"));
gtnChild.setTitle(translate("menutree.chat"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_CHAT);
gtnChild.setAltText(translate("menutree.chat.alt"));
gtnChild.setIconCssClass("o_icon_chat");
gtnChild.setCssClass("o_sel_group_chat");
root.addChild(gtnChild);
}
BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI) && securityModule.isWikiEnabled()) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("wiki"));
gtnChild.setTitle(translate("menutree.wiki"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_WIKI);
gtnChild.setAltText(translate("menutree.wiki.alt"));
gtnChild.setIconCssClass("o_wiki_icon");
gtnChild.setCssClass("o_sel_group_wiki");
root.addChild(gtnChild);
nodeWiki = gtnChild;
}
if (collabTools.isToolEnabled(CollaborationTools.TOOL_PORTFOLIO) && (portfolioModule.isEnabled() || portfolioV2Module.isEnabled())) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("eportfolio"));
gtnChild.setTitle(translate("menutree.portfolio"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_PORTFOLIO);
gtnChild.setAltText(translate("menutree.portfolio.alt"));
gtnChild.setIconCssClass("o_ep_icon");
gtnChild.setCssClass("o_sel_group_portfolio");
root.addChild(gtnChild);
nodePortfolio = gtnChild;
}
OpenMeetingsModule openMeetingsModule = CoreSpringFactory.getImpl(OpenMeetingsModule.class);
if (openMeetingsModule.isEnabled() && collabTools.isToolEnabled(CollaborationTools.TOOL_OPENMEETINGS)) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("meetings"));
gtnChild.setTitle(translate("menutree.openmeetings"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_OPENMEETINGS);
gtnChild.setAltText(translate("menutree.openmeetings.alt"));
gtnChild.setIconCssClass("o_openmeetings_icon");
root.addChild(gtnChild);
nodeOpenMeetings = gtnChild;
}
if (isAdmin) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("admin"));
gtnChild.setTitle(translate("menutree.administration"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_ADMINISTRATION);
gtnChild.setIdent(ACTIVITY_MENUSELECT_ADMINISTRATION);
gtnChild.setAltText(translate("menutree.administration.alt"));
gtnChild.setIconCssClass("o_icon_settings");
root.addChild(gtnChild);
adminNodeId = gtnChild.getIdent();
nodeAdmin = gtnChild;
AccessControlModule acModule = (AccessControlModule) CoreSpringFactory.getBean("acModule");
if (acModule.isEnabled() && acService.isResourceAccessControled(businessGroup.getResource(), null)) {
gtnChild = new GenericTreeNode(nodeIdPrefix.concat("ac"));
gtnChild.setTitle(translate("menutree.ac"));
gtnChild.setUserObject(ACTIVITY_MENUSELECT_AC);
gtnChild.setIdent(ACTIVITY_MENUSELECT_AC);
gtnChild.setAltText(translate("menutree.ac.alt"));
gtnChild.setIconCssClass("o_icon_booking");
root.addChild(gtnChild);
}
}
return gtm;
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class UserAdminMainController method activate.
public void activate(UserRequest ureq, String viewIdentifier) {
if (viewIdentifier == null)
return;
if (viewIdentifier.startsWith("notifications") || viewIdentifier.startsWith("NewIdentityCreated")) {
GenericTreeModel tm = (GenericTreeModel) olatMenuTree.getTreeModel();
TreeNode node = tm.findNodeByUserObject("created.newUsersNotification");
olatMenuTree.setSelectedNode(node);
Component resComp = initComponentFromMenuCommand("created.newUsersNotification", ureq);
content.setContent(resComp);
} else if (viewIdentifier.startsWith("AE")) {
String posStr = viewIdentifier.substring(3);
try {
GenericTreeModel treeModel = (GenericTreeModel) olatMenuTree.getTreeModel();
TreeNode node = treeModel.findNodeByUserObject("menuqueries");
int pos = Integer.parseInt(posStr);
if (pos >= 0 && pos < node.getChildCount()) {
TreeNode childNode = (TreeNode) node.getChildAt(pos);
olatMenuTree.setSelectedNode(childNode);
Component resComp = initComponentFromMenuCommand(childNode.getUserObject(), ureq);
content.setContent(resComp);
}
} catch (Exception e) {
logWarn("", e);
}
} else {
int first = viewIdentifier.indexOf(":");
String uobject = viewIdentifier.substring(0, first);
GenericTreeModel treeModel = (GenericTreeModel) olatMenuTree.getTreeModel();
TreeNode node = treeModel.findNodeByUserObject(uobject);
if (node == null) {
node = treeModel.getRootNode();
uobject = (String) node.getUserObject();
}
olatMenuTree.setSelectedNode(node);
Component resComp = initComponentFromMenuCommand(uobject, ureq);
content.setContent(resComp);
}
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class UserAdminMainController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
GenericTreeModel tm = (GenericTreeModel) olatMenuTree.getTreeModel();
ContextEntry entry = entries.get(0);
String entryPoint = entry.getOLATResourceable().getResourceableTypeName();
if (entryPoint.startsWith("notifications") || entryPoint.startsWith("NewIdentityCreated")) {
TreeNode node = tm.findNodeByUserObject("created.newUsersNotification");
selectNode(ureq, node);
} else if (entryPoint.startsWith("AE")) {
TreeNode node = tm.findNodeByUserObject("menuqueries");
int pos = entries.get(0).getOLATResourceable().getResourceableId().intValue();
if (pos >= 0 && pos < node.getChildCount()) {
TreeNode childNode = (TreeNode) node.getChildAt(pos);
selectNode(ureq, childNode);
}
} else {
TreeNode node = tm.findNodeByUserObject(entryPoint);
if (node != null) {
selectNode(ureq, node);
entries = entries.subList(1, entries.size());
if (contentCtr instanceof Activateable2) {
((Activateable2) contentCtr).activate(ureq, entries, entry.getTransientState());
}
if (!entries.isEmpty() && userAdminCtr != null) {
userAdminCtr.activate(ureq, entries, null);
}
}
}
}
Aggregations