Search in sources :

Example 1 with DefaultTreeModel

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;
}
Also used : JochreImage(com.joliciel.jochre.graphics.JochreImage) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) ArrayList(java.util.ArrayList) DocumentDao(com.joliciel.jochre.doc.DocumentDao) JochreDocument(com.joliciel.jochre.doc.JochreDocument) DefaultTreeModel(org.zkoss.zul.DefaultTreeModel) JochrePage(com.joliciel.jochre.doc.JochrePage) TreeNode(org.zkoss.zul.TreeNode) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode)

Aggregations

DocumentDao (com.joliciel.jochre.doc.DocumentDao)1 JochreDocument (com.joliciel.jochre.doc.JochreDocument)1 JochrePage (com.joliciel.jochre.doc.JochrePage)1 JochreImage (com.joliciel.jochre.graphics.JochreImage)1 ArrayList (java.util.ArrayList)1 DefaultTreeModel (org.zkoss.zul.DefaultTreeModel)1 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)1 TreeNode (org.zkoss.zul.TreeNode)1