Improve FS
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui / src / org / argeo / eclipse / ui / fs / NioFileLabelProvider.java
index 391f250eb70fcff5cf6c94ab2b89a6534a18a85e..d8cb1d83befd08062fb9964be3c068b9de36ca5d 100644 (file)
@@ -18,11 +18,26 @@ public class NioFileLabelProvider extends ColumnLabelProvider {
 
        @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:
@@ -39,7 +54,7 @@ public class NioFileLabelProvider extends ColumnLabelProvider {
                                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);
                }
        }
 }