]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/jcr/NodeFsBrowserView.java
Can browse node file system
[lgpl/argeo-commons.git] / org.argeo.cms.ui.workbench / src / org / argeo / cms / ui / workbench / jcr / NodeFsBrowserView.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.cms.ui.workbench.jcr;
17
18 import java.net.URI;
19 import java.nio.file.FileSystem;
20 import java.nio.file.Path;
21 import java.nio.file.Paths;
22 import java.nio.file.spi.FileSystemProvider;
23
24 import org.argeo.cms.CmsException;
25 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
26 import org.argeo.eclipse.ui.EclipseUiUtils;
27 import org.argeo.eclipse.ui.fs.SimpleFsBrowser;
28 import org.eclipse.swt.SWT;
29 import org.eclipse.swt.widgets.Composite;
30 import org.eclipse.ui.part.ViewPart;
31
32 /**
33 * Browse the node file system.
34 */
35 public class NodeFsBrowserView extends ViewPart {
36 public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".nodeFsBrowserView";
37
38 private FileSystemProvider nodeFileSystemProvider;
39
40 @Override
41 public void createPartControl(Composite parent) {
42 try {
43 URI uri = new URI("node:///home");
44 FileSystem fileSystem = nodeFileSystemProvider.getFileSystem(uri);
45 if(fileSystem==null)
46 fileSystem = nodeFileSystemProvider.newFileSystem(uri,null);
47 Path nodePath = fileSystem.getPath("/home");
48 // Path nodePath = Paths.get(uri);
49
50 Path path = Paths.get("/");
51 SimpleFsBrowser browser = new SimpleFsBrowser(parent, SWT.NO_FOCUS);
52 browser.setInput(path, nodePath);
53 browser.setLayoutData(EclipseUiUtils.fillAll());
54 } catch (Exception e) {
55 throw new CmsException("Cannot open file system browser", e);
56 }
57 }
58
59 @Override
60 public void setFocus() {
61 // TODO Auto-generated method stub
62
63 }
64
65 public void setNodeFileSystemProvider(FileSystemProvider nodeFileSystemProvider) {
66 this.nodeFileSystemProvider = nodeFileSystemProvider;
67 }
68 }