]> git.argeo.org Git - lgpl/argeo-commons.git/blob - NodeFsBrowserView.java
378e4b51036767568ac0aa6327ed6a5210a3e585
[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.e4.files;
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 javax.annotation.PostConstruct;
25 import javax.inject.Inject;
26
27 import org.argeo.cms.CmsException;
28 import org.argeo.eclipse.ui.fs.AdvancedFsBrowser;
29 import org.argeo.eclipse.ui.fs.SimpleFsBrowser;
30 import org.eclipse.swt.SWT;
31 import org.eclipse.swt.widgets.Composite;
32
33 /** Browse the node file system. */
34 public class NodeFsBrowserView {
35 // public final static String ID = WorkbenchUiPlugin.PLUGIN_ID +
36 // ".nodeFsBrowserView";
37
38 @Inject
39 FileSystemProvider nodeFileSystemProvider;
40
41 @PostConstruct
42 public void createPartControl(Composite parent) {
43 try {
44 //URI uri = new URI("node://root:demo@localhost:7070/");
45 URI uri = new URI("node:///");
46 FileSystem fileSystem = nodeFileSystemProvider.getFileSystem(uri);
47 if (fileSystem == null)
48 fileSystem = nodeFileSystemProvider.newFileSystem(uri, null);
49 Path nodePath = fileSystem.getPath("/");
50
51 Path localPath = Paths.get(System.getProperty("user.home"));
52
53 SimpleFsBrowser browser = new SimpleFsBrowser(parent, SWT.NO_FOCUS);
54 browser.setInput(nodePath, localPath);
55 // AdvancedFsBrowser browser = new AdvancedFsBrowser();
56 // browser.createUi(parent, localPath);
57 } catch (Exception e) {
58 throw new CmsException("Cannot open file system browser", e);
59 }
60 }
61
62 public void setFocus() {
63 }
64 }