]> git.argeo.org Git - lgpl/argeo-commons.git/blob - NodeFsBrowserView.java
cba228f2d27f748a56aa92f8669e363cbadcb066
[lgpl/argeo-commons.git] / 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.spi.FileSystemProvider;
22
23 import org.argeo.cms.CmsException;
24 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
25 import org.argeo.eclipse.ui.fs.SimpleFsBrowser;
26 import org.eclipse.swt.SWT;
27 import org.eclipse.swt.widgets.Composite;
28 import org.eclipse.ui.part.ViewPart;
29
30 /** Browse the node file system. */
31 public class NodeFsBrowserView extends ViewPart {
32 public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".nodeFsBrowserView";
33
34 private FileSystemProvider nodeFileSystemProvider;
35
36 @Override
37 public void createPartControl(Composite parent) {
38 try {
39 URI uri = new URI("node:///");
40 FileSystem fileSystem = nodeFileSystemProvider.getFileSystem(uri);
41 if (fileSystem == null)
42 fileSystem = nodeFileSystemProvider.newFileSystem(uri, null);
43 Path nodePath = fileSystem.getPath("~");
44 SimpleFsBrowser browser = new SimpleFsBrowser(parent, SWT.NO_FOCUS);
45 browser.setInput(nodePath);
46 } catch (Exception e) {
47 throw new CmsException("Cannot open file system browser", e);
48 }
49 }
50
51 @Override
52 public void setFocus() {
53 }
54
55 public void setNodeFileSystemProvider(FileSystemProvider nodeFileSystemProvider) {
56 this.nodeFileSystemProvider = nodeFileSystemProvider;
57 }
58 }