de.enough.polish.io.file
Class UiFileSystemTreeModel

java.lang.Object
  extended by de.enough.polish.io.file.FileSystemTreeModel
      extended by de.enough.polish.io.file.UiFileSystemTreeModel
All Implemented Interfaces:
TreeModel

public class UiFileSystemTreeModel
extends FileSystemTreeModel

Provides the file system of a device as a TreeModel.

Author:
Robert Virkus
See Also:
TreeModel, TreeItem, FileSystemTreeModel

Field Summary
protected  ItemCreator itemCreator
           
 
Constructor Summary
UiFileSystemTreeModel()
           
 
Method Summary
 void addChildren(Object parent, ArrayList list)
          Returns the number of children of parent.
protected  void addCommands(FileSystemNode node, Item item)
          Adds commands to this item.
protected  Style getStyle(FileSystemNode node)
          Selects a style for the given node.
 boolean isLeaf(Object node)
          Returns true if node is a leaf.
 void setItemCreator(ItemCreator itemCreator)
          Registers an ItemCreator which creates items for FileSystemNodes.
 
Methods inherited from class de.enough.polish.io.file.FileSystemTreeModel
getRoot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemCreator

protected ItemCreator itemCreator
Constructor Detail

UiFileSystemTreeModel

public UiFileSystemTreeModel()
Method Detail

isLeaf

public boolean isLeaf(Object node)
Description copied from interface: TreeModel
Returns true if node is a leaf. It is possible for this method to return false even if node has no children. A directory in a filesystem, for example, may contain no files; the node representing the directory is not a leaf, but it also has no children.

Specified by:
isLeaf in interface TreeModel
Overrides:
isLeaf in class FileSystemTreeModel
Parameters:
node - a node in the tree, obtained from this TreeModel
Returns:
true if the node is a leaf

addChildren

public void addChildren(Object parent,
                        ArrayList list)
Description copied from interface: TreeModel
Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this TreeModel.

Specified by:
addChildren in interface TreeModel
Overrides:
addChildren in class FileSystemTreeModel
Parameters:
parent - a node in the tree, obtained from this TreeModel
list - the ArrayList into which the children should be added

addCommands

protected void addCommands(FileSystemNode node,
                           Item item)
Adds commands to this item. The default implementation does not add any commands.

Parameters:
node - the file system node
item - the corresponding item.

getStyle

protected Style getStyle(FileSystemNode node)
Selects a style for the given node. This method is not called when an ItemCreator has been registered. The default implementation uses the .directory style for directories and .file for files.

Parameters:
node - the file system node that includes the path (name and suffix)
Returns:
a style for that node, null when no style should be applied
See Also:
setItemCreator(ItemCreator)

setItemCreator

public void setItemCreator(ItemCreator itemCreator)
Registers an ItemCreator which creates items for FileSystemNodes. Note that you can implement your own complex style handling, register your specific commands and ItemCommandListener, etc within the ItemCreator.createItem(FileSystemNode) method.

Parameters:
itemCreator - the ItemCreator that should be used, use null to de-register.