use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class ScormAPIandDisplayController method switchToPage.
/**
* @param te is an Event fired by clicking a node in a tree
*/
public void switchToPage(TreeEvent te) {
// switch to the new page
String nodeId = te.getNodeId();
GenericTreeNode tn = (GenericTreeNode) treeModel.getNodeById(nodeId);
if (te.getCommand().equals(MenuTree.COMMAND_TREENODE_EXPANDED)) {
iframectr.getInitialComponent().setVisible(false);
// update the view
myContent.setDirty(true);
} else {
iframectr.getInitialComponent().setVisible(true);
String scormId = String.valueOf(treeModel.lookupScormNodeId(tn));
updateNextPreviousButtons(scormId);
displayMessages(scormId, (String) tn.getUserObject());
}
updateMenuTreeIconsAndMessages();
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class ScormCPManifestTreeModel method buildNode.
private GenericTreeNode buildNode(Element item) {
GenericTreeNode treeNode = new GenericTreeNode();
// extract title
String title = item.elementText("title");
if (title == null)
title = item.attributeValue("identifier");
treeNode.setAltText(title);
treeNode.setTitle(title);
if (item.getName().equals("organization")) {
treeNode.setIconCssClass("o_scorm_org");
treeNode.setAccessible(false);
} else if (item.getName().equals("item")) {
scormIdToNode.put(new Integer(nodeId).toString(), treeNode);
nodeToId.put(treeNode, new Integer(nodeId));
// set node images according to scorm sco status
String itemStatusDesc = itemStatus.get(Integer.toString(nodeId));
treeNode.setIconCssClass("o_scorm_item");
if (itemStatusDesc != null && !"not_attempted".equals(itemStatusDesc)) {
// add icon decorator for current status
String decorator = "o_scorm_" + itemStatusDesc;
treeNode.setIconDecorator1CssClass(decorator);
}
nodeId++;
// set resolved file path directly
String identifierref = item.attributeValue("identifierref");
XPath meta = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
meta.setNamespaceURIs(nsuris);
String href = resources.get(identifierref);
if (href != null) {
treeNode.setUserObject(href);
// allow lookup of a treenode given a href so we can quickly adjust the menu if the user clicks on hyperlinks within the text
hrefToTreeNode.put(href, treeNode);
} else
treeNode.setAccessible(false);
}
List<Element> chds = item.elements("item");
int childcnt = chds.size();
for (int i = 0; i < childcnt; i++) {
Element childitem = chds.get(i);
GenericTreeNode gtnchild = buildNode(childitem);
treeNode.addChild(gtnchild);
}
return treeNode;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class ScormCPManifestTreeModel method buildTreeNodes.
private GenericTreeNode buildTreeNodes(List<Element> organizations) {
GenericTreeNode gtn = new GenericTreeNode();
// 0 is a valid index since List is testet be be not empty above
String rootNode = organizations.get(0).getParent().elementText("default");
// if only one organization avoid too much hierarchy levels...
if (organizations.size() == 1) {
return buildNode(organizations.get(0));
}
// FIXME: localize "Content:"
gtn.setTitle((rootNode == null) ? "Content:" : rootNode);
gtn.setIconCssClass("o_scorm_org");
gtn.setAccessible(false);
for (int i = 0; i < organizations.size(); ++i) {
GenericTreeNode gtnchild = buildNode(organizations.get(i));
gtn.addChild(gtnchild);
}
return gtn;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class WikiMainController method getAndUseExternalTree.
public GenericTreeModel getAndUseExternalTree() {
final String resId = ores.getResourceableId().toString();
Wiki wiki = getWiki();
wikiMenuModel = new GenericTreeModel();
String root = "wiki-" + resId;
GenericTreeNode rootNode = new GenericTreeNode(root);
wikiMenuModel.setRootNode(rootNode);
// Index
String navMainItem = "nav-main-item-" + resId;
navMainPageNode = new GenericTreeNode(navMainItem, translate("navigation.mainpage"), navMainItem);
rootNode.addChild(navMainPageNode);
// Wiki-Menu
String wikiMenuTitle = translate("navigation.menu");
String wikiMenuItem = "menu-item-" + resId;
wikiMenuNode = new GenericTreeNode(wikiMenuItem, wikiMenuTitle, wikiMenuItem);
rootNode.addChild(wikiMenuNode);
String navAZItem = "nav-az-item-" + resId;
navAZNode = new GenericTreeNode(navAZItem, translate("navigation.a-z"), navAZItem);
rootNode.addChild(navAZNode);
String navChangesItem = "nav-changes-item-" + resId;
navChangesNode = new GenericTreeNode(navChangesItem, translate("navigation.changes"), navChangesItem);
rootNode.addChild(navChangesNode);
updateWikiMenu(wiki);
navigationDropdown.setVisible(false);
wikiMenuDropdown.setVisible(false);
navigationContent.contextPut("navigationEnabled", Boolean.FALSE);
return wikiMenuModel;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class EPTOCController method reloadTreeModel.
private void reloadTreeModel(PortfolioStructure struct) {
EPTOCTreeModel model = (EPTOCTreeModel) treeCtr.getTreeModel();
if (struct != null) {
GenericTreeNode node = (GenericTreeNode) TreeHelper.findNodeByUserObject(struct, model.getRootNode());
if (node != null) {
node.setTitle(struct.getTitle());
node.setUserObject(struct);
model.loadChildNode(struct, node);
}
}
}
Aggregations