use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class EPCollectStepForm04 method initForm.
/**
* @see org.olat.core.gui.control.generic.wizard.StepFormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
List<PortfolioStructure> structs = ePFMgr.getStructureElementsForUser(getIdentity());
if (structs != null && structs.size() != 0) {
TreeModel treeModel = new MapsTreeModel(getIdentity(), getTranslator());
mapsTreeController = new MenuTree("my.maps");
mapsTreeController.setTreeModel(treeModel);
mapsTreeController.setSelectedNode(treeModel.getRootNode());
mapsTreeController.setDragEnabled(false);
mapsTreeController.setDropEnabled(false);
mapsTreeController.setDropSiblingEnabled(false);
mapsTreeController.addListener(this);
mapsTreeController.setRootVisible(true);
if (preSelectedStructure != null) {
TreeNode node = TreeHelper.findNodeByUserObject(preSelectedStructure, treeModel.getRootNode());
if (node != null) {
mapsTreeController.setSelectedNode(node);
}
}
flc.put("treeCtr", mapsTreeController);
}
if (!isUsedInStepWizzard()) {
// add form buttons
uifactory.addFormSubmitButton("stepform.submit", formLayout);
}
}
use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class SelectionTreeComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
SelectionTreeComponent stc = (SelectionTreeComponent) source;
Map<String, CheckboxElement> checkboxes = stc.getSubComponents();
TreeModel tm = stc.getTreeModel();
TreeNode rootNode = tm.getRootNode();
if (rootNode.getChildCount() == 1) {
rootNode = (TreeNode) rootNode.getChildAt(0);
}
INodeFilter selectableFilter = stc.getSelectableFilter();
sb.append("<div class='o_selection_tree'><ul class='o_selection_tree_l0'>");
renderNode(rootNode, rootNode, 0, stc.hashCode(), sb, renderer, stc, checkboxes, selectableFilter, args);
sb.append("</ul></div>");
}
use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class WikiRunController method createNodeRunConstructionResult.
public NodeRunConstructionResult createNodeRunConstructionResult() {
TreeModel wikiTreeModel = wikiCtr.getAndUseExternalTree();
String selNodeId = wikiTreeModel.getRootNode().getChildAt(0).getIdent();
return new NodeRunConstructionResult(this, wikiTreeModel, selNodeId, wikiCtr);
}
use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class DocumentPoolNotificationsHandler method createSubscriptionInfo.
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
try {
SubscriptionInfo si;
String taxonomyKey = documentPoolModule.getTaxonomyTreeKey();
if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews) && StringHelper.isLong(taxonomyKey)) {
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(taxonomyKey)));
if (taxonomy == null) {
return notificationsManager.getNoSubscriptionInfo();
}
Identity identity = subscriber.getIdentity();
Roles roles = securityManager.getRoles(identity);
boolean isTaxonomyAdmin = roles.isOLATAdmin();
Translator translator = Util.createPackageTranslator(DocumentPoolMainController.class, locale);
String templates = translator.translate("document.pool.templates");
TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(taxonomy, identity, null, isTaxonomyAdmin, documentPoolModule.isTemplatesDirectoryEnabled(), templates, locale);
TreeModel model = builder.buildTreeModel();
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), getTitleItemForPublisher(), null);
new TreeVisitor(node -> {
TaxonomyTreeNode tNode = (TaxonomyTreeNode) node;
if (tNode.getTaxonomyLevel() != null && tNode.isDocumentsLibraryEnabled() && tNode.isCanRead()) {
VFSContainer container = taxonomyService.getDocumentsLibrary(tNode.getTaxonomyLevel());
String prefixBusinessPath = "[DocumentPool:" + taxonomy.getKey() + "][TaxonomyLevel:" + tNode.getTaxonomyLevel().getKey() + "][path=";
createSubscriptionInfo(container, prefixBusinessPath, compareDate, si, p, translator);
} else if (tNode.getType() == TaxonomyTreeNodeType.templates) {
VFSContainer container = taxonomyService.getDocumentsLibrary(taxonomy);
String prefixBusinessPath = "[DocumentPool:" + taxonomy.getKey() + "][Templates:0s][path=";
createSubscriptionInfo(container, prefixBusinessPath, compareDate, si, p, translator);
}
}, model.getRootNode(), false).visitAll();
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
} catch (Exception e) {
log.error("Cannot create document pool notifications for subscriber: " + subscriber.getKey(), e);
return notificationsManager.getNoSubscriptionInfo();
}
}
use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class DocumentPoolWebDAVMergeSource method loadMergedContainers.
@Override
protected List<VFSContainer> loadMergedContainers() {
List<VFSContainer> containers = new ArrayList<>();
String taxonomyTreeKey = docPoolModule.getTaxonomyTreeKey();
if (StringHelper.isLong(taxonomyTreeKey)) {
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(taxonomyTreeKey)));
if (taxonomy != null) {
String templatesDir = Util.createPackageTranslator(DocumentPoolMainController.class, identityEnv.getLocale()).translate("document.pool.templates");
TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(taxonomy, identityEnv.getIdentity(), null, identityEnv.getRoles().isOLATAdmin(), docPoolModule.isTemplatesDirectoryEnabled(), templatesDir, null);
TreeModel model = builder.buildTreeModel();
TreeNode rootNode = model.getRootNode();
for (int i = 0; i < rootNode.getChildCount(); i++) {
VFSContainer container = loadRecursiveMergedContainers(taxonomy, rootNode.getChildAt(i));
if (container != null) {
containers.add(container);
}
}
}
}
return containers;
}
Aggregations