You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/03/16 08:10:21 UTC

[isis] branch master updated: ISIS-2308: Demo App: add featured type Markup

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new 79d1a76  ISIS-2308: Demo App: add featured type Markup
79d1a76 is described below

commit 79d1a766af177535b48d36628b3c2933b51b9259
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Mar 16 09:10:07 2020 +0100

    ISIS-2308: Demo App: add featured type Markup
---
 .../java/demoapp/dom/types/FeaturedTypesMenu.java  |  9 +++
 .../java/demoapp/dom/types/markup/MarkupDemo.adoc  |  5 ++
 .../java/demoapp/dom/types/markup/MarkupDemo.java  | 72 ++++++++++++++++++++++
 .../demoapp/dom/types/markup/MarkupDemo.layout.xml | 32 ++++++++++
 .../main/java/demoapp/dom/types/markup/markup.html | 17 +++++
 .../main/java/demoapp/webapp/menubars.layout.xml   |  3 +
 6 files changed, 138 insertions(+)

diff --git a/examples/demo/src/main/java/demoapp/dom/types/FeaturedTypesMenu.java b/examples/demo/src/main/java/demoapp/dom/types/FeaturedTypesMenu.java
index c063aba..f8f1b74 100644
--- a/examples/demo/src/main/java/demoapp/dom/types/FeaturedTypesMenu.java
+++ b/examples/demo/src/main/java/demoapp/dom/types/FeaturedTypesMenu.java
@@ -31,6 +31,7 @@ import lombok.val;
 
 import demoapp.dom.types.blob.BlobDemo;
 import demoapp.dom.types.clob.ClobDemo;
+import demoapp.dom.types.markup.MarkupDemo;
 import demoapp.dom.types.primitive.PrimitivesDemo;
 import demoapp.dom.types.text.TextDemo;
 import demoapp.dom.types.time.TemporalDemo;
@@ -89,5 +90,13 @@ public class FeaturedTypesMenu {
         demo.initDefaults();  
         return demo;
     }
+    
+    @Action
+    @ActionLayout(cssClassFa="fa-code")
+    public MarkupDemo markup(){
+        val demo = factoryService.viewModel(MarkupDemo.class);
+        demo.initDefaults();  
+        return demo;
+    }
 
 }
diff --git a/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.adoc b/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.adoc
new file mode 100644
index 0000000..82003e8
--- /dev/null
+++ b/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.adoc
@@ -0,0 +1,5 @@
+(since 1.)
+
+The framework supports Markup (plain HTML) values.
+
+See the text demo link:${SOURCES_DEMO}/demoapp/dom/types/markup[sources].
\ No newline at end of file
diff --git a/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.java b/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.java
new file mode 100644
index 0000000..1e57aa1
--- /dev/null
+++ b/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.java
@@ -0,0 +1,72 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package demoapp.dom.types.markup;
+
+import java.nio.charset.StandardCharsets;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.Editing;
+import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.annotation.Property;
+import org.apache.isis.applib.value.Markup;
+import org.apache.isis.core.commons.internal.base._Strings;
+import org.apache.isis.core.commons.internal.resources._Resources;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.val;
+import lombok.extern.log4j.Log4j2;
+
+import demoapp.dom.types.clob.ClobDemo;
+import demoapp.utils.DemoStub;
+
+@XmlRootElement(name = "Demo")
+@XmlType
+@XmlAccessorType(XmlAccessType.FIELD)
+@DomainObject(nature=Nature.VIEW_MODEL, objectType="demo.Markup", editing=Editing.ENABLED)
+@Log4j2
+public class MarkupDemo extends DemoStub {
+
+    @Override
+    public void initDefaults() {
+
+        log.info("MarkupDemo::initDefaults");
+
+        try {
+            val htmlSource = _Strings.read(_Resources.load(ClobDemo.class, "markup.html"), StandardCharsets.UTF_8);
+            markup = new Markup(htmlSource);
+        } catch (Exception e) {
+            log.error("failed to create Markup from file resource", e);
+        }
+        
+    }
+
+    // -- EDITABLE
+
+    @Property
+    @XmlElement @Getter @Setter private Markup markup;
+    
+    
+}
diff --git a/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.layout.xml b/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.layout.xml
new file mode 100644
index 0000000..795108b
--- /dev/null
+++ b/examples/demo/src/main/java/demoapp/dom/types/markup/MarkupDemo.layout.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<bs3:grid
+        xsi:schemaLocation="http://isis.apache.org/applib/layout/component http://isis.apache.org/applib/layout/component/component.xsd   http://isis.apache.org/applib/layout/grid/bootstrap3 http://isis.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd"
+        xmlns:bs3="http://isis.apache.org/applib/layout/grid/bootstrap3"
+        xmlns:cpt="http://isis.apache.org/applib/layout/component"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <bs3:row>
+        <bs3:col span="12" unreferencedActions="true">
+            <cpt:domainObject/>
+            <cpt:action id="clearHints"/>
+            <cpt:action id="downloadLayoutXml"/>
+            <cpt:action id="openRestApi"/>
+            <cpt:action id="rebuildMetamodel"/>
+        </bs3:col>
+    </bs3:row>
+
+    <bs3:row>
+        <bs3:col span="6">
+            <cpt:fieldSet name="Markup (plain HTML)" id="markup">
+                
+                <cpt:property id="markup"/>
+            </cpt:fieldSet>
+            
+        </bs3:col>
+        <bs3:col span="6" unreferencedCollections="true">
+         	<cpt:fieldSet name="Description" id="description" unreferencedProperties="true">
+                <cpt:property labelPosition="NONE" id="description"/>
+            </cpt:fieldSet>
+        </bs3:col>
+    </bs3:row>
+    
+</bs3:grid>
diff --git a/examples/demo/src/main/java/demoapp/dom/types/markup/markup.html b/examples/demo/src/main/java/demoapp/dom/types/markup/markup.html
new file mode 100644
index 0000000..bdc0b4b
--- /dev/null
+++ b/examples/demo/src/main/java/demoapp/dom/types/markup/markup.html
@@ -0,0 +1,17 @@
+<html>
+<body>
+
+	<a href="https://isis.apache.org/">Link Name</a> is a link
+
+	<h1>This is a Header</h1>
+
+	<h2>This is a Medium Header</h2>
+
+	<p>This is a new paragraph!</p>
+	<p>
+		<b>This is a new paragraph!</b> <br> 
+		<b><i>This is a new
+				sentence without a paragraph break, in bold italics.</i></b>
+	</p>
+</body>
+</html>
diff --git a/examples/demo/src/main/java/demoapp/webapp/menubars.layout.xml b/examples/demo/src/main/java/demoapp/webapp/menubars.layout.xml
index fc46fa7..885e3b7 100644
--- a/examples/demo/src/main/java/demoapp/webapp/menubars.layout.xml
+++ b/examples/demo/src/main/java/demoapp/webapp/menubars.layout.xml
@@ -26,6 +26,9 @@
                 <mb3:serviceAction objectType="demo.FeaturedTypesMenu" id="clobs">
                     <cpt:named>Clob Type</cpt:named>
                 </mb3:serviceAction>
+                <mb3:serviceAction objectType="demo.FeaturedTypesMenu" id="markup">
+                    <cpt:named>Markup Type (HTML)</cpt:named>
+                </mb3:serviceAction>
             </mb3:section>
         </mb3:menu>