From: Mathieu Baudier Date: Sat, 14 Jan 2017 11:18:37 +0000 (+0100) Subject: Can browse node file system X-Git-Tag: argeo-commons-2.1.56~9 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=17f36c3a0db9f665ae4826f1057a6249f31621b0;p=lgpl%2Fargeo-commons.git Can browse node file system --- diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/jcr/NodeFsBrowserView.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/jcr/NodeFsBrowserView.java index 68f45908b..e6ac7247a 100644 --- a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/jcr/NodeFsBrowserView.java +++ b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/jcr/NodeFsBrowserView.java @@ -15,10 +15,13 @@ */ package org.argeo.cms.ui.workbench.jcr; +import java.net.URI; +import java.nio.file.FileSystem; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.spi.FileSystemProvider; +import org.argeo.cms.CmsException; import org.argeo.cms.ui.workbench.WorkbenchUiPlugin; import org.argeo.eclipse.ui.EclipseUiUtils; import org.argeo.eclipse.ui.fs.SimpleFsBrowser; @@ -31,15 +34,26 @@ import org.eclipse.ui.part.ViewPart; */ public class NodeFsBrowserView extends ViewPart { public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".nodeFsBrowserView"; - + private FileSystemProvider nodeFileSystemProvider; @Override public void createPartControl(Composite parent) { - SimpleFsBrowser browser = new SimpleFsBrowser(parent, SWT.NO_FOCUS); - Path path = Paths.get("/"); - browser.setInput(path); - browser.setLayoutData(EclipseUiUtils.fillAll()); + try { + URI uri = new URI("node:///home"); + FileSystem fileSystem = nodeFileSystemProvider.getFileSystem(uri); + if(fileSystem==null) + fileSystem = nodeFileSystemProvider.newFileSystem(uri,null); + Path nodePath = fileSystem.getPath("/home"); +// Path nodePath = Paths.get(uri); + + Path path = Paths.get("/"); + SimpleFsBrowser browser = new SimpleFsBrowser(parent, SWT.NO_FOCUS); + browser.setInput(path, nodePath); + browser.setLayoutData(EclipseUiUtils.fillAll()); + } catch (Exception e) { + throw new CmsException("Cannot open file system browser", e); + } } @Override diff --git a/org.argeo.jcr/src/org/argeo/jcr/fs/JcrBasicfileAttributes.java b/org.argeo.jcr/src/org/argeo/jcr/fs/JcrBasicfileAttributes.java index e59abbc70..7ce9ca667 100644 --- a/org.argeo.jcr/src/org/argeo/jcr/fs/JcrBasicfileAttributes.java +++ b/org.argeo.jcr/src/org/argeo/jcr/fs/JcrBasicfileAttributes.java @@ -63,7 +63,10 @@ public class JcrBasicfileAttributes implements NodeFileAttributes { @Override public boolean isDirectory() { try { - return node.isNodeType(NodeType.NT_FOLDER); + if (node.isNodeType(NodeType.NT_FOLDER)) + return true; + // all other non file nodes + return !(node.isNodeType(NodeType.NT_FILE) || node.isNodeType(NodeType.NT_LINKED_FILE)); } catch (RepositoryException e) { throw new JcrFsException("Cannot check if directory", e); } @@ -88,7 +91,7 @@ public class JcrBasicfileAttributes implements NodeFileAttributes { if (isRegularFile()) { Binary binary = null; try { - binary = node.getNode(Property.JCR_DATA).getProperty(Property.JCR_CONTENT).getBinary(); + binary = node.getNode(Property.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary(); return binary.getSize(); } catch (RepositoryException e) { throw new JcrFsException("Cannot check size", e);