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 2021/03/28 07:16:03 UTC

[isis] branch master updated: ISIS-2590: Demo: add MessageServiceDemo

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 4609bea  ISIS-2590: Demo: add MessageServiceDemo
4609bea is described below

commit 4609bea5bad6e4a16245a1f061eb5208eee0b5c0
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Mar 28 09:15:51 2021 +0200

    ISIS-2590: Demo: add MessageServiceDemo
---
 .../src/main/java/demoapp/dom/menubars.layout.xml  |  1 +
 .../demoapp/dom/services/core/ServicesMenu.java    | 11 ++--
 .../MessageServiceDemoVm-description.adoc          | 33 ++++++++++
 .../core/messageservice/MessageServiceDemoVm.java  | 72 ++++++++++++++++++++++
 .../messageservice/MessageServiceDemoVm.layout.xml | 38 ++++++++++++
 5 files changed, 150 insertions(+), 5 deletions(-)

diff --git a/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
index 8fb9897..e24e574 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
+++ b/examples/demo/domain/src/main/java/demoapp/dom/menubars.layout.xml
@@ -243,6 +243,7 @@ For latest we use: https://raw.githubusercontent.com/apache/isis/master/antora/s
                 <mb3:named>Core</mb3:named>
                 <mb3:serviceAction objectType="demo.ServicesMenu" id="errorReportingService" />
                 <mb3:serviceAction objectType="demo.ServicesMenu" id="eventBusService" />
+                <mb3:serviceAction objectType="demo.ServicesMenu" id="messageService" />
                 <mb3:serviceAction objectType="demo.ServicesMenu" id="wrapperFactory"/>
                 <mb3:serviceAction objectType="demo.ServicesMenu" id="xmlSnapshot"/>
             </mb3:section>
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java
index f72b7a5..f201385 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/ServicesMenu.java
@@ -33,6 +33,7 @@ import lombok.extern.log4j.Log4j2;
 
 import demoapp.dom.services.core.errorreportingservice.ErrorReportingServiceDemoVm;
 import demoapp.dom.services.core.eventbusservice.EventBusServiceDemoVm;
+import demoapp.dom.services.core.messageservice.MessageServiceDemoVm;
 import demoapp.dom.services.core.wrapperFactory.WrapperFactoryJdo;
 import demoapp.dom.services.core.wrapperFactory.WrapperFactoryJdoEntities;
 import demoapp.dom.services.core.xmlSnapshotService.XmlSnapshotParentVm;
@@ -53,7 +54,11 @@ public class ServicesMenu {
         return factoryService.viewModel(new EventBusServiceDemoVm());
     }
 
-
+    @Action
+    @ActionLayout(cssClassFa="fa-sticky-note")
+    public MessageServiceDemoVm messageService(){
+        return factoryService.viewModel(new MessageServiceDemoVm());
+    }
 
     @Action
     @ActionLayout(cssClassFa="fa-bomb")
@@ -61,16 +66,12 @@ public class ServicesMenu {
         return factoryService.viewModel(new ErrorReportingServiceDemoVm());
     }
 
-
-
     @Action(semantics = SemanticsOf.SAFE)
     @ActionLayout(cssClassFa="fa-gift", describedAs = "Formal object interactions + async")
     public WrapperFactoryJdo wrapperFactory(){
         return wrapperFactoryJdoEntities.first();
     }
 
-
-
     @Action(semantics = SemanticsOf.SAFE)
     @ActionLayout(cssClassFa="fa-camera", describedAs = "Snapshot object graphs as XML")
     public XmlSnapshotParentVm xmlSnapshot(){
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm-description.adoc
new file mode 100644
index 0000000..1d328ef
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm-description.adoc
@@ -0,0 +1,33 @@
+:Notice: 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 ag [...]
+
+(since 2.0)
+
+The framework supports 3 styles of messages that can be presented to the user within the browser.  
+
+[source,java]
+----
+class MyViewmodel {
+
+	@Action
+	public MyViewmodel infoMessage(){
+	    messageService.informUser("Info Message.");
+	    return this;
+	}
+	
+	@Action
+	public MyViewmodel warnMessage(){
+	    messageService.warnUser("Warning Message.");
+	    return this;
+	}
+	
+	@Action
+	public MyViewmodel errorMessage(){
+	    messageService.raiseError("Error Message.");
+	    return this;
+	}
+
+}
+----
+
+See the link:${SOURCES_DEMO}/demoapp/dom/services/messageservice[sources].
+
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.java b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.java
new file mode 100644
index 0000000..b7f2f65
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.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.services.core.messageservice;
+
+import javax.inject.Inject;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.ActionLayout;
+import org.apache.isis.applib.annotation.ActionLayout.Position;
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.services.message.MessageService;
+
+import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+
+@DomainObject(nature=Nature.VIEW_MODEL, objectType = "demo.MessageServiceDemoVm")
+public class MessageServiceDemoVm implements HasAsciiDocDescription {
+
+    @Inject private MessageService messageService;
+
+    public String title() {
+        return "Message Demo";
+    }
+
+    @ActionLayout(
+            describedAs = "Presents an info style message.",
+            cssClassFa="fa-sticky-note",
+            position = Position.PANEL)
+    @Action
+    public MessageServiceDemoVm infoMessage(){
+        messageService.informUser("Demo Info Message.");
+        return this;
+    }
+    
+    @ActionLayout(
+            describedAs = "Presents an warning style message.",
+            cssClassFa="fa-sticky-note",
+            position = Position.PANEL)
+    @Action
+    public MessageServiceDemoVm warnMessage(){
+        messageService.warnUser("Demo Warning Message.");
+        return this;
+    }
+    
+    @ActionLayout(
+            describedAs = "Presents an error style message.",
+            cssClassFa="fa-sticky-note",
+            position = Position.PANEL)
+    @Action
+    public MessageServiceDemoVm errorMessage(){
+        messageService.raiseError("Demo Error Message.");
+        return this;
+    }
+
+
+}
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.layout.xml
new file mode 100644
index 0000000..7180690
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/services/core/messageservice/MessageServiceDemoVm.layout.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- 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. -->
+<bs3:grid 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="5">
+         	<cpt:action id="infoMessage" cssClass="btn-info"/>
+         	<cpt:action id="warnMessage" cssClass="btn-warning"/>
+         	<cpt:action id="errorMessage" cssClass="btn-danger"/>
+        </bs3:col>
+        <bs3:col span="7" unreferencedCollections="true">
+			<cpt:fieldSet name="Description" id="description" unreferencedProperties="true">
+				<cpt:property labelPosition="NONE" id="description" />
+			</cpt:fieldSet>
+		</bs3:col>
+    </bs3:row>
+
+    
+</bs3:grid>