List of usage examples for org.apache.commons.vfs2 FileObject equals
public boolean equals(Object obj)
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModel.java
public TreePath getTreePathForSelection(FileObject selectedFolder, final String selection) throws FileSystemException { if (root.getRoot() == null) { return null; }/*from w ww . j a v a 2 s .com*/ if (root.getRoot().equals(selectedFolder)) { return new TreePath(root); } final LinkedList<Object> list = new LinkedList<Object>(); while (selectedFolder != null) { list.add(0, selectedFolder); final FileObject parent = selectedFolder.getParent(); if (selectedFolder.equals(parent)) { break; } if (root.getRoot().equals(parent)) { break; } selectedFolder = parent; } list.add(0, root); return new TreePath(list.toArray()); }
From source file:org.pentaho.vfs.ui.VfsBrowser.java
public void selectTreeItemByFileObject(FileObject selectedFileObject, boolean expandSelection) throws FileSystemException { // note that this method WILL cause the tree to load files from VFS // go through selectedFileObject's parent elements until we hit the root if (selectedFileObject == null) { return;/*w ww .ja v a 2s .c o m*/ } List selectedFileObjectParentList = new ArrayList(); selectedFileObjectParentList.add(selectedFileObject); FileObject parent = selectedFileObject.getParent(); while (parent != null && !parent.equals(rootFileObject)) { selectedFileObjectParentList.add(parent); parent = parent.getParent(); } if (fileSystemTree.getSelection().length > 0) { TreeItem treeItem = fileSystemTree.getSelection()[0]; treeItem.setExpanded(true); fileSystemTree.setSelection(treeItem); setSelectedFileObject(selectedFileObject); for (int i = selectedFileObjectParentList.size() - 1; i >= 0; i--) { FileObject obj = (FileObject) selectedFileObjectParentList.get(i); treeItem = findTreeItemByName(treeItem, obj.getName().getBaseName()); if (treeItem != null && !treeItem.isDisposed()) { if (treeItem.getData() == null || treeItem.getData("isLoaded") == null //$NON-NLS-1$ || !((Boolean) treeItem.getData("isLoaded")).booleanValue()) { //$NON-NLS-1$ treeItem.removeAll(); populateFileSystemTree(obj, fileSystemTree, treeItem); } } if (treeItem != null && !treeItem.isDisposed()) { fileSystemTree.setSelection(treeItem); treeItem.setExpanded(expandSelection); } } } }
From source file:pl.otros.vfs.browser.util.VFSUtils.java
/** * Returns whether a folder contains a given file * * @param folder A folder//from w ww . ja v a2 s .c om * @param file A file * @return whether a folder contains a given file */ public static boolean isParent(FileObject folder, FileObject file) { try { FileObject parent = file.getParent(); return parent != null && parent.equals(folder); } catch (FileSystemException ex) { return false; } }