@Override
public String getText(Object element) {
- Path path = (Path) element;
try {
+ if (element instanceof ParentDir) {
+ switch (propName) {
+ case FsUiConstants.PROPERTY_SIZE:
+ return "-";
+ case FsUiConstants.PROPERTY_LAST_MODIFIED:
+ return "-";
+ // return Files.getLastModifiedTime(((ParentDir) element).getPath()).toString();
+ case FsUiConstants.PROPERTY_TYPE:
+ return "Folder";
+ }
+ }
+
+ Path path = (Path) element;
switch (propName) {
case FsUiConstants.PROPERTY_SIZE:
- return FsUiUtils.humanReadableByteCount(Files.size(path), false);
+ if (Files.isDirectory(path))
+ return "-";
+ else
+ return FsUiUtils.humanReadableByteCount(Files.size(path), false);
case FsUiConstants.PROPERTY_LAST_MODIFIED:
return Files.getLastModifiedTime(path).toString();
case FsUiConstants.PROPERTY_TYPE:
throw new IllegalArgumentException("Unsupported property " + propName);
}
} catch (IOException ioe) {
- throw new FsUiException("Cannot get property " + propName + " on " + path.toString());
+ throw new FsUiException("Cannot get property " + propName + " on " + element);
}
}
}