Class FileTreeModel
java.lang.Object
com.codename1.components.FileTreeModel
- All Implemented Interfaces:
TreeModel
A tree model representing the file system as a whole, notice that this class returns absolute
file names which would result in an unreadable tree. To fix this you can create a Tree object
and override functionality such as the childToDisplayLabel method like this:
Tree fileTree = new Tree(new FileTreeModel(true)) { protected String childToDisplayLabel(Object child) { if (((String) child).endsWith("/")) { return ((String) child).substring(((String) child).lastIndexOf('/', ((String) child).length() - 2)); } return ((String) child).substring(((String) child).lastIndexOf('/')); } };-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtensionFilter(String extension) Shows only files with the given extensiongetChildren(java.lang.Object parent) Returns the child objects representing the given parent, null should return the root objectsbooleanisLeaf(java.lang.Object node) Is the node a leaf or a folderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
FileTreeModel
public FileTreeModel(boolean showFiles) Construct a filesystem tree model
Parameters
showFiles: indicates whether this is a directory only view or a whole filesystem view
-
-
Method Details
-
addExtensionFilter
Shows only files with the given extension
Parameters
extension: the file extension to display
-
getChildren
Returns the child objects representing the given parent, null should return the root objects
Parameters
parent: @param parent the parent object whose children should be returned, null would return the tree roots
Returns
the children of the given node within the tree
- Specified by:
getChildrenin interfaceTreeModel
-
isLeaf
-