use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class CatalogTreeModel method addNode.
/**
* Create and add a node to the tree
* @param entry
* @return
*/
private GenericTreeNode addNode(CatalogEntry entry) {
GenericTreeNode node = entryMap.get(entry.getKey());
if (node == null && entry.getType() == CatalogEntry.TYPE_NODE) {
if (entry.getParent() != null) {
node = entryMap.get(entry.getParent().getKey());
if (node != null) {
GenericTreeNode build = buildNode(entry);
node.addChild(build);
build.setParent(node);
} else {
addMissingNodes(entry);
}
} else {
// it's the root
node = buildNode(entry);
}
}
return node;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class CatalogTreeModel method addMissingNodes.
/**
* Create the parent and child nodes that are not yet in the entry map
*
* @param fault
*/
private void addMissingNodes(CatalogEntry fault) {
GenericTreeNode branch = null;
GenericTreeNode helper = null;
while (fault != null) {
if (entryMap.get(fault.getKey()) == null) {
GenericTreeNode build = buildNode(fault);
if (// in case of catalog root
fault.getParent() != null)
branch = entryMap.get(fault.getParent().getKey());
if (helper != null) {
helper.setParent(build);
build.addChild(helper);
}
if (branch != null) {
build.setParent(branch);
branch.addChild(build);
return;
}
helper = build;
}
fault = fault.getParent();
}
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class MoveTaxonomyLevelController method filterByAllowedTypes.
private boolean filterByAllowedTypes(TreeNode node, List<TreeNode> openedNodes) {
((GenericTreeNode) node).setIconCssClass(null);
for (int i = node.getChildCount(); i-- > 0; ) {
boolean ok = filterByAllowedTypes((TreeNode) node.getChildAt(i), openedNodes);
if (!ok) {
node.remove(node.getChildAt(i));
}
}
boolean ok = false;
Object uobject = node.getUserObject();
if (uobject instanceof TaxonomyLevel) {
TaxonomyLevel level = (TaxonomyLevel) uobject;
TaxonomyLevelType type = level.getType();
if (type == null || allowedTypes.contains(type)) {
openedNodes.add(node);
((GenericTreeNode) node).setIconCssClass("o_icon_node_under o_icon-rotate-180");
targetableNodes.add(node);
ok = true;
} else if (node.getChildCount() > 0) {
openedNodes.add(node);
ok = true;
}
} else {
targetableNodes.add(node);
openedNodes.add(node);
ok = true;
}
return ok;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
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.GenericTreeNode in project openolat by klemens.
the class TaxonomyTreeNodeComparator method compare.
@Override
public int compare(INode i1, INode i2) {
if (i1 == null || i2 == null) {
return compareNullObjects(i1, i2);
}
Integer s1 = null;
Integer s2 = null;
String title1 = null;
String title2 = null;
TaxonomyTreeNodeType type1 = null;
TaxonomyTreeNodeType type2 = null;
if (i1 instanceof TaxonomyTreeNode) {
TaxonomyTreeNode t1 = (TaxonomyTreeNode) i1;
title1 = t1.getTitle();
type1 = t1.getType();
if (t1.getTaxonomyLevel() != null) {
s1 = t1.getTaxonomyLevel().getSortOrder();
}
} else if (i1 instanceof GenericTreeNode) {
GenericTreeNode node = (GenericTreeNode) i1;
title1 = node.getTitle();
Object uobject = node.getUserObject();
if (uobject instanceof TaxonomyLevel) {
TaxonomyLevel level = (TaxonomyLevel) uobject;
type1 = TaxonomyTreeNodeType.taxonomyLevel;
s1 = level.getSortOrder();
}
}
if (i2 instanceof TaxonomyTreeNode) {
TaxonomyTreeNode t2 = (TaxonomyTreeNode) i2;
title2 = t2.getTitle();
type2 = t2.getType();
if (t2.getTaxonomyLevel() != null) {
s2 = t2.getTaxonomyLevel().getSortOrder();
}
} else if (i1 instanceof GenericTreeNode) {
GenericTreeNode node = (GenericTreeNode) i2;
title2 = node.getTitle();
Object uobject = node.getUserObject();
if (uobject instanceof TaxonomyLevel) {
TaxonomyLevel level = (TaxonomyLevel) uobject;
type2 = TaxonomyTreeNodeType.taxonomyLevel;
s2 = level.getSortOrder();
}
}
int c = 0;
if (type1 == TaxonomyTreeNodeType.templates && type2 == TaxonomyTreeNodeType.templates) {
c = 0;
} else if (type1 == TaxonomyTreeNodeType.templates) {
return -1;
} else if (type2 == TaxonomyTreeNodeType.templates) {
return 1;
}
if (type1 == TaxonomyTreeNodeType.lostAndFound && type2 == TaxonomyTreeNodeType.lostAndFound) {
c = 0;
} else if (type1 == TaxonomyTreeNodeType.lostAndFound) {
return 1;
} else if (type2 == TaxonomyTreeNodeType.lostAndFound) {
return -1;
}
if (c == 0) {
if (s1 == null || s2 == null) {
c = compareNullObjects(s1, s2);
} else {
c = s1.compareTo(s2);
}
}
if (c == 0) {
if (title1 == null || title2 == null) {
c = compareNullObjects(title1, title2);
} else {
c = title1.compareTo(title2);
}
}
return c;
}
Aggregations