Move composites to main Documents UI package.
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 23 Oct 2020 09:54:07 +0000 (11:54 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 23 Oct 2020 09:54:07 +0000 (11:54 +0200)
library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsContextMenu.java [deleted file]
library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsFileComposite.java [deleted file]
library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsFolderComposite.java [deleted file]
library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsContextMenu.java [new file with mode: 0644]
library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFileComposite.java [new file with mode: 0644]
library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFolderComposite.java [new file with mode: 0644]

diff --git a/library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsContextMenu.java b/library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsContextMenu.java
deleted file mode 100644 (file)
index 63172c8..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-package org.argeo.documents.composites;
-
-import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_BOOKMARK_FOLDER;
-import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_CREATE_FOLDER;
-import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_DELETE;
-import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_DOWNLOAD_FOLDER;
-import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_RENAME;
-import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_SHARE_FOLDER;
-import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_UPLOAD_FILE;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import org.argeo.documents.ui.DocumentsUiService;
-import org.argeo.suite.ui.widgets.AbstractConnectContextMenu;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-
-/** Generic popup context menu to manage NIO Path in a Viewer. */
-public class DocumentsContextMenu extends AbstractConnectContextMenu {
-       // Local context
-       private final DocumentsFolderComposite browser;
-       private final DocumentsUiService uiService;
-//     private final Repository repository;
-
-       private final static String[] DEFAULT_ACTIONS = { ACTION_ID_CREATE_FOLDER, ACTION_ID_BOOKMARK_FOLDER,
-                       ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_RENAME,
-                       ACTION_ID_DELETE };
-
-       private Path currFolderPath;
-
-       public DocumentsContextMenu(DocumentsFolderComposite browser,
-                       DocumentsUiService documentsUiService) {
-               super(browser.getDisplay(), DEFAULT_ACTIONS);
-               this.browser = browser;
-               this.uiService = documentsUiService;
-//             this.repository = repository;
-
-               createControl();
-       }
-
-       public void setCurrFolderPath(Path currFolderPath) {
-               this.currFolderPath = currFolderPath;
-       }
-
-       protected boolean aboutToShow(Control source, Point location, IStructuredSelection selection) {
-               boolean emptySel = true;
-               boolean multiSel = false;
-               boolean isFolder = true;
-               if (selection != null && !selection.isEmpty()) {
-                       emptySel = false;
-                       multiSel = selection.size() > 1;
-                       if (!multiSel && selection.getFirstElement() instanceof Path) {
-                               isFolder = Files.isDirectory((Path) selection.getFirstElement());
-                       }
-               }
-               if (emptySel) {
-                       setVisible(true, ACTION_ID_CREATE_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_BOOKMARK_FOLDER);
-                       setVisible(false, ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER, ACTION_ID_RENAME, ACTION_ID_DELETE
-                               );
-               } else if (multiSel) {
-                       setVisible(true, ACTION_ID_CREATE_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_DELETE,
-                                       ACTION_ID_BOOKMARK_FOLDER);
-                       setVisible(false, ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER, ACTION_ID_RENAME);
-               } else if (isFolder) {
-                       setVisible(true, ACTION_ID_CREATE_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_RENAME, ACTION_ID_DELETE,
-                                       ACTION_ID_BOOKMARK_FOLDER);
-                       setVisible(false, 
-                                       // to be implemented
-                                       ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER);
-               } else {
-                       setVisible(true, ACTION_ID_CREATE_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_RENAME,
-                                       ACTION_ID_DELETE);
-                       setVisible(false, ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER, ACTION_ID_BOOKMARK_FOLDER);
-               }
-               return true;
-       }
-
-       public void show(Control source, Point location, IStructuredSelection selection, Path currFolderPath) {
-               // TODO find a better way to retrieve the parent path (cannot be deduced
-               // from table content because it will fail on an empty folder)
-               this.currFolderPath = currFolderPath;
-               super.show(source, location, selection);
-
-       }
-
-       @Override
-       protected boolean performAction(String actionId) {
-               switch (actionId) {
-               case ACTION_ID_CREATE_FOLDER:
-                       createFolder();
-                       break;
-               case ACTION_ID_BOOKMARK_FOLDER:
-                       bookmarkFolder();
-                       break;
-               case ACTION_ID_RENAME:
-                       renameItem();
-                       break;
-               case ACTION_ID_DELETE:
-                       deleteItems();
-                       break;
-//             case ACTION_ID_OPEN:
-//                     openFile();
-//                     break;
-               case ACTION_ID_UPLOAD_FILE:
-                       uploadFiles();
-                       break;
-               default:
-                       throw new IllegalArgumentException("Unimplemented action " + actionId);
-                       // case ACTION_ID_SHARE_FOLDER:
-                       // return "Share Folder";
-                       // case ACTION_ID_DOWNLOAD_FOLDER:
-                       // return "Download as zip archive";
-               }
-               browser.setFocus();
-               return false;
-       }
-
-       @Override
-       protected String getLabel(String actionId) {
-               return uiService.getLabel(actionId);
-       }
-
-       private void openFile() {
-               IStructuredSelection selection = ((IStructuredSelection) browser.getViewer().getSelection());
-               if (selection.isEmpty() || selection.size() > 1)
-                       // Should never happen
-                       return;
-               Path toOpenPath = ((Path) selection.getFirstElement());
-               uiService.openFile(toOpenPath);
-       }
-
-       private void deleteItems() {
-               IStructuredSelection selection = ((IStructuredSelection) browser.getViewer().getSelection());
-               if (selection.isEmpty())
-                       return;
-               else if (uiService.deleteItems(getParentShell(), selection))
-                       browser.refresh();
-       }
-
-       private void renameItem() {
-               IStructuredSelection selection = ((IStructuredSelection) browser.getViewer().getSelection());
-               if (selection.isEmpty() || selection.size() > 1)
-                       // Should never happen
-                       return;
-               Path toRenamePath = ((Path) selection.getFirstElement());
-               if (uiService.renameItem(getParentShell(), currFolderPath, toRenamePath))
-                       browser.refresh();
-       }
-
-       private void createFolder() {
-               if (uiService.createFolder(getParentShell(), currFolderPath))
-                       browser.refresh();
-       }
-
-       private void bookmarkFolder() {
-               Path toBookmarkPath = null;
-               IStructuredSelection selection = ((IStructuredSelection) browser.getViewer().getSelection());
-               if (selection.isEmpty())
-                       toBookmarkPath = currFolderPath;
-               else if (selection.size() > 1)
-                       toBookmarkPath = currFolderPath;
-               else if (selection.size() == 1) {
-                       Path currSelected = ((Path) selection.getFirstElement());
-                       if (Files.isDirectory(currSelected))
-                               toBookmarkPath = currSelected;
-                       else
-                               return;
-               }
-               //uiService.bookmarkFolder(toBookmarkPath, repository, null);
-       }
-
-       private void uploadFiles() {
-               if (uiService.uploadFiles(getParentShell(), currFolderPath))
-                       browser.refresh();
-       }
-}
diff --git a/library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsFileComposite.java b/library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsFileComposite.java
deleted file mode 100644 (file)
index 307eed7..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.argeo.documents.composites;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.spi.FileSystemProvider;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ui.util.CmsUiUtils;
-import org.argeo.documents.ui.DocumentsUtils;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.fs.FsUiUtils;
-import org.argeo.eclipse.ui.specific.UiContext;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-/**
- * Default Documents file composite: a sashForm with a browser in the middle and
- * meta data at right hand side.
- */
-public class DocumentsFileComposite extends Composite {
-       private static final long serialVersionUID = -7567632342889241793L;
-
-       private final static Log log = LogFactory.getLog(DocumentsFileComposite.class);
-
-       private final Node currentBaseContext;
-
-       // UI Parts for the browser
-       private Composite rightPannelCmp;
-
-       public DocumentsFileComposite(Composite parent, int style, Node context,
-                       FileSystemProvider fsp) {
-               super(parent, style);
-               this.currentBaseContext = context;
-               this.setLayout(EclipseUiUtils.noSpaceGridLayout());
-               SashForm form = new SashForm(this, SWT.HORIZONTAL);
-
-               Composite centerCmp = new Composite(form, SWT.BORDER | SWT.NO_FOCUS);
-               createDisplay(centerCmp);
-
-               rightPannelCmp = new Composite(form, SWT.NO_FOCUS);
-
-               Path path = DocumentsUtils.getPath(fsp, context);
-               setOverviewInput(path);
-               form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               form.setWeights(new int[] { 55, 20 });
-       }
-
-       private void createDisplay(final Composite parent) {
-               parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
-               Browser browser = new Browser(parent, SWT.NONE);
-               // browser.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true,
-               // true));
-               browser.setLayoutData(EclipseUiUtils.fillAll());
-               try {
-                       // FIXME make it more robust
-                       String url = CmsUiUtils.getDataUrl(currentBaseContext, UiContext.getHttpRequest());
-                       // FIXME issue with the redirection to https
-                       if (url.startsWith("http://") && !url.startsWith("http://localhost"))
-                               url = "https://" + url.substring("http://".length(), url.length());
-                       if (log.isTraceEnabled())
-                               log.debug("Trying to display " + url);
-                       browser.setUrl(url);
-                       browser.layout(true, true);
-               } catch (RepositoryException re) {
-                       throw new IllegalStateException("Cannot open file at " + currentBaseContext, re);
-               }
-       }
-
-       /**
-        * Recreates the content of the box that displays information about the current
-        * selected Path.
-        */
-       private void setOverviewInput(Path path) {
-               try {
-                       EclipseUiUtils.clear(rightPannelCmp);
-                       rightPannelCmp.setLayout(new GridLayout());
-                       if (path != null) {
-                               // if (isImg(context)) {
-                               // EditableImage image = new Img(parent, RIGHT, context,
-                               // imageWidth);
-                               // image.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER,
-                               // true, false,
-                               // 2, 1));
-                               // }
-
-                               Label contextL = new Label(rightPannelCmp, SWT.NONE);
-                               contextL.setText(path.getFileName().toString());
-                               contextL.setFont(EclipseUiUtils.getBoldFont(rightPannelCmp));
-                               addProperty(rightPannelCmp, "Last modified", Files.getLastModifiedTime(path).toString());
-                               // addProperty(rightPannelCmp, "Owner",
-                               // Files.getOwner(path).getName());
-                               if (Files.isDirectory(path)) {
-                                       addProperty(rightPannelCmp, "Type", "Folder");
-                               } else {
-                                       String mimeType = Files.probeContentType(path);
-                                       if (EclipseUiUtils.isEmpty(mimeType))
-                                               mimeType = "<i>Unknown</i>";
-                                       addProperty(rightPannelCmp, "Type", mimeType);
-                                       addProperty(rightPannelCmp, "Size", FsUiUtils.humanReadableByteCount(Files.size(path), false));
-                               }
-                       }
-                       rightPannelCmp.layout(true, true);
-               } catch (IOException e) {
-                       throw new IllegalStateException("Cannot display details for " + path.toString(), e);
-               }
-       }
-
-       // Simplify UI implementation
-       private void addProperty(Composite parent, String propName, String value) {
-               Label propLbl = new Label(parent, SWT.NONE);
-               //propLbl.setText(ConnectUtils.replaceAmpersand(propName + ": " + value));
-               propLbl.setText(value);
-               //CmsUiUtils.markup(propLbl);
-       }
-}
diff --git a/library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsFolderComposite.java b/library/org.argeo.documents.ui/src/org/argeo/documents/composites/DocumentsFolderComposite.java
deleted file mode 100644 (file)
index a8b6930..0000000
+++ /dev/null
@@ -1,456 +0,0 @@
-package org.argeo.documents.composites;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.attribute.FileTime;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.jcr.Node;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ui.fs.FileDrop;
-import org.argeo.cms.ui.fs.FsStyles;
-import org.argeo.cms.ui.util.CmsUiUtils;
-import org.argeo.documents.ui.DocumentsUiService;
-import org.argeo.eclipse.ui.ColumnDefinition;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.fs.FileIconNameLabelProvider;
-import org.argeo.eclipse.ui.fs.FsTableViewer;
-import org.argeo.eclipse.ui.fs.FsUiConstants;
-import org.argeo.eclipse.ui.fs.FsUiUtils;
-import org.argeo.eclipse.ui.fs.NioFileLabelProvider;
-import org.argeo.eclipse.ui.fs.ParentDir;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowData;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Default Documents folder composite: a sashForm layout with a simple table in
- * the middle and an overview at right hand side.
- */
-public class DocumentsFolderComposite extends Composite {
-       private final static Log log = LogFactory.getLog(DocumentsFolderComposite.class);
-       private static final long serialVersionUID = -40347919096946585L;
-
-       private final Node currentBaseContext;
-
-       private final DocumentsUiService documentUiService = new DocumentsUiService();
-
-       // UI Parts for the browser
-       private Composite filterCmp;
-       private Composite breadCrumbCmp;
-       private Text filterTxt;
-       private FsTableViewer directoryDisplayViewer;
-       private Composite rightPanelCmp;
-
-       private DocumentsContextMenu contextMenu;
-       private DateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm");
-
-       // Local context
-       private Path initialPath;
-       private Path currentFolder;
-
-       public DocumentsFolderComposite(Composite parent, int style, Node context) {
-               super(parent, style);
-               this.currentBaseContext = context;
-
-               this.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
-               SashForm form = new SashForm(this, SWT.HORIZONTAL);
-
-               Composite centerCmp = new Composite(form, SWT.BORDER | SWT.NO_FOCUS);
-               createDisplay(centerCmp);
-
-               rightPanelCmp = new Composite(form, SWT.NO_FOCUS);
-
-               form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               form.setWeights(new int[] { 55, 20 });
-       }
-
-       public void populate(Path path) {
-               initialPath = path;
-               directoryDisplayViewer.setInitialPath(initialPath);
-               setInput(path);
-       }
-
-       void refresh() {
-               modifyFilter(false);
-       }
-
-       private void createDisplay(final Composite parent) {
-               parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
-               // top filter
-               filterCmp = new Composite(parent, SWT.NO_FOCUS);
-               filterCmp.setLayoutData(EclipseUiUtils.fillWidth());
-               RowLayout rl = new RowLayout(SWT.HORIZONTAL);
-               rl.wrap = true;
-               rl.center = true;
-               filterCmp.setLayout(rl);
-               // addFilterPanel(filterCmp);
-
-               // Main display
-               directoryDisplayViewer = new FsTableViewer(parent, SWT.MULTI);
-               List<ColumnDefinition> colDefs = new ArrayList<>();
-               colDefs.add(new ColumnDefinition(new FileIconNameLabelProvider(), " Name", 250));
-               colDefs.add(new ColumnDefinition(new NioFileLabelProvider(FsUiConstants.PROPERTY_SIZE), "Size", 100));
-//             colDefs.add(new ColumnDefinition(new NioFileLabelProvider(FsUiConstants.PROPERTY_TYPE), "Type", 150));
-               colDefs.add(new ColumnDefinition(new NioFileLabelProvider(FsUiConstants.PROPERTY_LAST_MODIFIED),
-                               "Last modified", 400));
-               final Table table = directoryDisplayViewer.configureDefaultTable(colDefs);
-               table.setLayoutData(EclipseUiUtils.fillAll());
-
-               directoryDisplayViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
-                       @Override
-                       public void selectionChanged(SelectionChangedEvent event) {
-                               IStructuredSelection selection = (IStructuredSelection) directoryDisplayViewer.getSelection();
-                               Path selected = null;
-                               if (selection.isEmpty())
-                                       setSelected(null);
-                               else {
-                                       Object o = selection.getFirstElement();
-                                       if (o instanceof Path)
-                                               selected = (Path) o;
-                                       else if (o instanceof ParentDir)
-                                               selected = ((ParentDir) o).getPath();
-                               }
-                               if (selected != null) {
-                                       // TODO manage multiple selection
-                                       setSelected(selected);
-                               }
-                       }
-               });
-
-               directoryDisplayViewer.addDoubleClickListener(new IDoubleClickListener() {
-                       @Override
-                       public void doubleClick(DoubleClickEvent event) {
-                               IStructuredSelection selection = (IStructuredSelection) directoryDisplayViewer.getSelection();
-                               Path selected = null;
-                               if (!selection.isEmpty()) {
-                                       Object o = selection.getFirstElement();
-                                       if (o instanceof Path)
-                                               selected = (Path) o;
-                                       else if (o instanceof ParentDir)
-                                               selected = ((ParentDir) o).getPath();
-                               }
-                               if (selected != null) {
-                                       if (Files.isDirectory(selected))
-                                               setInput(selected);
-                                       else
-                                               externalNavigateTo(selected);
-                               }
-                       }
-               });
-
-               // The context menu
-               contextMenu = new DocumentsContextMenu(this,  documentUiService);
-
-               table.addMouseListener(new MouseAdapter() {
-                       private static final long serialVersionUID = 6737579410648595940L;
-
-                       @Override
-                       public void mouseDown(MouseEvent e) {
-                               if (e.button == 3) {
-                                       // contextMenu.setCurrFolderPath(currDisplayedFolder);
-                                       contextMenu.show(table, new Point(e.x, e.y),
-                                                       (IStructuredSelection) directoryDisplayViewer.getSelection(), currentFolder);
-                               }
-                       }
-               });
-
-               FileDrop fileDrop = new FileDrop() {
-
-                       @Override
-                       protected void processFileUpload(InputStream in, String fileName, String contetnType) throws IOException {
-                               Path file = currentFolder.resolve(fileName);
-                               Files.copy(in, file);
-                               refresh();
-                       }
-               };
-               fileDrop.createDropTarget(directoryDisplayViewer.getTable());
-       }
-
-       /**
-        * Overwrite to enable single sourcing between workbench and CMS navigation
-        */
-       protected void externalNavigateTo(Path path) {
-
-       }
-
-       private void addPathElementBtn(Path path) {
-               Button elemBtn = new Button(breadCrumbCmp, SWT.PUSH);
-               String nameStr;
-               if (path.toString().equals("/"))
-                       nameStr = "[jcr:root]";
-               else
-                       nameStr = path.getFileName().toString();
-//             elemBtn.setText(nameStr + " >> ");
-               elemBtn.setText(nameStr);
-               CmsUiUtils.style(elemBtn, FsStyles.BREAD_CRUMB_BTN);
-               elemBtn.addSelectionListener(new SelectionAdapter() {
-                       private static final long serialVersionUID = -4103695476023480651L;
-
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               setInput(path);
-                       }
-               });
-       }
-
-       public void setInput(Path path) {
-               if (path.equals(currentFolder))
-                       return;
-               // below initial path
-               if (!initialPath.equals(path) && initialPath.startsWith(path))
-                       return;
-               currentFolder = path;
-
-               Path diff = initialPath.relativize(currentFolder);
-
-               for (Control child : filterCmp.getChildren())
-                       if (!child.equals(filterTxt))
-                               child.dispose();
-
-               // Bread crumbs
-               breadCrumbCmp = new Composite(filterCmp, SWT.NO_FOCUS);
-               CmsUiUtils.style(breadCrumbCmp, FsStyles.BREAD_CRUMB_BTN);
-               RowLayout breadCrumbLayout = new RowLayout();
-               breadCrumbLayout.spacing = 0;
-               breadCrumbLayout.marginTop = 0;
-               breadCrumbLayout.marginBottom = 0;
-               breadCrumbLayout.marginRight = 0;
-               breadCrumbLayout.marginLeft = 0;
-               breadCrumbCmp.setLayout(breadCrumbLayout);
-               addPathElementBtn(initialPath);
-               Path currTarget = initialPath;
-               if (!diff.toString().equals(""))
-                       for (Path pathElem : diff) {
-                               currTarget = currTarget.resolve(pathElem);
-                               addPathElementBtn(currTarget);
-                       }
-
-               if (filterTxt != null) {
-                       filterTxt.setText("");
-                       filterTxt.moveBelow(null);
-               } else {
-                       modifyFilter(false);
-               }
-               setSelected(null);
-               filterCmp.getParent().layout(true, true);
-       }
-
-       private void setSelected(Path path) {
-               if (path == null)
-                       setOverviewInput(currentFolder);
-               else
-                       setOverviewInput(path);
-       }
-
-       public Viewer getViewer() {
-               return directoryDisplayViewer;
-       }
-
-       /**
-        * Recreates the content of the box that displays information about the current
-        * selected Path.
-        */
-       private void setOverviewInput(Path path) {
-               try {
-                       EclipseUiUtils.clear(rightPanelCmp);
-                       rightPanelCmp.setLayout(new GridLayout());
-                       if (path != null) {
-                               // if (isImg(context)) {
-                               // EditableImage image = new Img(parent, RIGHT, context,
-                               // imageWidth);
-                               // image.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER,
-                               // true, false,
-                               // 2, 1));
-                               // }
-
-                               Label contextL = new Label(rightPanelCmp, SWT.NONE);
-                               contextL.setText(path.getFileName().toString());
-                               contextL.setFont(EclipseUiUtils.getBoldFont(rightPanelCmp));
-                               FileTime lastModified = Files.getLastModifiedTime(path);
-                               if (lastModified.toMillis() != 0)
-                                       try {
-                                               String lastModifiedStr = dateFormat.format(new Date(lastModified.toMillis()));
-                                               addProperty(rightPanelCmp, "Last modified", lastModifiedStr);
-                                       } catch (Exception e) {
-                                               log.error("Workarounded issue while getting last update date for " + path, e);
-                                               addProperty(rightPanelCmp, "Last modified", "-");
-                                       }
-                               // addProperty(rightPannelCmp, "Owner",
-                               // Files.getOwner(path).getName());
-                               if (Files.isDirectory(path)) {
-                                       addProperty(rightPanelCmp, "Type", "Folder");
-                               } else {
-                                       String mimeType = Files.probeContentType(path);
-                                       if (EclipseUiUtils.isEmpty(mimeType))
-                                               mimeType = "<i>Unknown</i>";
-                                       addProperty(rightPanelCmp, "Type", mimeType);
-                                       addProperty(rightPanelCmp, "Size", FsUiUtils.humanReadableByteCount(Files.size(path), false));
-                               }
-
-                               // read all attributes
-//                             Map<String, Object> attrs = Files.readAttributes(path, "*");
-//                             for (String attr : attrs.keySet()) {
-//                                     Object value = attrs.get(attr);
-//                                     String str;
-//                                     if (value instanceof Calendar) {
-//                                             str = dateFormat.format(((Calendar) value).getTime());
-//                                     } else {
-//                                             str = value.toString();
-//                                     }
-//                                     addProperty(rightPanelCmp, attr, str);
-//
-//                             }
-                       }
-                       rightPanelCmp.layout(true, true);
-               } catch (IOException e) {
-                       throw new IllegalStateException("Cannot display details for " + path.toString(), e);
-               }
-       }
-
-       private void addFilterPanel(Composite parent) {
-               // parent.setLayout(EclipseUiUtils.noSpaceGridLayout(new GridLayout(2,
-               // false)));
-
-               filterTxt = new Text(parent, SWT.SEARCH | SWT.ICON_CANCEL);
-               filterTxt.setMessage("Search current folder");
-               filterTxt.setLayoutData(new RowData(250, SWT.DEFAULT));
-               filterTxt.addModifyListener(new ModifyListener() {
-                       private static final long serialVersionUID = 1L;
-
-                       public void modifyText(ModifyEvent event) {
-                               modifyFilter(false);
-                       }
-               });
-               filterTxt.addKeyListener(new KeyListener() {
-                       private static final long serialVersionUID = 2533535233583035527L;
-
-                       @Override
-                       public void keyReleased(KeyEvent e) {
-                       }
-
-                       @Override
-                       public void keyPressed(KeyEvent e) {
-                               // boolean shiftPressed = (e.stateMask & SWT.SHIFT) != 0;
-                               // // boolean altPressed = (e.stateMask & SWT.ALT) != 0;
-                               // FilterEntitiesVirtualTable currTable = null;
-                               // if (currEdited != null) {
-                               // FilterEntitiesVirtualTable table =
-                               // browserCols.get(currEdited);
-                               // if (table != null && !table.isDisposed())
-                               // currTable = table;
-                               // }
-                               //
-                               // if (e.keyCode == SWT.ARROW_DOWN)
-                               // currTable.setFocus();
-                               // else if (e.keyCode == SWT.BS) {
-                               // if (filterTxt.getText().equals("")
-                               // && !(currEdited.getNameCount() == 1 ||
-                               // currEdited.equals(initialPath))) {
-                               // Path oldEdited = currEdited;
-                               // Path parentPath = currEdited.getParent();
-                               // setEdited(parentPath);
-                               // if (browserCols.containsKey(parentPath))
-                               // browserCols.get(parentPath).setSelected(oldEdited);
-                               // filterTxt.setFocus();
-                               // e.doit = false;
-                               // }
-                               // } else if (e.keyCode == SWT.TAB && !shiftPressed) {
-                               // Path uniqueChild = getOnlyChild(currEdited,
-                               // filterTxt.getText());
-                               // if (uniqueChild != null) {
-                               // // Highlight the unique chosen child
-                               // currTable.setSelected(uniqueChild);
-                               // setEdited(uniqueChild);
-                               // }
-                               // filterTxt.setFocus();
-                               // e.doit = false;
-                               // }
-                       }
-               });
-       }
-
-       // private Path getOnlyChild(Path parent, String filter) {
-       // try (DirectoryStream<Path> stream =
-       // Files.newDirectoryStream(currDisplayedFolder, filter + "*")) {
-       // Path uniqueChild = null;
-       // boolean moreThanOne = false;
-       // loop: for (Path entry : stream) {
-       // if (uniqueChild == null) {
-       // uniqueChild = entry;
-       // } else {
-       // moreThanOne = true;
-       // break loop;
-       // }
-       // }
-       // if (!moreThanOne)
-       // return uniqueChild;
-       // return null;
-       // } catch (IOException ioe) {
-       // throw new DocumentsException(
-       // "Unable to determine unique child existence and get it under " + parent +
-       // " with filter " + filter,
-       // ioe);
-       // }
-       // }
-
-       private void modifyFilter(boolean fromOutside) {
-               if (!fromOutside)
-                       if (currentFolder != null) {
-                               String filter;
-                               if (filterTxt != null)
-                                       filter = filterTxt.getText() + "*";
-                               else
-                                       filter = "*";
-                               directoryDisplayViewer.setInput(currentFolder, filter);
-                       }
-       }
-
-       // Simplify UI implementation
-       private void addProperty(Composite parent, String propName, String value) {
-               Label propLbl = new Label(parent, SWT.NONE);
-               //propLbl.setText(ConnectUtils.replaceAmpersand(propName + ": " + value));
-               propLbl.setText(value);
-               //CmsUiUtils.markup(propLbl);
-       }
-
-       public Path getCurrentFolder() {
-               return currentFolder;
-       }
-
-}
diff --git a/library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsContextMenu.java b/library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsContextMenu.java
new file mode 100644 (file)
index 0000000..3757dc7
--- /dev/null
@@ -0,0 +1,177 @@
+package org.argeo.documents.ui;
+
+import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_BOOKMARK_FOLDER;
+import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_CREATE_FOLDER;
+import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_DELETE;
+import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_DOWNLOAD_FOLDER;
+import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_RENAME;
+import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_SHARE_FOLDER;
+import static org.argeo.documents.ui.DocumentsUiService.ACTION_ID_UPLOAD_FILE;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.argeo.suite.ui.widgets.AbstractConnectContextMenu;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+
+/** Generic popup context menu to manage NIO Path in a Viewer. */
+public class DocumentsContextMenu extends AbstractConnectContextMenu {
+       // Local context
+       private final DocumentsFolderComposite browser;
+       private final DocumentsUiService uiService;
+//     private final Repository repository;
+
+       private final static String[] DEFAULT_ACTIONS = { ACTION_ID_CREATE_FOLDER, ACTION_ID_BOOKMARK_FOLDER,
+                       ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_RENAME,
+                       ACTION_ID_DELETE };
+
+       private Path currFolderPath;
+
+       public DocumentsContextMenu(DocumentsFolderComposite browser,
+                       DocumentsUiService documentsUiService) {
+               super(browser.getDisplay(), DEFAULT_ACTIONS);
+               this.browser = browser;
+               this.uiService = documentsUiService;
+//             this.repository = repository;
+
+               createControl();
+       }
+
+       public void setCurrFolderPath(Path currFolderPath) {
+               this.currFolderPath = currFolderPath;
+       }
+
+       protected boolean aboutToShow(Control source, Point location, IStructuredSelection selection) {
+               boolean emptySel = true;
+               boolean multiSel = false;
+               boolean isFolder = true;
+               if (selection != null && !selection.isEmpty()) {
+                       emptySel = false;
+                       multiSel = selection.size() > 1;
+                       if (!multiSel && selection.getFirstElement() instanceof Path) {
+                               isFolder = Files.isDirectory((Path) selection.getFirstElement());
+                       }
+               }
+               if (emptySel) {
+                       setVisible(true, ACTION_ID_CREATE_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_BOOKMARK_FOLDER);
+                       setVisible(false, ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER, ACTION_ID_RENAME, ACTION_ID_DELETE
+                               );
+               } else if (multiSel) {
+                       setVisible(true, ACTION_ID_CREATE_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_DELETE,
+                                       ACTION_ID_BOOKMARK_FOLDER);
+                       setVisible(false, ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER, ACTION_ID_RENAME);
+               } else if (isFolder) {
+                       setVisible(true, ACTION_ID_CREATE_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_RENAME, ACTION_ID_DELETE,
+                                       ACTION_ID_BOOKMARK_FOLDER);
+                       setVisible(false, 
+                                       // to be implemented
+                                       ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER);
+               } else {
+                       setVisible(true, ACTION_ID_CREATE_FOLDER, ACTION_ID_UPLOAD_FILE, ACTION_ID_RENAME,
+                                       ACTION_ID_DELETE);
+                       setVisible(false, ACTION_ID_SHARE_FOLDER, ACTION_ID_DOWNLOAD_FOLDER, ACTION_ID_BOOKMARK_FOLDER);
+               }
+               return true;
+       }
+
+       public void show(Control source, Point location, IStructuredSelection selection, Path currFolderPath) {
+               // TODO find a better way to retrieve the parent path (cannot be deduced
+               // from table content because it will fail on an empty folder)
+               this.currFolderPath = currFolderPath;
+               super.show(source, location, selection);
+
+       }
+
+       @Override
+       protected boolean performAction(String actionId) {
+               switch (actionId) {
+               case ACTION_ID_CREATE_FOLDER:
+                       createFolder();
+                       break;
+               case ACTION_ID_BOOKMARK_FOLDER:
+                       bookmarkFolder();
+                       break;
+               case ACTION_ID_RENAME:
+                       renameItem();
+                       break;
+               case ACTION_ID_DELETE:
+                       deleteItems();
+                       break;
+//             case ACTION_ID_OPEN:
+//                     openFile();
+//                     break;
+               case ACTION_ID_UPLOAD_FILE:
+                       uploadFiles();
+                       break;
+               default:
+                       throw new IllegalArgumentException("Unimplemented action " + actionId);
+                       // case ACTION_ID_SHARE_FOLDER:
+                       // return "Share Folder";
+                       // case ACTION_ID_DOWNLOAD_FOLDER:
+                       // return "Download as zip archive";
+               }
+               browser.setFocus();
+               return false;
+       }
+
+       @Override
+       protected String getLabel(String actionId) {
+               return uiService.getLabel(actionId);
+       }
+
+       private void openFile() {
+               IStructuredSelection selection = ((IStructuredSelection) browser.getViewer().getSelection());
+               if (selection.isEmpty() || selection.size() > 1)
+                       // Should never happen
+                       return;
+               Path toOpenPath = ((Path) selection.getFirstElement());
+               uiService.openFile(toOpenPath);
+       }
+
+       private void deleteItems() {
+               IStructuredSelection selection = ((IStructuredSelection) browser.getViewer().getSelection());
+               if (selection.isEmpty())
+                       return;
+               else if (uiService.deleteItems(getParentShell(), selection))
+                       browser.refresh();
+       }
+
+       private void renameItem() {
+               IStructuredSelection selection = ((IStructuredSelection) browser.getViewer().getSelection());
+               if (selection.isEmpty() || selection.size() > 1)
+                       // Should never happen
+                       return;
+               Path toRenamePath = ((Path) selection.getFirstElement());
+               if (uiService.renameItem(getParentShell(), currFolderPath, toRenamePath))
+                       browser.refresh();
+       }
+
+       private void createFolder() {
+               if (uiService.createFolder(getParentShell(), currFolderPath))
+                       browser.refresh();
+       }
+
+       private void bookmarkFolder() {
+               Path toBookmarkPath = null;
+               IStructuredSelection selection = ((IStructuredSelection) browser.getViewer().getSelection());
+               if (selection.isEmpty())
+                       toBookmarkPath = currFolderPath;
+               else if (selection.size() > 1)
+                       toBookmarkPath = currFolderPath;
+               else if (selection.size() == 1) {
+                       Path currSelected = ((Path) selection.getFirstElement());
+                       if (Files.isDirectory(currSelected))
+                               toBookmarkPath = currSelected;
+                       else
+                               return;
+               }
+               //uiService.bookmarkFolder(toBookmarkPath, repository, null);
+       }
+
+       private void uploadFiles() {
+               if (uiService.uploadFiles(getParentShell(), currFolderPath))
+                       browser.refresh();
+       }
+}
diff --git a/library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFileComposite.java b/library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFileComposite.java
new file mode 100644 (file)
index 0000000..e0eaf1e
--- /dev/null
@@ -0,0 +1,124 @@
+package org.argeo.documents.ui;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.spi.FileSystemProvider;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.ui.util.CmsUiUtils;
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.eclipse.ui.fs.FsUiUtils;
+import org.argeo.eclipse.ui.specific.UiContext;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Default Documents file composite: a sashForm with a browser in the middle and
+ * meta data at right hand side.
+ */
+public class DocumentsFileComposite extends Composite {
+       private static final long serialVersionUID = -7567632342889241793L;
+
+       private final static Log log = LogFactory.getLog(DocumentsFileComposite.class);
+
+       private final Node currentBaseContext;
+
+       // UI Parts for the browser
+       private Composite rightPannelCmp;
+
+       public DocumentsFileComposite(Composite parent, int style, Node context,
+                       FileSystemProvider fsp) {
+               super(parent, style);
+               this.currentBaseContext = context;
+               this.setLayout(EclipseUiUtils.noSpaceGridLayout());
+               SashForm form = new SashForm(this, SWT.HORIZONTAL);
+
+               Composite centerCmp = new Composite(form, SWT.BORDER | SWT.NO_FOCUS);
+               createDisplay(centerCmp);
+
+               rightPannelCmp = new Composite(form, SWT.NO_FOCUS);
+
+               Path path = DocumentsUtils.getPath(fsp, context);
+               setOverviewInput(path);
+               form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               form.setWeights(new int[] { 55, 20 });
+       }
+
+       private void createDisplay(final Composite parent) {
+               parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
+               Browser browser = new Browser(parent, SWT.NONE);
+               // browser.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true,
+               // true));
+               browser.setLayoutData(EclipseUiUtils.fillAll());
+               try {
+                       // FIXME make it more robust
+                       String url = CmsUiUtils.getDataUrl(currentBaseContext, UiContext.getHttpRequest());
+                       // FIXME issue with the redirection to https
+                       if (url.startsWith("http://") && !url.startsWith("http://localhost"))
+                               url = "https://" + url.substring("http://".length(), url.length());
+                       if (log.isTraceEnabled())
+                               log.debug("Trying to display " + url);
+                       browser.setUrl(url);
+                       browser.layout(true, true);
+               } catch (RepositoryException re) {
+                       throw new IllegalStateException("Cannot open file at " + currentBaseContext, re);
+               }
+       }
+
+       /**
+        * Recreates the content of the box that displays information about the current
+        * selected Path.
+        */
+       private void setOverviewInput(Path path) {
+               try {
+                       EclipseUiUtils.clear(rightPannelCmp);
+                       rightPannelCmp.setLayout(new GridLayout());
+                       if (path != null) {
+                               // if (isImg(context)) {
+                               // EditableImage image = new Img(parent, RIGHT, context,
+                               // imageWidth);
+                               // image.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER,
+                               // true, false,
+                               // 2, 1));
+                               // }
+
+                               Label contextL = new Label(rightPannelCmp, SWT.NONE);
+                               contextL.setText(path.getFileName().toString());
+                               contextL.setFont(EclipseUiUtils.getBoldFont(rightPannelCmp));
+                               addProperty(rightPannelCmp, "Last modified", Files.getLastModifiedTime(path).toString());
+                               // addProperty(rightPannelCmp, "Owner",
+                               // Files.getOwner(path).getName());
+                               if (Files.isDirectory(path)) {
+                                       addProperty(rightPannelCmp, "Type", "Folder");
+                               } else {
+                                       String mimeType = Files.probeContentType(path);
+                                       if (EclipseUiUtils.isEmpty(mimeType))
+                                               mimeType = "<i>Unknown</i>";
+                                       addProperty(rightPannelCmp, "Type", mimeType);
+                                       addProperty(rightPannelCmp, "Size", FsUiUtils.humanReadableByteCount(Files.size(path), false));
+                               }
+                       }
+                       rightPannelCmp.layout(true, true);
+               } catch (IOException e) {
+                       throw new IllegalStateException("Cannot display details for " + path.toString(), e);
+               }
+       }
+
+       // Simplify UI implementation
+       private void addProperty(Composite parent, String propName, String value) {
+               Label propLbl = new Label(parent, SWT.NONE);
+               //propLbl.setText(ConnectUtils.replaceAmpersand(propName + ": " + value));
+               propLbl.setText(value);
+               //CmsUiUtils.markup(propLbl);
+       }
+}
diff --git a/library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFolderComposite.java b/library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFolderComposite.java
new file mode 100644 (file)
index 0000000..289a0cd
--- /dev/null
@@ -0,0 +1,455 @@
+package org.argeo.documents.ui;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileTime;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.jcr.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.ui.fs.FileDrop;
+import org.argeo.cms.ui.fs.FsStyles;
+import org.argeo.cms.ui.util.CmsUiUtils;
+import org.argeo.eclipse.ui.ColumnDefinition;
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.eclipse.ui.fs.FileIconNameLabelProvider;
+import org.argeo.eclipse.ui.fs.FsTableViewer;
+import org.argeo.eclipse.ui.fs.FsUiConstants;
+import org.argeo.eclipse.ui.fs.FsUiUtils;
+import org.argeo.eclipse.ui.fs.NioFileLabelProvider;
+import org.argeo.eclipse.ui.fs.ParentDir;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Default Documents folder composite: a sashForm layout with a simple table in
+ * the middle and an overview at right hand side.
+ */
+public class DocumentsFolderComposite extends Composite {
+       private final static Log log = LogFactory.getLog(DocumentsFolderComposite.class);
+       private static final long serialVersionUID = -40347919096946585L;
+
+       private final Node currentBaseContext;
+
+       private final DocumentsUiService documentUiService = new DocumentsUiService();
+
+       // UI Parts for the browser
+       private Composite filterCmp;
+       private Composite breadCrumbCmp;
+       private Text filterTxt;
+       private FsTableViewer directoryDisplayViewer;
+       private Composite rightPanelCmp;
+
+       private DocumentsContextMenu contextMenu;
+       private DateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm");
+
+       // Local context
+       private Path initialPath;
+       private Path currentFolder;
+
+       public DocumentsFolderComposite(Composite parent, int style, Node context) {
+               super(parent, style);
+               this.currentBaseContext = context;
+
+               this.setLayout(EclipseUiUtils.noSpaceGridLayout());
+
+               SashForm form = new SashForm(this, SWT.HORIZONTAL);
+
+               Composite centerCmp = new Composite(form, SWT.BORDER | SWT.NO_FOCUS);
+               createDisplay(centerCmp);
+
+               rightPanelCmp = new Composite(form, SWT.NO_FOCUS);
+
+               form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               form.setWeights(new int[] { 55, 20 });
+       }
+
+       public void populate(Path path) {
+               initialPath = path;
+               directoryDisplayViewer.setInitialPath(initialPath);
+               setInput(path);
+       }
+
+       void refresh() {
+               modifyFilter(false);
+       }
+
+       private void createDisplay(final Composite parent) {
+               parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
+
+               // top filter
+               filterCmp = new Composite(parent, SWT.NO_FOCUS);
+               filterCmp.setLayoutData(EclipseUiUtils.fillWidth());
+               RowLayout rl = new RowLayout(SWT.HORIZONTAL);
+               rl.wrap = true;
+               rl.center = true;
+               filterCmp.setLayout(rl);
+               // addFilterPanel(filterCmp);
+
+               // Main display
+               directoryDisplayViewer = new FsTableViewer(parent, SWT.MULTI);
+               List<ColumnDefinition> colDefs = new ArrayList<>();
+               colDefs.add(new ColumnDefinition(new FileIconNameLabelProvider(), " Name", 250));
+               colDefs.add(new ColumnDefinition(new NioFileLabelProvider(FsUiConstants.PROPERTY_SIZE), "Size", 100));
+//             colDefs.add(new ColumnDefinition(new NioFileLabelProvider(FsUiConstants.PROPERTY_TYPE), "Type", 150));
+               colDefs.add(new ColumnDefinition(new NioFileLabelProvider(FsUiConstants.PROPERTY_LAST_MODIFIED),
+                               "Last modified", 400));
+               final Table table = directoryDisplayViewer.configureDefaultTable(colDefs);
+               table.setLayoutData(EclipseUiUtils.fillAll());
+
+               directoryDisplayViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+                       @Override
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               IStructuredSelection selection = (IStructuredSelection) directoryDisplayViewer.getSelection();
+                               Path selected = null;
+                               if (selection.isEmpty())
+                                       setSelected(null);
+                               else {
+                                       Object o = selection.getFirstElement();
+                                       if (o instanceof Path)
+                                               selected = (Path) o;
+                                       else if (o instanceof ParentDir)
+                                               selected = ((ParentDir) o).getPath();
+                               }
+                               if (selected != null) {
+                                       // TODO manage multiple selection
+                                       setSelected(selected);
+                               }
+                       }
+               });
+
+               directoryDisplayViewer.addDoubleClickListener(new IDoubleClickListener() {
+                       @Override
+                       public void doubleClick(DoubleClickEvent event) {
+                               IStructuredSelection selection = (IStructuredSelection) directoryDisplayViewer.getSelection();
+                               Path selected = null;
+                               if (!selection.isEmpty()) {
+                                       Object o = selection.getFirstElement();
+                                       if (o instanceof Path)
+                                               selected = (Path) o;
+                                       else if (o instanceof ParentDir)
+                                               selected = ((ParentDir) o).getPath();
+                               }
+                               if (selected != null) {
+                                       if (Files.isDirectory(selected))
+                                               setInput(selected);
+                                       else
+                                               externalNavigateTo(selected);
+                               }
+                       }
+               });
+
+               // The context menu
+               contextMenu = new DocumentsContextMenu(this,  documentUiService);
+
+               table.addMouseListener(new MouseAdapter() {
+                       private static final long serialVersionUID = 6737579410648595940L;
+
+                       @Override
+                       public void mouseDown(MouseEvent e) {
+                               if (e.button == 3) {
+                                       // contextMenu.setCurrFolderPath(currDisplayedFolder);
+                                       contextMenu.show(table, new Point(e.x, e.y),
+                                                       (IStructuredSelection) directoryDisplayViewer.getSelection(), currentFolder);
+                               }
+                       }
+               });
+
+               FileDrop fileDrop = new FileDrop() {
+
+                       @Override
+                       protected void processFileUpload(InputStream in, String fileName, String contetnType) throws IOException {
+                               Path file = currentFolder.resolve(fileName);
+                               Files.copy(in, file);
+                               refresh();
+                       }
+               };
+               fileDrop.createDropTarget(directoryDisplayViewer.getTable());
+       }
+
+       /**
+        * Overwrite to enable single sourcing between workbench and CMS navigation
+        */
+       protected void externalNavigateTo(Path path) {
+
+       }
+
+       private void addPathElementBtn(Path path) {
+               Button elemBtn = new Button(breadCrumbCmp, SWT.PUSH);
+               String nameStr;
+               if (path.toString().equals("/"))
+                       nameStr = "[jcr:root]";
+               else
+                       nameStr = path.getFileName().toString();
+//             elemBtn.setText(nameStr + " >> ");
+               elemBtn.setText(nameStr);
+               CmsUiUtils.style(elemBtn, FsStyles.BREAD_CRUMB_BTN);
+               elemBtn.addSelectionListener(new SelectionAdapter() {
+                       private static final long serialVersionUID = -4103695476023480651L;
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               setInput(path);
+                       }
+               });
+       }
+
+       public void setInput(Path path) {
+               if (path.equals(currentFolder))
+                       return;
+               // below initial path
+               if (!initialPath.equals(path) && initialPath.startsWith(path))
+                       return;
+               currentFolder = path;
+
+               Path diff = initialPath.relativize(currentFolder);
+
+               for (Control child : filterCmp.getChildren())
+                       if (!child.equals(filterTxt))
+                               child.dispose();
+
+               // Bread crumbs
+               breadCrumbCmp = new Composite(filterCmp, SWT.NO_FOCUS);
+               CmsUiUtils.style(breadCrumbCmp, FsStyles.BREAD_CRUMB_BTN);
+               RowLayout breadCrumbLayout = new RowLayout();
+               breadCrumbLayout.spacing = 0;
+               breadCrumbLayout.marginTop = 0;
+               breadCrumbLayout.marginBottom = 0;
+               breadCrumbLayout.marginRight = 0;
+               breadCrumbLayout.marginLeft = 0;
+               breadCrumbCmp.setLayout(breadCrumbLayout);
+               addPathElementBtn(initialPath);
+               Path currTarget = initialPath;
+               if (!diff.toString().equals(""))
+                       for (Path pathElem : diff) {
+                               currTarget = currTarget.resolve(pathElem);
+                               addPathElementBtn(currTarget);
+                       }
+
+               if (filterTxt != null) {
+                       filterTxt.setText("");
+                       filterTxt.moveBelow(null);
+               } else {
+                       modifyFilter(false);
+               }
+               setSelected(null);
+               filterCmp.getParent().layout(true, true);
+       }
+
+       private void setSelected(Path path) {
+               if (path == null)
+                       setOverviewInput(currentFolder);
+               else
+                       setOverviewInput(path);
+       }
+
+       public Viewer getViewer() {
+               return directoryDisplayViewer;
+       }
+
+       /**
+        * Recreates the content of the box that displays information about the current
+        * selected Path.
+        */
+       private void setOverviewInput(Path path) {
+               try {
+                       EclipseUiUtils.clear(rightPanelCmp);
+                       rightPanelCmp.setLayout(new GridLayout());
+                       if (path != null) {
+                               // if (isImg(context)) {
+                               // EditableImage image = new Img(parent, RIGHT, context,
+                               // imageWidth);
+                               // image.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER,
+                               // true, false,
+                               // 2, 1));
+                               // }
+
+                               Label contextL = new Label(rightPanelCmp, SWT.NONE);
+                               contextL.setText(path.getFileName().toString());
+                               contextL.setFont(EclipseUiUtils.getBoldFont(rightPanelCmp));
+                               FileTime lastModified = Files.getLastModifiedTime(path);
+                               if (lastModified.toMillis() != 0)
+                                       try {
+                                               String lastModifiedStr = dateFormat.format(new Date(lastModified.toMillis()));
+                                               addProperty(rightPanelCmp, "Last modified", lastModifiedStr);
+                                       } catch (Exception e) {
+                                               log.error("Workarounded issue while getting last update date for " + path, e);
+                                               addProperty(rightPanelCmp, "Last modified", "-");
+                                       }
+                               // addProperty(rightPannelCmp, "Owner",
+                               // Files.getOwner(path).getName());
+                               if (Files.isDirectory(path)) {
+                                       addProperty(rightPanelCmp, "Type", "Folder");
+                               } else {
+                                       String mimeType = Files.probeContentType(path);
+                                       if (EclipseUiUtils.isEmpty(mimeType))
+                                               mimeType = "<i>Unknown</i>";
+                                       addProperty(rightPanelCmp, "Type", mimeType);
+                                       addProperty(rightPanelCmp, "Size", FsUiUtils.humanReadableByteCount(Files.size(path), false));
+                               }
+
+                               // read all attributes
+//                             Map<String, Object> attrs = Files.readAttributes(path, "*");
+//                             for (String attr : attrs.keySet()) {
+//                                     Object value = attrs.get(attr);
+//                                     String str;
+//                                     if (value instanceof Calendar) {
+//                                             str = dateFormat.format(((Calendar) value).getTime());
+//                                     } else {
+//                                             str = value.toString();
+//                                     }
+//                                     addProperty(rightPanelCmp, attr, str);
+//
+//                             }
+                       }
+                       rightPanelCmp.layout(true, true);
+               } catch (IOException e) {
+                       throw new IllegalStateException("Cannot display details for " + path.toString(), e);
+               }
+       }
+
+       private void addFilterPanel(Composite parent) {
+               // parent.setLayout(EclipseUiUtils.noSpaceGridLayout(new GridLayout(2,
+               // false)));
+
+               filterTxt = new Text(parent, SWT.SEARCH | SWT.ICON_CANCEL);
+               filterTxt.setMessage("Search current folder");
+               filterTxt.setLayoutData(new RowData(250, SWT.DEFAULT));
+               filterTxt.addModifyListener(new ModifyListener() {
+                       private static final long serialVersionUID = 1L;
+
+                       public void modifyText(ModifyEvent event) {
+                               modifyFilter(false);
+                       }
+               });
+               filterTxt.addKeyListener(new KeyListener() {
+                       private static final long serialVersionUID = 2533535233583035527L;
+
+                       @Override
+                       public void keyReleased(KeyEvent e) {
+                       }
+
+                       @Override
+                       public void keyPressed(KeyEvent e) {
+                               // boolean shiftPressed = (e.stateMask & SWT.SHIFT) != 0;
+                               // // boolean altPressed = (e.stateMask & SWT.ALT) != 0;
+                               // FilterEntitiesVirtualTable currTable = null;
+                               // if (currEdited != null) {
+                               // FilterEntitiesVirtualTable table =
+                               // browserCols.get(currEdited);
+                               // if (table != null && !table.isDisposed())
+                               // currTable = table;
+                               // }
+                               //
+                               // if (e.keyCode == SWT.ARROW_DOWN)
+                               // currTable.setFocus();
+                               // else if (e.keyCode == SWT.BS) {
+                               // if (filterTxt.getText().equals("")
+                               // && !(currEdited.getNameCount() == 1 ||
+                               // currEdited.equals(initialPath))) {
+                               // Path oldEdited = currEdited;
+                               // Path parentPath = currEdited.getParent();
+                               // setEdited(parentPath);
+                               // if (browserCols.containsKey(parentPath))
+                               // browserCols.get(parentPath).setSelected(oldEdited);
+                               // filterTxt.setFocus();
+                               // e.doit = false;
+                               // }
+                               // } else if (e.keyCode == SWT.TAB && !shiftPressed) {
+                               // Path uniqueChild = getOnlyChild(currEdited,
+                               // filterTxt.getText());
+                               // if (uniqueChild != null) {
+                               // // Highlight the unique chosen child
+                               // currTable.setSelected(uniqueChild);
+                               // setEdited(uniqueChild);
+                               // }
+                               // filterTxt.setFocus();
+                               // e.doit = false;
+                               // }
+                       }
+               });
+       }
+
+       // private Path getOnlyChild(Path parent, String filter) {
+       // try (DirectoryStream<Path> stream =
+       // Files.newDirectoryStream(currDisplayedFolder, filter + "*")) {
+       // Path uniqueChild = null;
+       // boolean moreThanOne = false;
+       // loop: for (Path entry : stream) {
+       // if (uniqueChild == null) {
+       // uniqueChild = entry;
+       // } else {
+       // moreThanOne = true;
+       // break loop;
+       // }
+       // }
+       // if (!moreThanOne)
+       // return uniqueChild;
+       // return null;
+       // } catch (IOException ioe) {
+       // throw new DocumentsException(
+       // "Unable to determine unique child existence and get it under " + parent +
+       // " with filter " + filter,
+       // ioe);
+       // }
+       // }
+
+       private void modifyFilter(boolean fromOutside) {
+               if (!fromOutside)
+                       if (currentFolder != null) {
+                               String filter;
+                               if (filterTxt != null)
+                                       filter = filterTxt.getText() + "*";
+                               else
+                                       filter = "*";
+                               directoryDisplayViewer.setInput(currentFolder, filter);
+                       }
+       }
+
+       // Simplify UI implementation
+       private void addProperty(Composite parent, String propName, String value) {
+               Label propLbl = new Label(parent, SWT.NONE);
+               //propLbl.setText(ConnectUtils.replaceAmpersand(propName + ": " + value));
+               propLbl.setText(value);
+               //CmsUiUtils.markup(propLbl);
+       }
+
+       public Path getCurrentFolder() {
+               return currentFolder;
+       }
+
+}