use of org.alfresco.web.ui.repo.component.UITree.TreeNode in project acs-community-packaging by Alfresco.
the class CategoryBrowserPluginBean method nodeCollapsed.
/**
* Sets the state of the node given in the 'nodeRef' parameter to collapsed
*/
public void nodeCollapsed() throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
ResponseWriter out = context.getResponseWriter();
Map params = context.getExternalContext().getRequestParameterMap();
String nodeRefStr = (String) params.get("nodeRef");
// work out which list to cache the nodes in
Map<String, TreeNode> currentNodes = getNodesMap();
if (nodeRefStr != null && currentNodes != null) {
TreeNode treeNode = currentNodes.get(nodeRefStr);
if (treeNode != null) {
treeNode.setExpanded(false);
// we need to return something for the client to be happy!
out.write("<ok/>");
if (logger.isDebugEnabled())
logger.debug("Set node " + treeNode + " to collapsed state");
}
}
}
use of org.alfresco.web.ui.repo.component.UITree.TreeNode in project acs-community-packaging by Alfresco.
the class YahooTreeRenderer method generateNode.
/**
* Generates the JavaScript required to create the branch of a tree from
* the given node.
*
* @param node The node to generate
* @param out Response writer
* @param parentVarName Name of the parent variable, null if the node has no parent
*/
protected void generateNode(TreeNode node, ResponseWriter out, String parentVarName) throws IOException {
String currentVarName = getNextVarName();
// generate the Javascript to create the given node using the
// appropriate parent variable
out.write(" var ");
out.write(currentVarName);
out.write(" = createYahooTreeNode(");
if (node.getParent() == null) {
out.write("root");
} else {
out.write(parentVarName);
}
out.write(", \"");
out.write(node.getNodeRef());
out.write("\", \"");
out.write(node.getName());
out.write("\", \"");
out.write(node.getIcon());
out.write("\", ");
out.write(Boolean.toString(node.isExpanded()));
out.write(", ");
out.write(Boolean.toString(node.isSelected()));
out.write(");\n");
// iterate through the child nodes and generate them
if (node.isExpanded() && node.getChildren().size() > 0) {
// order the children
List<TreeNode> children = node.getChildren();
if (children.size() > 1) {
QuickSort sorter = new QuickSort(children, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
for (TreeNode child : children) {
generateNode(child, out, currentVarName);
}
}
}
Aggregations