Introduce content layer.
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 5 May 2021 09:14:46 +0000 (11:14 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 5 May 2021 09:14:46 +0000 (11:14 +0200)
30 files changed:
core/org.argeo.entity.api/src/org/argeo/entity/EntityType.java
core/org.argeo.entity.api/src/org/argeo/entity/entity.cnd
core/org.argeo.suite.ui/OSGI-INF/leadPane.xml
core/org.argeo.suite.ui/src/org/argeo/suite/ui/widgets/TreeOrSearchArea.java [new file with mode: 0644]
library/org.argeo.documents.ui/config/documentsLayer.properties [deleted file]
library/org.argeo.documents.ui/config/entryArea.properties [deleted file]
library/org.argeo.library.ui/.classpath [moved from library/org.argeo.documents.ui/.classpath with 100% similarity]
library/org.argeo.library.ui/.gitignore [moved from library/org.argeo.documents.ui/.gitignore with 100% similarity]
library/org.argeo.library.ui/.project [moved from library/org.argeo.documents.ui/.project with 95% similarity]
library/org.argeo.library.ui/META-INF/.gitignore [moved from library/org.argeo.documents.ui/META-INF/.gitignore with 100% similarity]
library/org.argeo.library.ui/OSGI-INF/contentEntryArea.xml [new file with mode: 0644]
library/org.argeo.library.ui/OSGI-INF/contentLayer.xml [moved from library/org.argeo.documents.ui/OSGI-INF/documentsLayer.xml with 62% similarity]
library/org.argeo.library.ui/OSGI-INF/documentsFolder.xml [moved from library/org.argeo.documents.ui/OSGI-INF/documentsFolder.xml with 86% similarity]
library/org.argeo.library.ui/OSGI-INF/fsEntryArea.xml [moved from library/org.argeo.documents.ui/OSGI-INF/entryArea.xml with 68% similarity]
library/org.argeo.library.ui/OSGI-INF/l10n/bundle.properties [moved from library/org.argeo.documents.ui/OSGI-INF/l10n/bundle.properties with 100% similarity]
library/org.argeo.library.ui/bnd.bnd [moved from library/org.argeo.documents.ui/bnd.bnd with 52% similarity]
library/org.argeo.library.ui/build.properties [moved from library/org.argeo.documents.ui/build.properties with 76% similarity]
library/org.argeo.library.ui/config/contentEntryArea.properties [new file with mode: 0644]
library/org.argeo.library.ui/config/contentLayer.properties [new file with mode: 0644]
library/org.argeo.library.ui/config/documentsFolder.properties [moved from library/org.argeo.documents.ui/config/documentsFolder.properties with 100% similarity]
library/org.argeo.library.ui/config/fsEntryArea.properties [new file with mode: 0644]
library/org.argeo.library.ui/pom.xml [moved from library/org.argeo.documents.ui/pom.xml with 95% similarity]
library/org.argeo.library.ui/src/org/argeo/library/ui/ContentEntryArea.java [new file with mode: 0644]
library/org.argeo.library.ui/src/org/argeo/library/ui/DocumentsContextMenu.java [moved from library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsContextMenu.java with 90% similarity]
library/org.argeo.library.ui/src/org/argeo/library/ui/DocumentsFileComposite.java [moved from library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFileComposite.java with 99% similarity]
library/org.argeo.library.ui/src/org/argeo/library/ui/DocumentsFolderComposite.java [moved from library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFolderComposite.java with 99% similarity]
library/org.argeo.library.ui/src/org/argeo/library/ui/DocumentsFolderUiProvider.java [moved from library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsFolderUiProvider.java with 97% similarity]
library/org.argeo.library.ui/src/org/argeo/library/ui/DocumentsTreeUiProvider.java [moved from library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsTreeUiProvider.java with 98% similarity]
library/org.argeo.library.ui/src/org/argeo/library/ui/DocumentsUiService.java [moved from library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsUiService.java with 99% similarity]
library/pom.xml

index ecd6330fed6252be79b537ac1e6573535050eccd..84fa16fdf3a9c453a9a0b9b1415c204642b09e43 100644 (file)
@@ -4,6 +4,8 @@ package org.argeo.entity;
 public enum EntityType implements JcrName {
        // entity
        entity, local, relatedTo,
+       // structure
+       space,
        // typology
        typologies, terms, term,
        // form
index b64a275a116788f9a5e1fbdf0f83d164e445d07d..cd3f327fde8a0331176665190b489827ec092cb8 100644 (file)
@@ -35,6 +35,12 @@ mixin
 //+ * (entity:reference)
 //+ * (entity:composite)
 
+//
+// STRUCTURE
+//
+[entity:space]
+mixin
+
 //
 // TYPOLOGY
 //
index 1aeec0ab8efef0d329f9f537b2354dd12d31dfd0..c43d9336ace5ff523d8ef982da56cc0424a7b6cb 100644 (file)
@@ -6,7 +6,7 @@
    </service>
    <properties entry="config/leadPane.properties"/>
    <property name="defaultLayers" type="String">argeo.suite.ui.dashboardLayer
-argeo.documents.ui.documentsLayer
+argeo.library.ui.contentLayer
 argeo.people.ui.peopleLayer
 argeo.geo.ui.mapLayer
    </property>
diff --git a/core/org.argeo.suite.ui/src/org/argeo/suite/ui/widgets/TreeOrSearchArea.java b/core/org.argeo.suite.ui/src/org/argeo/suite/ui/widgets/TreeOrSearchArea.java
new file mode 100644 (file)
index 0000000..3434ed5
--- /dev/null
@@ -0,0 +1,74 @@
+package org.argeo.suite.ui.widgets;
+
+import org.argeo.cms.ui.util.CmsUiUtils;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Displays a tree by default, which becomes a list if the search text field is
+ * used.
+ */
+public class TreeOrSearchArea extends Composite {
+       private static final long serialVersionUID = -1302546480076719532L;
+
+       private Text searchT;
+       private StackLayout bodyLayout;
+
+       private TreeViewer treeViewer;
+       private TreeViewer searchResultsViewer;
+
+       public TreeOrSearchArea(Composite parent, int style) {
+               super(parent, style);
+               createUi(this);
+       }
+
+       protected void createUi(Composite parent) {
+               parent.setLayout(new GridLayout());
+               Composite searchC = new Composite(parent, SWT.NONE);
+               searchC.setLayout(new GridLayout());
+               searchC.setLayoutData(CmsUiUtils.fillWidth());
+               createSearchUi(searchC);
+
+               Composite bodyC = new Composite(parent, SWT.NONE);
+               bodyC.setLayoutData(CmsUiUtils.fillAll());
+               bodyLayout = new StackLayout();
+               bodyC.setLayout(bodyLayout);
+               Composite treeC = new Composite(bodyC, SWT.NONE);
+               createTreeUi(treeC);
+               Composite searchResultsC = new Composite(bodyC, SWT.NONE);
+               createSearchResultsUi(searchResultsC);
+
+               bodyLayout.topControl = treeC;
+       }
+
+       protected void createSearchUi(Composite parent) {
+               parent.setLayout(CmsUiUtils.noSpaceGridLayout());
+               searchT = new Text(parent, SWT.MULTI | SWT.BORDER);
+               searchT.setLayoutData(CmsUiUtils.fillWidth());
+       }
+
+       protected void createTreeUi(Composite parent) {
+               parent.setLayout(CmsUiUtils.noSpaceGridLayout());
+               treeViewer = new TreeViewer(parent);
+               treeViewer.getTree().setLayoutData(CmsUiUtils.fillAll());
+       }
+
+       protected void createSearchResultsUi(Composite parent) {
+               parent.setLayout(CmsUiUtils.noSpaceGridLayout());
+               searchResultsViewer = new TreeViewer(parent);
+               searchResultsViewer.getTree().setLayoutData(CmsUiUtils.fillAll());
+       }
+
+       public TreeViewer getTreeViewer() {
+               return treeViewer;
+       }
+
+       public TreeViewer getSearchResultsViewer() {
+               return searchResultsViewer;
+       }
+
+}
diff --git a/library/org.argeo.documents.ui/config/documentsLayer.properties b/library/org.argeo.documents.ui/config/documentsLayer.properties
deleted file mode 100644 (file)
index 78382a6..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-service.pid=argeo.documents.ui.documentsLayer
-
-title=%content
-icon=documents
-
-entity.type=nt:folder
diff --git a/library/org.argeo.documents.ui/config/entryArea.properties b/library/org.argeo.documents.ui/config/entryArea.properties
deleted file mode 100644 (file)
index 43b08f0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-service.pid=argeo.documents.ui.entryArea
similarity index 95%
rename from library/org.argeo.documents.ui/.project
rename to library/org.argeo.library.ui/.project
index c046a7d544091d70957487d4ac9805ecf31e05c8..6aa2010b994fa7e8c6d84b0c913489758d8b9067 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-       <name>org.argeo.documents.ui</name>
+       <name>org.argeo.library.ui</name>
        <comment></comment>
        <projects>
        </projects>
diff --git a/library/org.argeo.library.ui/OSGI-INF/contentEntryArea.xml b/library/org.argeo.library.ui/OSGI-INF/contentEntryArea.xml
new file mode 100644 (file)
index 0000000..0b5646e
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+   <implementation class="org.argeo.library.ui.ContentEntryArea"/>
+   <service>
+      <provide interface="org.argeo.cms.ui.CmsUiProvider"/>
+   </service>
+   <properties entry="config/contentEntryArea.properties"/>
+</scr:component>
similarity index 62%
rename from library/org.argeo.documents.ui/OSGI-INF/documentsLayer.xml
rename to library/org.argeo.library.ui/OSGI-INF/contentLayer.xml
index 38332375fef5c3ff3355ca6e8ed77260b762127e..0dae1af26d0bc7d3120d634dc9e90931dd1faba4 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="Documents Layer">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
    <implementation class="org.argeo.suite.ui.DefaultEditionLayer"/>
    <service>
       <provide interface="org.argeo.suite.ui.SuiteLayer"/>
    </service>
-   <reference bind="setEntryArea" cardinality="1..1" interface="org.argeo.cms.ui.CmsUiProvider" name="CmsUiProvider" policy="dynamic" target="(service.pid=argeo.documents.ui.entryArea)"/>
-   <properties entry="config/documentsLayer.properties"/>
+   <reference bind="setEntryArea" cardinality="1..1" interface="org.argeo.cms.ui.CmsUiProvider" name="CmsUiProvider" policy="dynamic" target="(service.pid=argeo.library.ui.contentEntryArea)"/>
+   <properties entry="config/contentLayer.properties"/>
 </scr:component>
similarity index 86%
rename from library/org.argeo.documents.ui/OSGI-INF/documentsFolder.xml
rename to library/org.argeo.library.ui/OSGI-INF/documentsFolder.xml
index a7c2e4b0f04c4fa702cd04030f7d98a604a1d305..d7d71f0b42a383d13d519291792830b18e163489 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="Documents Folder">
-   <implementation class="org.argeo.documents.ui.DocumentsFolderUiProvider"/>
+   <implementation class="org.argeo.library.ui.DocumentsFolderUiProvider"/>
    <service>
       <provide interface="org.argeo.cms.ui.CmsUiProvider"/>
    </service>
similarity index 68%
rename from library/org.argeo.documents.ui/OSGI-INF/entryArea.xml
rename to library/org.argeo.library.ui/OSGI-INF/fsEntryArea.xml
index 50fcfe36d09be46fce8727c7bce8c6e8038e1f01..540f4ff946317cd4ffc830e19bf4d350a3a09c66 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="Documents Entry Area">
-   <implementation class="org.argeo.documents.ui.DocumentsTreeUiProvider"/>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+   <implementation class="org.argeo.library.ui.DocumentsTreeUiProvider"/>
    <service>
       <provide interface="org.argeo.cms.ui.CmsUiProvider"/>
    </service>
-   <properties entry="config/entryArea.properties"/>
+   <properties entry="config/contentEntryArea.properties"/>
    <reference bind="setNodeFileSystemProvider" cardinality="1..1" interface="java.nio.file.spi.FileSystemProvider" name="FileSystemProvider" policy="dynamic" target="(service.pid=org.argeo.api.fsProvider)"/>
    <reference bind="setRepository" cardinality="1..1" interface="javax.jcr.Repository" name="Repository" policy="static" target="(cn=ego)"/>
 </scr:component>
similarity index 52%
rename from library/org.argeo.documents.ui/bnd.bnd
rename to library/org.argeo.library.ui/bnd.bnd
index 9a3a99c8de112a84cf55ea407fbe899a4ec4dc77..71f461825e79a55a3cb6f9c218acc2bb0f5a966e 100644 (file)
@@ -1,10 +1,12 @@
 Service-Component:\
-OSGI-INF/entryArea.xml,\
-OSGI-INF/documentsLayer.xml,\
+OSGI-INF/contentEntryArea.xml,\
+OSGI-INF/fsEntryArea.xml,\
+OSGI-INF/contentLayer.xml,\
 OSGI-INF/documentsFolder.xml
 
 Import-Package:\
 org.eclipse.swt,\
+javax.jcr.nodetype,\
 org.argeo.api,\
 org.argeo.suite.ui,\
 *
\ No newline at end of file
similarity index 76%
rename from library/org.argeo.documents.ui/build.properties
rename to library/org.argeo.library.ui/build.properties
index 0a508e270ce4acb26d58d10fb210a9f38bd3b38c..0859c527436c43d4082519efaa7111c79964b291 100644 (file)
@@ -2,6 +2,6 @@ output.. = bin/
 bin.includes = META-INF/,\
                .,\
                OSGI-INF/,\
-               OSGI-INF/documentsLayer.xml,\
+               OSGI-INF/contentLayer.xml,\
                OSGI-INF/documentsFolder.xml
 source.. = src/
diff --git a/library/org.argeo.library.ui/config/contentEntryArea.properties b/library/org.argeo.library.ui/config/contentEntryArea.properties
new file mode 100644 (file)
index 0000000..855fe97
--- /dev/null
@@ -0,0 +1 @@
+service.pid=argeo.library.ui.contentEntryArea
diff --git a/library/org.argeo.library.ui/config/contentLayer.properties b/library/org.argeo.library.ui/config/contentLayer.properties
new file mode 100644 (file)
index 0000000..ad7b10e
--- /dev/null
@@ -0,0 +1,6 @@
+service.pid=argeo.library.ui.contentLayer
+
+title=%content
+icon=documents
+
+entity.type=nt:folder,entity:space
diff --git a/library/org.argeo.library.ui/config/fsEntryArea.properties b/library/org.argeo.library.ui/config/fsEntryArea.properties
new file mode 100644 (file)
index 0000000..0bceaf0
--- /dev/null
@@ -0,0 +1 @@
+service.pid=argeo.library.ui.fsEntryArea
similarity index 95%
rename from library/org.argeo.documents.ui/pom.xml
rename to library/org.argeo.library.ui/pom.xml
index 2c59ff32c35c2039f502325a56a0236b1e862e47..048dd4a515a3755cff4a784deb80025fce3af64e 100644 (file)
@@ -7,7 +7,7 @@
                <version>2.3.1-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
-       <artifactId>org.argeo.documents.ui</artifactId>
+       <artifactId>org.argeo.library.ui</artifactId>
        <name>Documents UI</name>
        <packaging>jar</packaging>
        <dependencies>
diff --git a/library/org.argeo.library.ui/src/org/argeo/library/ui/ContentEntryArea.java b/library/org.argeo.library.ui/src/org/argeo/library/ui/ContentEntryArea.java
new file mode 100644 (file)
index 0000000..4c8b041
--- /dev/null
@@ -0,0 +1,103 @@
+package org.argeo.library.ui;
+
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.Query;
+
+import org.argeo.cms.ui.CmsUiProvider;
+import org.argeo.cms.ui.util.CmsUiUtils;
+import org.argeo.entity.EntityType;
+import org.argeo.jcr.Jcr;
+import org.argeo.jcr.JcrException;
+import org.argeo.suite.ui.widgets.TreeOrSearchArea;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+public class ContentEntryArea implements CmsUiProvider {
+
+       @Override
+       public Control createUi(Composite parent, Node context) throws RepositoryException {
+               parent.setLayout(new GridLayout());
+               Ui ui = new Ui(parent, SWT.NONE);
+               ui.setLayoutData(CmsUiUtils.fillAll());
+
+               ui.getTreeViewer().setContentProvider(new SpacesContentProvider());
+               ui.getTreeViewer().setInput(context.getSession());
+               return ui;
+       }
+
+       protected boolean isLeaf(Node node) {
+               return Jcr.isNodeType(node, EntityType.entity.get()) || Jcr.isNodeType(node, NodeType.NT_FILE);
+       }
+
+       class Ui extends TreeOrSearchArea {
+
+               public Ui(Composite parent, int style) {
+                       super(parent, style);
+               }
+
+       }
+
+       class SpacesContentProvider implements ITreeContentProvider {
+
+               @Override
+               public Object[] getElements(Object inputElement) {
+                       Session session = (Session) inputElement;
+                       try {
+                               Query query = session.getWorkspace().getQueryManager()
+                                               .createQuery("SELECT * FROM [" + EntityType.space.get() + "]", Query.JCR_SQL2);
+                               NodeIterator spacesIt = query.execute().getNodes();
+                               SortedMap<String, Node> map = new TreeMap<>();
+                               while (spacesIt.hasNext()) {
+                                       Node space = spacesIt.nextNode();
+                                       String path = space.getPath();
+                                       map.put(path, space);
+                               }
+                               return map.values().toArray();
+                       } catch (RepositoryException e) {
+                               throw new JcrException(e);
+                       }
+               }
+
+               @Override
+               public Object[] getChildren(Object parentElement) {
+                       Node parent = (Node) parentElement;
+                       if (isLeaf(parent))
+                               return null;
+                       return Jcr.getNodes(parent).toArray();
+               }
+
+               @Override
+               public Object getParent(Object element) {
+                       Node node = (Node) element;
+                       return Jcr.getParent(node);
+               }
+
+               @Override
+               public boolean hasChildren(Object element) {
+                       Node node = (Node) element;
+                       return !isLeaf(node);
+               }
+
+               @Override
+               public void dispose() {
+               }
+
+               @Override
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+       }
+
+}
similarity index 90%
rename from library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsContextMenu.java
rename to library/org.argeo.library.ui/src/org/argeo/library/ui/DocumentsContextMenu.java
index 3757dc7c197b8563a96ecc30de5373fb1a486dc0..03de2514131690415885b109bebb8a0394f4ccc5 100644 (file)
@@ -1,12 +1,12 @@
-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;
+package org.argeo.library.ui;
+
+import static org.argeo.library.ui.DocumentsUiService.ACTION_ID_BOOKMARK_FOLDER;
+import static org.argeo.library.ui.DocumentsUiService.ACTION_ID_CREATE_FOLDER;
+import static org.argeo.library.ui.DocumentsUiService.ACTION_ID_DELETE;
+import static org.argeo.library.ui.DocumentsUiService.ACTION_ID_DOWNLOAD_FOLDER;
+import static org.argeo.library.ui.DocumentsUiService.ACTION_ID_RENAME;
+import static org.argeo.library.ui.DocumentsUiService.ACTION_ID_SHARE_FOLDER;
+import static org.argeo.library.ui.DocumentsUiService.ACTION_ID_UPLOAD_FILE;
 
 import java.nio.file.Files;
 import java.nio.file.Path;
similarity index 99%
rename from library/org.argeo.documents.ui/src/org/argeo/documents/ui/DocumentsUiService.java
rename to library/org.argeo.library.ui/src/org/argeo/library/ui/DocumentsUiService.java
index a0fa7824b3c16f5051dd9ee7414644d3eeed6bf9..ad13d28863130992148881fa7174afae7a261008 100644 (file)
@@ -1,4 +1,4 @@
-package org.argeo.documents.ui;
+package org.argeo.library.ui;
 
 import static org.argeo.cms.ui.dialogs.CmsMessageDialog.openConfirm;
 import static org.argeo.cms.ui.dialogs.CmsMessageDialog.openError;
index ea3ef63ea4395507d25c3de28695f60f2faebdf3..ea051de789e313d618af538006c9d6c8baf882d6 100644 (file)
@@ -11,6 +11,6 @@
        <name>Argeo Library Components</name>
        <packaging>pom</packaging>
        <modules>
-               <module>org.argeo.documents.ui</module>
+               <module>org.argeo.library.ui</module>
        </modules>
 </project>