use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class CPOfflineReadableManager method writeOfflineCPStartHTMLFile.
/**
* generates a html-file (_START_.html) that presents the given cp-content
* (specified by its "_unzipped_"-dir). The resulting file is suitable for
* offline reading of the cp.
*
* @param unzippedDir
* the directory that contains the unzipped CP
*/
private void writeOfflineCPStartHTMLFile(File unzippedDir) throws IOException {
/* first, we do the menu-tree */
File mani = new File(unzippedDir, FILENAME_IMSMANIFEST);
LocalFileImpl vfsMani = new LocalFileImpl(mani);
CPManifestTreeModel ctm = new CPManifestTreeModel(vfsMani, "");
TreeNode root = ctm.getRootNode();
// let's take the rootnode title as page title
this.rootTitle = root.getTitle();
StringBuilder menuTreeSB = new StringBuilder();
renderMenuTreeNodeRecursively(root, menuTreeSB, 0);
// now put values to velocityContext
VelocityContext ctx = new VelocityContext();
ctx.put("menutree", menuTreeSB.toString());
ctx.put("rootTitle", this.rootTitle);
ctx.put("cpoff", DIRNAME_CPOFFLINEMENUMAT);
StringWriter sw = new StringWriter();
try {
String template = FileUtils.load(CPOfflineReadableManager.class.getResourceAsStream("_content/cpofflinereadable.html"), "utf-8");
boolean evalResult = velocityEngine.evaluate(ctx, sw, "cpexport", template);
if (!evalResult)
log.error("Could not evaluate velocity template for CP Export");
} catch (Exception e) {
log.error("Error while evaluating velovity template for CP Export", e);
}
File f = new File(unzippedDir, FILENAME_START);
if (f.exists()) {
FileUtils.deleteDirsAndFiles(f, false, true);
}
ExportUtil.writeContentToFile(FILENAME_START, sw.toString(), unzippedDir, "utf-8");
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class CPDisplayController 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 == cpTree) {
// TreeEvent.dito...
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
TreeEvent te = (TreeEvent) event;
switchToPage(ureq, te);
}
} else if (source == cpComponent) {
if (event instanceof NewInlineUriEvent) {
NewInlineUriEvent nue = (NewInlineUriEvent) event;
// adjust the tree selection to the current choice if found
selectTreeNode(ureq, nue.getNewUri());
}
} else if (source == nextLink) {
TreeNode nextUri = (TreeNode) nextLink.getUserObject();
switchToPage(ureq, nextUri);
if (cpTree != null) {
cpTree.setSelectedNode(nextUri);
}
fireEvent(ureq, new TreeNodeEvent(nextUri));
} else if (source == previousLink) {
TreeNode previousUri = (TreeNode) previousLink.getUserObject();
if (cpTree != null) {
cpTree.setSelectedNode(previousUri);
}
switchToPage(ureq, previousUri);
fireEvent(ureq, new TreeNodeEvent(previousUri));
} else if (source == printLink) {
selectPagesToPrint(ureq);
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class DocumentPoolMainController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty()) {
if (taxonomyTree.getTreeModel().getRootNode().getChildCount() > 0) {
doSelectTaxonomy(ureq);
}
} else {
String resourceName = entries.get(0).getOLATResourceable().getResourceableTypeName();
if ("Templates".equals(resourceName) || resourceName.startsWith("path=")) {
TreeNode rootNode = taxonomyTree.getTreeModel().getRootNode();
if (rootNode.getChildCount() > 0) {
TaxonomyTreeNode node = (TaxonomyTreeNode) rootNode.getChildAt(0);
if (node.getType() == TaxonomyTreeNodeType.templates) {
DocumentDirectoryController directoryCtrl = doSelectTemplatesDirectory(ureq, node);
if (directoryCtrl != null) {
taxonomyTree.setSelectedNode(node);
List<ContextEntry> subEntries = entries.subList(1, entries.size());
directoryCtrl.activate(ureq, subEntries, entries.get(0).getTransientState());
}
}
}
} else if ("TaxonomyLevel".equalsIgnoreCase(resourceName)) {
String levelKey = entries.get(0).getOLATResourceable().getResourceableId().toString();
TaxonomyTreeNode node = (TaxonomyTreeNode) taxonomyTree.getTreeModel().getNodeById(levelKey);
if (node != null) {
DocumentPoolLevelController levelCtrl = doSelectTaxonomyLevel(ureq, node);
if (levelCtrl != null) {
taxonomyTree.setSelectedNode(node);
List<ContextEntry> subEntries = entries.subList(1, entries.size());
levelCtrl.activate(ureq, subEntries, entries.get(0).getTransientState());
}
}
}
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class DocumentPoolMainController method doSelectTaxonomyLevel.
private DocumentPoolLevelController doSelectTaxonomyLevel(UserRequest ureq, TaxonomyTreeNode node) {
if (isTaxonomyAdmin || node.isCanRead() || node.isCanWrite()) {
TaxonomyLevel level = node.getTaxonomyLevel();
SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(node, subscriptionCtx);
OLATResourceable ores = OresHelper.createOLATResourceableInstance("TaxonomyLevel", node.getTaxonomyLevel().getKey());
WindowControl bwControl = addToHistory(ureq, ores, null);
DocumentPoolLevelController levelCtrl = new DocumentPoolLevelController(ureq, bwControl, level, node, secCallback);
listenTo(levelCtrl);
String displayName = level.getDisplayName();
content.popUpToRootController(ureq);
List<TreeNode> parentLines = TreeHelper.getTreePath(node);
for (int i = 1; i < parentLines.size() - 1; i++) {
TreeNode parent = parentLines.get(i);
content.pushController(parent.getTitle(), null, parent);
}
content.pushController(displayName, levelCtrl);
return levelCtrl;
}
return null;
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class QuestionPoolMainEditorController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
OLATResourceable resource = entries.get(0).getOLATResourceable();
if ("QuestionItem".equalsIgnoreCase(resource.getResourceableTypeName())) {
activateQuestionItem(ureq, resource.getResourceableId(), entries);
} else {
TreeNode rootNode = menuTree.getTreeModel().getRootNode();
TreeNode node = TreeHelper.findNodeByResourceableUserObject(resource, rootNode);
if (node == null) {
node = TreeHelper.findNodeByUserObject(resource.getResourceableTypeName(), rootNode);
}
if (node != null) {
List<ContextEntry> subEntries = entries.subList(1, entries.size());
stackPanel.popUpToRootController(ureq);
doSelectControllerTreeNode(ureq, node, subEntries, entries.get(0).getTransientState());
menuTree.setSelectedNode(node);
}
}
}
Aggregations