FileSystemContainer with multiple roots and TreeTable


I am trying to use FileSystemContainer in conjunction with TreeTable.
I am adding multiple roots to the FileSystemContainer. In my case I am enumerating the drives on the PC with FileSystemView. e.g. C:// and D://

When I attach the FileSystemContainer to a TreeTable, I see blank lines at the top level. Once you expand them - every looks fine. If I use only one root (so the root is not displayed) everything looks fine.

I found the reason for this, and I think its a bug…

Once you dig deep under the covers you get to a class called FileItem inside Its what is ultimately used to map the file system to Item inside the table.

Inside that class there is a File object pointing to the actual File. There is also a function called getName(). FileItem.getName is a straight call to File.getName() which in turn returns everything after the last file system separator (e.g. '') as the name of the file. This works great for most files. Except for things like 'C:' and 'D:'. In those cases we get an empty String “”. When you bind to a Table - you get an empty cell. And I don’t know how to override that… (any solutions would be great).

Since empty file names don’t make any sense anyway, I would suggest that FileItem.getName() be chaged to read as something like

public String getName() {
String name = file.getName();
if (name == “”) {
name = file.getPath();
return name;


In the mean time I added a generated column which has the behavior I wanted. Not ideal by any means for efficiency reasons. But at least it works…

(availableDirectories is a TreeTable bound to a FilesystemContainer that has c:\ and d:\ set as roots with addRoot() )

[font=courier new]
availableDirectories.addGeneratedColumn(“File”, new TreeTable.ColumnGenerator() {
public Object generateCell(Table source, Object itemId, Object columnId) {
String fileName;

            fileName = itemId.toString();
            int index = fileName.lastIndexOf(File.separatorChar);
            if( index == ( fileName.length() - 1 ) ) {
                return fileName;
            } else {
                return fileName.substring( index + 1 );