Improve files UI
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui / src / org / argeo / eclipse / ui / fs / FsTableViewer.java
index 47258f718df314c5d02e4e4638046cd4a0ef490e..3b126e90bcdcc33dcc1b380e22f228f76a31ceb4 100644 (file)
@@ -1,6 +1,5 @@
 package org.argeo.eclipse.ui.fs;
 
-import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.List;
 
@@ -28,6 +27,8 @@ public class FsTableViewer extends TableViewer {
        private boolean reverseOrder = false;
        private String orderProperty = FsUiConstants.PROPERTY_NAME;
 
+       private Path initialPath = null;
+
        public FsTableViewer(Composite parent, int style) {
                super(parent, style | SWT.VIRTUAL);
        }
@@ -78,10 +79,18 @@ public class FsTableViewer extends TableViewer {
                        this.setItemCount(0);
                        return;
                }
-               boolean isRoot = dir.getRoot().equals(dir);
+               boolean isRoot;
+               try {
+                       isRoot = dir.getRoot().equals(dir);
+               } catch (Exception e) {
+                       // FIXME Workaround for JCR root node access
+                       isRoot = dir.toString().equals("/");
+               }
                final Object[] res;
                if (isRoot)
                        res = rows;
+               else if (initialPath != null && initialPath.equals(dir))
+                       res = rows;
                else {
                        res = new Object[rows.length + 1];
                        res[0] = new ParentDir(dir.getParent());
@@ -102,6 +111,14 @@ public class FsTableViewer extends TableViewer {
                this.refresh();
        }
 
+       /**
+        * A path which is to be considered as root (and thus provide no link to a
+        * parent directory)
+        */
+       public void setInitialPath(Path initialPath) {
+               this.initialPath = initialPath;
+       }
+
        private class MyLazyCP implements ILazyContentProvider {
                private static final long serialVersionUID = 9096550041395433128L;
                private Object[] elements;