Introduce examples.
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 1 Jan 2020 11:12:00 +0000 (12:12 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 1 Jan 2020 11:12:00 +0000 (12:12 +0100)
21 files changed:
demo/cms-e4-rap.properties
example/org.argeo.example.cms.e4/.classpath [new file with mode: 0644]
example/org.argeo.example.cms.e4/.gitignore [new file with mode: 0644]
example/org.argeo.example.cms.e4/.project [new file with mode: 0644]
example/org.argeo.example.cms.e4/META-INF/.gitignore [new file with mode: 0644]
example/org.argeo.example.cms.e4/OSGI-INF/cms-example-rap.xml [new file with mode: 0644]
example/org.argeo.example.cms.e4/bnd.bnd [new file with mode: 0644]
example/org.argeo.example.cms.e4/build.properties [new file with mode: 0644]
example/org.argeo.example.cms.e4/e4xmi/text.e4xmi [new file with mode: 0644]
example/org.argeo.example.cms.e4/pom.xml [new file with mode: 0644]
example/org.argeo.example.data/.project [new file with mode: 0644]
example/org.argeo.example.data/META-INF/.gitignore [new file with mode: 0644]
example/org.argeo.example.data/build.properties [new file with mode: 0644]
example/org.argeo.example.data/text/LoremIpsum-flat.dbk.xml [new file with mode: 0644]
example/org.argeo.example.data/text/empty.dbk.xml [new file with mode: 0644]
example/pom.xml [new file with mode: 0644]
org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java
org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/SimpleRapE4App.java [new file with mode: 0644]
org.argeo.cms.e4/src/org/argeo/cms/e4/parts/CmsDocBookEditor.java
org.argeo.cms.ui/src/org/argeo/cms/viewers/AbstractPageViewer.java
pom.xml

index e8f2458401f2b885dec81a6a7c0ac8ef6893f2da..785b4b6201c135eae6014b13e2f5a0d75aca9ddd 100644 (file)
@@ -14,6 +14,9 @@ org.argeo.cms
 argeo.osgi.start.5.node=\
 org.argeo.cms.e4.rap
 
+argeo.osgi.start.5.example=\
+org.argeo.example.cms.e4
+
 # Local
 argeo.node.repo.type=h2
 org.osgi.service.http.port=7070
diff --git a/example/org.argeo.example.cms.e4/.classpath b/example/org.argeo.example.cms.e4/.classpath
new file mode 100644 (file)
index 0000000..e801ebf
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/example/org.argeo.example.cms.e4/.gitignore b/example/org.argeo.example.cms.e4/.gitignore
new file mode 100644 (file)
index 0000000..09e3bc9
--- /dev/null
@@ -0,0 +1,2 @@
+/bin/
+/target/
diff --git a/example/org.argeo.example.cms.e4/.project b/example/org.argeo.example.cms.e4/.project
new file mode 100644 (file)
index 0000000..a5d18dd
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.example.cms.e4</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ds.core.builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/example/org.argeo.example.cms.e4/META-INF/.gitignore b/example/org.argeo.example.cms.e4/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/example/org.argeo.example.cms.e4/OSGI-INF/cms-example-rap.xml b/example/org.argeo.example.cms.e4/OSGI-INF/cms-example-rap.xml
new file mode 100644 (file)
index 0000000..4fb099a
--- /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" activate="init" deactivate="destroy">
+   <implementation class="org.argeo.cms.e4.rap.SimpleRapE4App"/>
+   <service>
+      <provide interface="org.eclipse.rap.rwt.application.ApplicationConfiguration"/>
+   </service>
+   <property name="contextName" type="String" value="cms/example"/>
+</scr:component>
diff --git a/example/org.argeo.example.cms.e4/bnd.bnd b/example/org.argeo.example.cms.e4/bnd.bnd
new file mode 100644 (file)
index 0000000..ffcf95d
--- /dev/null
@@ -0,0 +1,4 @@
+
+Service-Component: OSGI-INF/cms-example-rap.xml
+
+Import-Package: org.argeo.cms.e4.rap,*
\ No newline at end of file
diff --git a/example/org.argeo.example.cms.e4/build.properties b/example/org.argeo.example.cms.e4/build.properties
new file mode 100644 (file)
index 0000000..92a7ee7
--- /dev/null
@@ -0,0 +1,5 @@
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               OSGI-INF/cms-example-rap.xml
+source.. = src/
diff --git a/example/org.argeo.example.cms.e4/e4xmi/text.e4xmi b/example/org.argeo.example.cms.e4/e4xmi/text.e4xmi
new file mode 100644 (file)
index 0000000..1ecd7fc
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ASCII"?>
+<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_PjHLwMb4EeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.application">
+  <children xsi:type="basic:TrimmedWindow" xmi:id="_QnyU0Mb4EeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.trimmedwindow.0">
+    <children xsi:type="basic:PartStack" xmi:id="_V9EXcMb4EeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.partstack.0">
+      <children xsi:type="basic:Part" xmi:id="_RVKlIMctEeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.part.docbook" contributionURI="bundleclass://org.argeo.cms.e4/org.argeo.cms.e4.parts.CmsDocBookEditor" label="DocBook">
+        <properties key="defaultContentUri" value="platform:/plugin/org.argeo.example.data/text/LoremIpsum-flat.dbk.xml"/>
+        <toolbar xmi:id="_TANxsMctEeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.toolbar.1">
+          <children xsi:type="menu:HandledToolItem" xmi:id="_alIUoMctEeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.handledtoolitem.save" label="Save" command="_vsxg8McmEeiIG7Bq51Btuw"/>
+        </toolbar>
+      </children>
+      <children xsi:type="basic:Part" xmi:id="_fPCGgMcCEeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.part.texteditor" contributionURI="bundleclass://org.argeo.cms.e4/org.argeo.cms.e4.parts.CmsTextEditor" label="Text Editor">
+        <toolbar xmi:id="_jlPucMcmEeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.toolbar.0">
+          <children xsi:type="menu:HandledToolItem" xmi:id="_r3TEMMcmEeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.handledtoolitem.0" command="_vsxg8McmEeiIG7Bq51Btuw"/>
+        </toolbar>
+      </children>
+      <children xsi:type="basic:Part" xmi:id="_cIlegMb4EeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.part.htmleditor" contributionURI="bundleclass://org.argeo.cms.e4.rap/org.argeo.cms.e4.rap.parts.HtmlEditor" label="HTML Editor"/>
+    </children>
+  </children>
+  <handlers xmi:id="_zqabMMcmEeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.handler.0" contributionURI="bundleclass://org.argeo.cms.e4/org.argeo.cms.e4.handlers.SavePart" command="_vsxg8McmEeiIG7Bq51Btuw"/>
+  <commands xmi:id="_vsxg8McmEeiIG7Bq51Btuw" elementId="org.argeo.cms.e4.command.save" commandName="Save"/>
+  <addons xmi:id="_PjHLwcb4EeiIG7Bq51Btuw" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
+  <addons xmi:id="_PjHLwsb4EeiIG7Bq51Btuw" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
+  <addons xmi:id="_PjHLw8b4EeiIG7Bq51Btuw" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
+  <addons xmi:id="_PjHLxMb4EeiIG7Bq51Btuw" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/>
+  <addons xmi:id="_PjHLxcb4EeiIG7Bq51Btuw" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/>
+  <addons xmi:id="_PjHLxsb4EeiIG7Bq51Btuw" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/>
+  <addons xmi:id="_PjHLx8b4EeiIG7Bq51Btuw" elementId="org.eclipse.e4.ui.workbench.handler.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon"/>
+</application:Application>
diff --git a/example/org.argeo.example.cms.e4/pom.xml b/example/org.argeo.example.cms.e4/pom.xml
new file mode 100644 (file)
index 0000000..ec08721
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.commons.example</groupId>
+               <artifactId>argeo-commons-example</artifactId>
+               <version>2.1.85-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.example.cms.e4</artifactId>
+       <name>Example CMS E4</name>
+       <packaging>jar</packaging>
+       <dependencies>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.cms.ui</artifactId>
+                       <version>2.1.85-SNAPSHOT</version>
+               </dependency>
+
+               <!-- UI -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.eclipse.ui.rap</artifactId>
+                       <version>2.1.85-SNAPSHOT</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>argeo-tp-rap-e4</artifactId>
+                       <version>${version.argeo-tp}</version>
+                       <type>pom</type>
+                       <scope>provided</scope>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/example/org.argeo.example.data/.project b/example/org.argeo.example.data/.project
new file mode 100644 (file)
index 0000000..3ead5b0
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.example.data</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/example/org.argeo.example.data/META-INF/.gitignore b/example/org.argeo.example.data/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/example/org.argeo.example.data/build.properties b/example/org.argeo.example.data/build.properties
new file mode 100644 (file)
index 0000000..5f22cdd
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = META-INF/
diff --git a/example/org.argeo.example.data/text/LoremIpsum-flat.dbk.xml b/example/org.argeo.example.data/text/LoremIpsum-flat.dbk.xml
new file mode 100644 (file)
index 0000000..a851f3d
--- /dev/null
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<article xmlns="http://docbook.org/ns/docbook">
+       <para>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus
+               sed dolor nisl. Nullam vitae odio sagittis, cursus urna ut, fringilla
+               dui. Nunc aliquet laoreet ligula ut lobortis. Suspendisse at elit sed
+               ipsum volutpat aliquet ut ac lacus. Cras eget vulputate dolor, sed
+               faucibus ante. Donec sagittis, augue sed consectetur viverra, dolor
+               nisi efficitur erat, non pellentesque purus libero ac tortor. Aenean
+               ac augue eget lectus vulputate ullamcorper. Cras a erat massa. Nam
+               malesuada tortor vel ullamcorper interdum. Quisque lacinia tristique
+               quam, quis tristique mauris pellentesque eu. Maecenas sit amet dui sed
+               nulla vehicula vehicula. Sed nibh sapien, rutrum vestibulum diam nec,
+               vulputate volutpat ipsum. Class aptent taciti sociosqu ad litora
+               torquent per conubia nostra, per inceptos himenaeos.
+       </para>
+       <para>Donec vitae sodales turpis, et congue nisl. Donec a scelerisque
+               justo. Quisque posuere bibendum nibh, ac gravida nunc sollicitudin
+               ultricies. Maecenas blandit urna in massa luctus placerat. Nam ornare
+               orci quis ligula dignissim placerat. Sed quis elit ultrices, volutpat
+               est vitae, mollis turpis. Donec vel efficitur urna. Vivamus sit amet
+               vehicula lacus. Donec nec dui erat. Proin congue ac odio ut congue.
+               Nunc porta dui ac leo accumsan, non rutrum enim luctus. Sed semper
+               risus et augue pretium, sit amet viverra eros placerat. Sed in
+               lobortis nulla. Donec consequat, nunc egestas blandit imperdiet,
+               lectus felis mattis est, quis lobortis magna augue non odio.
+               Vestibulum vel mattis nibh, non facilisis orci.
+       </para>
+       <para>Proin id leo est. Quisque laoreet molestie sodales. Phasellus
+               volutpat elit metus, a placerat tellus hendrerit vitae. Aenean quis
+               odio pharetra, consectetur tortor et, fermentum dolor. Mauris vel
+               auctor enim. Donec leo nulla, finibus id lectus nec, dictum gravida
+               quam. Sed scelerisque leo ligula, sit amet viverra mauris convallis
+               posuere. Mauris pulvinar, est id lacinia cursus, lacus nisi vehicula
+               erat, nec ornare ante dolor auctor mauris. Quisque sed congue elit.
+       </para>
+       <para>Aenean porttitor eget purus a cursus. Maecenas viverra libero
+               tellus, eget imperdiet dui suscipit at. Cras vel felis in ante
+               fringilla suscipit. Phasellus ornare arcu ligula, sed venenatis turpis
+               commodo quis. Integer tortor nisl, faucibus mollis nulla sed, rhoncus
+               elementum leo. Vestibulum ante ipsum primis in faucibus orci luctus et
+               ultrices posuere cubilia Curae; Praesent placerat ullamcorper commodo.
+               Morbi vel mollis lectus. Suspendisse potenti. Donec quis cursus
+               tortor. Etiam turpis tellus, vehicula a urna et, convallis semper
+               lectus. Phasellus fermentum est ac euismod congue.
+       </para>
+       <para>Vivamus non nisl vel ipsum porta molestie pharetra et mi. Sed
+               volutpat, mauris et euismod ultricies, turpis ex maximus augue, nec
+               tempus neque elit non velit. Mauris elementum, urna eget luctus
+               molestie, nunc sapien molestie odio, vel vehicula dolor massa at eros.
+               Etiam magna dui, pulvinar at purus non, suscipit imperdiet mi.
+               Vestibulum nec quam risus. Integer dui sapien, tincidunt id augue et,
+               iaculis porttitor felis. Donec quis enim vel tellus euismod molestie.
+               Fusce venenatis nunc nec dui molestie, sit amet porttitor elit
+               feugiat. Quisque eu odio placerat, maximus lectus at, fringilla dolor.
+               Nam a mollis purus. Curabitur eu lorem nisl. Suspendisse enim eros,
+               rutrum quis egestas ac, fringilla sollicitudin velit. Praesent
+               faucibus neque eu ligula pellentesque porta in in nibh. Ut vitae
+               mauris ac ante pharetra blandit non in dui. Ut euismod quam et diam
+               imperdiet, eu mollis ex pulvinar.
+       </para>
+</article>
\ No newline at end of file
diff --git a/example/org.argeo.example.data/text/empty.dbk.xml b/example/org.argeo.example.data/text/empty.dbk.xml
new file mode 100644 (file)
index 0000000..71c2624
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<article xml:id="empty" version="5.0"
+       xmlns="http://docbook.org/ns/docbook"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://docbook.org/ns/docbook https://docbook.org/xml/5.0/xsd/docbook.xsd">
+       <para></para>
+</article>
\ No newline at end of file
diff --git a/example/pom.xml b/example/pom.xml
new file mode 100644 (file)
index 0000000..3bb7342
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.commons</groupId>
+               <artifactId>argeo-commons</artifactId>
+               <version>2.1.85-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <groupId>org.argeo.commons.example</groupId>
+       <artifactId>argeo-commons-example</artifactId>
+       <name>Commons Example</name>
+       <packaging>pom</packaging>
+       <modules>
+               <module>org.argeo.example.cms.e4</module>
+       </modules>
+</project>
\ No newline at end of file
index c293f1ab02524b4516a5f9ca00c9935aeef6b9eb..8bf16a265c6665a3b1aaa22b613b654a306ae4c6 100644 (file)
@@ -10,6 +10,7 @@ import org.eclipse.rap.rwt.application.Application.OperationMode;
 import org.eclipse.rap.rwt.application.ApplicationConfiguration;
 import org.eclipse.rap.rwt.application.ExceptionHandler;
 import org.eclipse.rap.rwt.client.WebClient;
+import org.osgi.framework.BundleContext;
 
 /** Base class for CMS RAP applications. */
 public abstract class AbstractRapE4App implements ApplicationConfiguration {
@@ -17,7 +18,18 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration {
        private String path;
        private String lifeCycleUri = "bundleclass://org.argeo.cms.e4.rap/org.argeo.cms.e4.rap.CmsLoginLifecycle";
 
-       Map<String, String> baseProperties = new HashMap<String, String>();
+       private Map<String, String> baseProperties = new HashMap<String, String>();
+
+       private BundleContext bundleContext;
+       private final static String CONTEXT_NAME_PROPERTY = "contextName";
+       private String contextName;
+
+       /**
+        * To be overridden in order to add multiple entry points, directly or using
+        * {@link #addE4EntryPoint(Application, String, String, Map)}.
+        */
+       protected void addEntryPoints(Application application) {
+       }
 
        public void configure(Application application) {
                application.setExceptionHandler(new ExceptionHandler() {
@@ -35,14 +47,6 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration {
                }
        }
 
-       /**
-        * To be overridden in order to add multiple entry points, directly or using
-        * {@link #addE4EntryPoint(Application, String, String, Map)}.
-        */
-       protected void addEntryPoints(Application application) {
-
-       }
-
        protected Map<String, String> getBaseProperties() {
                return baseProperties;
        }
@@ -97,12 +101,28 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration {
                this.lifeCycleUri = lifeCycleUri;
        }
 
-       public void init(Map<String, Object> properties) {
+       protected BundleContext getBundleContext() {
+               return bundleContext;
+       }
+
+       protected String getContextName() {
+               return contextName;
+       }
+
+       public void init(BundleContext bundleContext, Map<String, Object> properties) {
+               this.bundleContext = bundleContext;
                for (String key : properties.keySet()) {
                        Object value = properties.get(key);
                        if (value != null)
                                baseProperties.put(key, value.toString());
                }
+
+               if (properties.containsKey(CONTEXT_NAME_PROPERTY)) {
+                       assert properties.get(CONTEXT_NAME_PROPERTY) != null;
+                       contextName = properties.get(CONTEXT_NAME_PROPERTY).toString();
+               } else {
+                       contextName = "<unknown context>";
+               }
        }
 
        public void destroy(Map<String, Object> properties) {
diff --git a/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/SimpleRapE4App.java b/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/SimpleRapE4App.java
new file mode 100644 (file)
index 0000000..12c4f63
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.cms.e4.rap;
+
+import java.util.Enumeration;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.rap.rwt.application.Application;
+import org.osgi.framework.Bundle;
+
+/** Simple RAP app which loads all e4xmi files. */
+public class SimpleRapE4App extends AbstractRapE4App {
+       private final static Log log = LogFactory.getLog(SimpleRapE4App.class);
+
+       private String baseE4xmi = "/e4xmi";
+
+       @Override
+       protected void addEntryPoints(Application application) {
+               Bundle bundle = getBundleContext().getBundle();
+               Enumeration<String> paths = bundle.getEntryPaths(baseE4xmi);
+               while (paths.hasMoreElements()) {
+                       String p = paths.nextElement();
+                       if (p.endsWith(".e4xmi")) {
+                               String e4xmiPath = bundle.getSymbolicName() + '/' + p;
+                               String name = '/' + FilenameUtils.removeExtension(FilenameUtils.getName(p));
+                               addE4EntryPoint(application, name, e4xmiPath, getBaseProperties());
+                               if (log.isDebugEnabled())
+                                       log.debug("Registered " + e4xmiPath + " as " + getContextName() + name);
+                       }
+               }
+       }
+
+}
index b39feab14ae0426201a67983fec87178708e806d..ae77e1e5b86925ab8938fe34b2b6275728e51925 100644 (file)
@@ -1,21 +1,27 @@
 package org.argeo.cms.e4.parts;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Map;
 import java.util.Observable;
 import java.util.Observer;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
+import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.Node;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
 
+import org.apache.commons.logging.Log;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.text.DocumentTextEditor;
 import org.argeo.cms.viewers.JcrVersionCmsEditable;
 import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.docbook.DocBookNames;
 import org.argeo.jcr.docbook.DocBookTypes;
 import org.eclipse.e4.ui.di.Persist;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
@@ -37,16 +43,41 @@ public class CmsDocBookEditor implements Observer {
        public void createUI(Composite parent) {
                try {
                        parent.setLayout(new GridLayout());
-                       session = repository.login();
-                       JcrUtils.loginOrCreateWorkspace(repository, "demo");
-                       Node textNode = JcrUtils.getOrAdd(session.getRootNode(), "article", DocBookTypes.ARTICLE);
-                       if (textNode.isCheckedOut())
-                               textNode.addMixin(NodeType.MIX_TITLE);
+                       // session = repository.login();
+                       session = JcrUtils.loginOrCreateWorkspace(repository, "example");
+//                     Node textNode = JcrUtils.getOrAdd(session.getRootNode(), "article", DocBookTypes.ARTICLE);
+//                     if (textNode.isCheckedOut())
+//                             textNode.addMixin(NodeType.MIX_TITLE);
+
+                       String textNodeName = "docbook";
+                       if (session.getRootNode().hasNode(textNodeName))
+                               session.getRootNode().getNode(textNodeName).remove();
+
+                       Node textNode = JcrUtils.getOrAdd(session.getRootNode(), textNodeName, DocBookTypes.BOOK);
+                       Map<String, String> properties = mpart.getProperties();
+                       String defaultContentUri = properties.get("defaultContentUri");
+                       if (textNode.hasNode(DocBookNames.DBK_ARTICLE))
+                               textNode.getNode(DocBookNames.DBK_ARTICLE).remove();
+                       if (defaultContentUri != null && !textNode.hasNode(DocBookNames.DBK_ARTICLE))
+                               try {
+                                       URL url = new URL(defaultContentUri);
+                                       try (InputStream in = url.openStream()) {
+                                               session.importXML(textNode.getPath(), in,
+                                                               ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
+                                       }
+                                       Node dbkNode = textNode.getNode(DocBookNames.DBK_ARTICLE);
+                                       if (dbkNode.isNodeType(DocBookTypes.ARTICLE))
+                                               System.out.println(dbkNode + " is an article");
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                               }
+
                        cmsEditable = new JcrVersionCmsEditable(textNode);
                        if (session.hasPendingChanges())
                                session.save();
                        cmsEditable.addObserver(this);
-                       DocumentTextEditor textEditor = new DocumentTextEditor(parent, SWT.NONE, textNode, cmsEditable);
+                       DocumentTextEditor textEditor = new DocumentTextEditor(parent, SWT.NONE,
+                                       textNode.getNode(DocBookNames.DBK_ARTICLE), cmsEditable);
                        mpart.setDirty(isDirty());
                } catch (RepositoryException e) {
                        throw new CmsException("Cannot create text editor", e);
index 492203b4483cce63f29a171135d6387d046a861f..eaaf4bc3f573cee88a2471040d2dfbfc24ae2017 100644 (file)
@@ -280,9 +280,9 @@ public abstract class AbstractPageViewer extends ContentViewer implements Observ
                if (e instanceof IllegalArgumentException)
                        if (e.getCause() instanceof SAXParseException)
                                eToLog = e.getCause();
-               log.error(eToLog.getMessage());
-               if (log.isTraceEnabled())
-                       log.trace("Full stack of " + eToLog.getMessage(), e);
+               log.error(eToLog.getMessage(), eToLog);
+//             if (log.isTraceEnabled())
+//                     log.trace("Full stack of " + eToLog.getMessage(), e);
                // TODO Light error notification popup
        }
 
diff --git a/pom.xml b/pom.xml
index 93900e68cfbeb59aca90f57d6f960cbda663f3b2..100105e4962755782a09da274b6166a77b75ffc3 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,8 @@
                <!-- Third Parties Extensions -->
                <module>org.argeo.ext.jackrabbit</module>
                <module>org.argeo.ext.equinox.jetty</module>
+               <!-- Example -->
+               <module>example</module>
                <!-- Legacy -->
                <module>legacy</module>
                <!-- Distribution -->