use of org.olat.core.gui.components.tree.TreeNode 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());
}
}
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
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);
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class TreeHelper method findNodeByResourceableUserObject.
public static TreeNode findNodeByResourceableUserObject(OLATResourceable userObject, TreeNode node) {
if (node.getUserObject() instanceof OLATResourceable && OresHelper.equals((OLATResourceable) node.getUserObject(), userObject)) {
return node;
}
int childcnt = node.getChildCount();
for (int i = 0; i < childcnt; i++) {
TreeNode child = (TreeNode) node.getChildAt(i);
TreeNode result = findNodeByUserObject(userObject, child);
if (result != null)
return result;
}
return null;
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class TreeHelper method getTreePath.
public static List<TreeNode> getTreePath(TreeNode node) {
List<TreeNode> conPath = new ArrayList<TreeNode>();
for (TreeNode cur = node; cur != null; cur = (TreeNode) cur.getParent()) {
conPath.add(cur);
}
Collections.reverse(conPath);
return conPath;
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class TreeHelper method findNodeByUserObject.
/**
* Depth-first traversal.
* @param nodeId
* @param node the root node to start the search with
* @return the first treenode with the given user object or null if not found
*/
public static TreeNode findNodeByUserObject(Object userObject, TreeNode node) {
if (node.getUserObject() != null && node.getUserObject().equals(userObject)) {
return node;
}
int childcnt = node.getChildCount();
for (int i = 0; i < childcnt; i++) {
TreeNode child = (TreeNode) node.getChildAt(i);
TreeNode result = findNodeByUserObject(userObject, child);
if (result != null)
return result;
}
return null;
}
Aggregations