/* private DefaultMutableTreeNode newTreeNode(VDC vdc) { String id = "vdc_" + vdc.getId().toString(); String styleClass = "vdcTreeDataverse"; String url = null; if (vdcUrl != null) { url = "/dv/" + vdc.getAlias() + vdcUrl; } ImageComponent image = new ImageComponent(); if (vdc.isRestricted()) { image.setUrl("/resources/images/icon_lock.gif"); image.setAlt("Restricted Dataverse"); } else { image.setUrl("/resources/images/icon_dataverse.gif"); image.setAlt("Dataverse"); } return newTreeNode(id, vdc.getName(), url, image, styleClass); } */ private DefaultMutableTreeNode newTreeNode(VDCCollection coll, VDC vdc) { String url = null; if (collectionUrl != null) { url = appendParameterToUrl( "/dvn/dv/" + vdc.getAlias() + collectionUrl, "collectionId=" + coll.getId()); } return newTreeNode(coll.getName(), url, true); }
private Boolean addCollectionNode( DefaultMutableTreeNode parentNode, VDCCollection c, VDC vdc, boolean alwaysInclude) { boolean includeFlag = alwaysInclude; boolean expandFlag = expandAll; int studyCount = 0; DefaultMutableTreeNode collectionNode = newTreeNode(c, vdc); CollectionUI collUI = new CollectionUI(c); Collection subCollections = collUI.getSubCollections(); for (Iterator it = subCollections.iterator(); it.hasNext(); ) { getNodeObject(collectionNode).setLeaf(false); VDCCollection subColl = (VDCCollection) it.next(); Boolean expanded = addCollectionNode(collectionNode, subColl, vdc, false); if (expanded != null) { includeFlag = true; expandFlag = expanded ? true : expandFlag; } } // check if collection should be included (and determine count) if (studyFilter == null) { includeFlag = true; } else { Iterator studyIter = studyFilter.iterator(); while (studyIter.hasNext()) { Study study = (Study) studyIter.next(); if (isStudyInCollection(study, c, true)) { studyCount++; } } if (studyCount > 0) { includeFlag = true; } } if (includeFlag) { if (c.getId().equals(collectionToBeExpanded)) { expandFlag = true; } // get studies, if need be if (includeStudies) { Iterator studyIter = collUI.getStudies().iterator(); while (studyIter.hasNext()) { Study s = (Study) studyIter.next(); if (studyFilter == null || StudyUI.isStudyInList(s, studyFilter)) { DefaultMutableTreeNode studyNode = newTreeNode(s, vdc); getNodeObject(collectionNode).setLeaf(false); collectionNode.add(studyNode); } } } if (includeCount && studyFilter != null) { getNodeObject(collectionNode) .setText(getNodeObject(collectionNode).getText() + " (" + studyCount + ")"); } getNodeObject(collectionNode).setExpanded(expandFlag); parentNode.add(collectionNode); return expandFlag; } else { // this collection is not included return null; } }