RepositoryTreeNode treeNode = repositoryTreeNode.getFolders().get(folder);
if (showOnlyFolders && treeNode.getFolders().size() == 0) {
TreeItem hiddenItem = new TreeItem();
folderItem.addItem(hiddenItem);
String tooltip = folder.getDescription();
new ToolTip(label, null, tooltip);
hiddenItem.setVisible(false);
} else if (treeNode.getFiles().size() == 0 && treeNode.getFolders().size() == 0) {
TreeItem hiddenItem = new TreeItem();
folderItem.addItem(hiddenItem);
String tooltip = folder.getDescription() + " (empty)";
new ToolTip(label, null, tooltip);
hiddenItem.setVisible(false);
} else {
String tooltip = folder.getDescription();
new ToolTip(label, null, tooltip);
buildRepositoryTree(treeNode, folderItem);
}
}
if (showOnlyFolders) {
return;
}
// add files
Collections.sort(repositoryTreeNode.getFiles(), new FileAlphaComparator(sortAToZ));
for (File file : repositoryTreeNode.getFiles()) {
Label treeItemLabel = new Label(file.getName());
TreeItem fileItem = new TreeItem(treeItemLabel);
if (!showHiddenFiles && file.isHidden()) {
fileItem.setVisible(false);
}
NumberFormat formatter = NumberFormat.getFormat("#,###");
String tooltip = "";
tooltip += "Description: " + file.getDescription();
tooltip += "<BR>";
tooltip += "Type: " + file.getContentType();
tooltip += "<BR>";
tooltip += "Date Created: " + (new Date(file.getCreationDate()).toLocaleString());
tooltip += "<BR>";
tooltip += "Last Modified: " + (new Date(file.getLastModifiedDate()).toLocaleString());
tooltip += "<BR>";
tooltip += "Owner: " + file.getOwner().getUsername();
tooltip += "<BR>";
tooltip += "Size: " + formatter.format(file.getSize()) + " bytes";
String thumbnailImageURL = null;
if (file instanceof Photo) {
Photo photo = (Photo) file;
if (photo.getThumbnailImage() != null) {
thumbnailImageURL = BaseApplication.getSettings().getString("GetFileService", BaseApplication.GET_FILE_SERVICE_PATH) + photo.getThumbnailImage().getId() + "_inline_" + photo.getName();
}
}
new ToolTip(treeItemLabel, thumbnailImageURL, tooltip);
fileItem.setUserObject(file);
if (parentItem != null) {
parentItem.addItem(fileItem);
} else if (createRootItem) {
rootItem.addItem(fileItem);