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(Object parent) Returns the child objects representing the given parent, null should return the root objectsbooleanIs the node a leaf or a folderMethods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
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
-