use of org.zkoss.zul.DefaultTreeModel in project jochre by urieli.
the class DocumentController method getDocumentTree.
public TreeModel<TreeNode<DocOrImage>> getDocumentTree() {
LOG.debug("getDocumentTree2");
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
List<JochreDocument> docs = documentDao.findDocuments();
List<TreeNode<DocOrImage>> docNodeList = new ArrayList<>();
for (JochreDocument doc : docs) {
List<TreeNode<DocOrImage>> imageNodeList = new ArrayList<>();
for (JochrePage page : doc.getPages()) {
LOG.debug("page " + page.getIndex());
for (JochreImage image : page.getImages()) {
DefaultTreeNode<DocOrImage> imageNode = new DefaultTreeNode<DocumentController.DocOrImage>(new DocOrImage(image));
imageNodeList.add(imageNode);
if (imageId == image.getId())
currentImage = image;
}
// have images?
}
boolean open = docId == doc.getId();
if (open)
currentDoc = doc;
DefaultTreeNode<DocOrImage> docNode = new DirectoryTreeNode<DocumentController.DocOrImage>(new DocOrImage(doc), imageNodeList, open);
docNodeList.add(docNode);
}
DefaultTreeNode<DocOrImage> root = new DefaultTreeNode<DocumentController.DocOrImage>(null, docNodeList);
TreeModel<TreeNode<DocOrImage>> docTree = new DefaultTreeModel<>(root);
this.reloadDoc();
this.reloadImage();
return docTree;
}
Aggregations