You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2023/03/02 07:21:20 UTC

[causeway] branch master updated: CAUSEWAY-3309: [Demo] flesh out DomainObjectLayoutXxxUiEvent

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/causeway.git


The following commit(s) were added to refs/heads/master by this push:
     new fa851c7e0d CAUSEWAY-3309: [Demo] flesh out DomainObjectLayoutXxxUiEvent
fa851c7e0d is described below

commit fa851c7e0dd43edd60921ceb3a206d5b52a74178
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Mar 2 08:21:14 2023 +0100

    CAUSEWAY-3309: [Demo] flesh out DomainObjectLayoutXxxUiEvent
---
 .../DomainObjectLayout/DomainObjectLayoutMenu.java |  8 ---
 .../objects/DomainObjectLayout/plural/.gitkeep     |  0
 .../DomainObjectLayoutPluralVm-description.adoc    |  7 ---
 .../plural/DomainObjectLayoutPluralVm.java         | 72 ----------------------
 .../plural/DomainObjectLayoutPluralVm.layout.xml   | 49 ---------------
 .../DomainObjectLayoutXxxUiEventService.java       | 68 ++++++++++++++++++++
 .../DomainObjectLayoutXxxUiEventVm-signature.svg   |  1 +
 .../xxxUiEvent/DomainObjectLayoutXxxUiEventVm.java | 14 ++++-
 8 files changed, 82 insertions(+), 137 deletions(-)

diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/DomainObjectLayoutMenu.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/DomainObjectLayoutMenu.java
index 5db65713c1..4d5343f807 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/DomainObjectLayoutMenu.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/DomainObjectLayoutMenu.java
@@ -36,7 +36,6 @@ import demoapp.dom.domain.objects.DomainObjectLayout.cssClassFa.DomainObjectLayo
 import demoapp.dom.domain.objects.DomainObjectLayout.describedAs.DomainObjectLayoutDescribedAsVm;
 import demoapp.dom.domain.objects.DomainObjectLayout.named.DomainObjectLayoutNamedVm;
 import demoapp.dom.domain.objects.DomainObjectLayout.paged.DomainObjectLayoutPagedVm;
-import demoapp.dom.domain.objects.DomainObjectLayout.plural.DomainObjectLayoutPluralVm;
 import demoapp.dom.domain.objects.DomainObjectLayout.tabledec.DomainObjectLayoutTableDecoratorVm;
 import demoapp.dom.domain.objects.DomainObjectLayout.xxxUiEvent.DomainObjectLayoutXxxUiEventVm;
 
@@ -92,13 +91,6 @@ public class DomainObjectLayoutMenu {
         return factoryService.viewModel(new DomainObjectLayoutPagedVm());
     }
 
-    @Action(semantics = SemanticsOf.SAFE)
-    @ActionLayout(cssClassFa="fa-signature",
-        describedAs = "Overrides plural form for the domain object's type, eg for irregular plurals")
-    public DomainObjectLayoutPluralVm plural(){
-        return factoryService.viewModel(new DomainObjectLayoutPluralVm());
-    }
-
     @Action(semantics = SemanticsOf.SAFE)
     @ActionLayout(cssClassFa="fa-solid fa-table-columns",
         describedAs = "Allows to specify a custom client side table renderer.")
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/.gitkeep b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/.gitkeep
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm-description.adoc
deleted file mode 100644
index db20be303a..0000000000
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm-description.adoc
+++ /dev/null
@@ -1,7 +0,0 @@
-: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 [...]
-
-The `plural` attribute ...
-
-TODO[ISIS-3309]
-Overrides plural form for the domain object's type, eg for irregular plurals
-
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm.java
deleted file mode 100644
index 75e364946f..0000000000
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *  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.domain.objects.DomainObjectLayout.plural;
-
-import java.util.List;
-import java.util.UUID;
-
-import javax.inject.Named;
-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.causeway.applib.annotation.Action;
-import org.apache.causeway.applib.annotation.DomainObject;
-import org.apache.causeway.applib.annotation.DomainObjectLayout;
-import org.apache.causeway.applib.annotation.Nature;
-import org.apache.causeway.applib.annotation.ObjectSupport;
-import org.apache.causeway.applib.annotation.Optionality;
-import org.apache.causeway.applib.annotation.Property;
-
-import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
-import lombok.Getter;
-import lombok.Setter;
-
-//tag::class[]
-@XmlRootElement(name = "root")
-@XmlType
-@XmlAccessorType(XmlAccessType.FIELD)
-@Named("demo.DomainObjectLayoutPluralVm")
-@DomainObject(
-        nature=Nature.VIEW_MODEL)
-@DomainObjectLayout(
-        // plural="Example Plural Name" TODO: DEPRECATED
-        )
-public class DomainObjectLayoutPluralVm implements HasAsciiDocDescription {
-
-    @ObjectSupport public String title() {
-        return "DomainObjectLayout#plural";
-    }
-
-    @Action
-    public List<DomainObjectLayoutPluralVm> standaloneTable() {
-        return List.of(
-                    new DomainObjectLayoutPluralVm(),
-                    new DomainObjectLayoutPluralVm());
-    }
-
-    @Property(optionality = Optionality.OPTIONAL)
-    @XmlElement(required = false)
-    @Getter @Setter
-    private String uuid = UUID.randomUUID().toString();
-
-}
-//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm.layout.xml
deleted file mode 100644
index b4f853de75..0000000000
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/plural/DomainObjectLayoutPluralVm.layout.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?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
-        xsi:schemaLocation="https://causeway.apache.org/applib/layout/component https://causeway.apache.org/applib/layout/component/component.xsd   https://causeway.apache.org/applib/layout/grid/bootstrap3 https://causeway.apache.org/applib/layout/grid/bootstrap3/bootstrap3.xsd"
-        xmlns:bs3="https://causeway.apache.org/applib/layout/grid/bootstrap3"
-        xmlns:cpt="https://causeway.apache.org/applib/layout/component"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
-	<bs3:row>
-		<bs3:col span="10" unreferencedActions="true">
-			<cpt:domainObject />
-		</bs3:col>
-		<bs3:col span="2">
-			<cpt:fieldSet name="" id="sources" />
-		</bs3:col>
-	</bs3:row>
-
-	<bs3:row>
-		<bs3:col span="6">
-			<cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
-		</bs3:col>
-		<bs3:col span="6">
-			<cpt:fieldSet name="Description" id="description" >
-				<cpt:action id="clearHints" position="PANEL" />
-				<cpt:action id="downloadLayoutXml"  position="PANEL_DROPDOWN"/>
-				<cpt:action id="rebuildMetamodel" position="PANEL"/>
-				<cpt:action id="downloadMetamodelXml"  position="PANEL_DROPDOWN"/>
-				<cpt:action id="inspectMetamodel"  position="PANEL_DROPDOWN"/>
-                <cpt:action id="recentCommands"  position="PANEL_DROPDOWN"/>
-				<cpt:action id="downloadJdoMetadata"  position="PANEL_DROPDOWN"/>
-				<cpt:action id="openRestApi" position="PANEL_DROPDOWN" />
-				<cpt:property id="description"/>
-			</cpt:fieldSet>
-		</bs3:col>
-	</bs3:row>
-	<bs3:row>
-		<bs3:col span="12" unreferencedCollections="true"/>
-	</bs3:row>
-
-</bs3:grid>
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventService.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventService.java
new file mode 100644
index 0000000000..0f3c7209f8
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventService.java
@@ -0,0 +1,68 @@
+/*
+ *  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.domain.objects.DomainObjectLayout.xxxUiEvent;
+
+import javax.inject.Named;
+
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Service;
+
+import lombok.val;
+import lombok.extern.log4j.Log4j2;
+
+//tag::class[]
+@Service
+@Named("demo.DomainObjectLayoutXxxUiEventService")
+@Log4j2
+public class DomainObjectLayoutXxxUiEventService {
+
+    @EventListener
+    void onTitleUiEvent(final DomainObjectLayoutXxxUiEventVm.TitleUiEvent titleUiEvent) {
+        val in = titleUiEvent.getTitle();
+        val out = "DomainObjectLayout-UiEvents";
+        titleUiEvent.setTitle(out);
+        log.info("titleUiEvent: {}->{}", in, out);
+    }
+
+    @EventListener
+    void onIconUiEvent(final DomainObjectLayoutXxxUiEventVm.IconUiEvent iconUiEvent) {
+        val in = iconUiEvent.getIconName();
+        val out = "signature";
+        iconUiEvent.setIconName(out);
+        log.info("iconUiEvent: {}->{}", in, out);
+    }
+
+    @EventListener
+    void onCssClassUiEvent(final DomainObjectLayoutXxxUiEventVm.CssClassUiEvent cssClassUiEvent) {
+        val in = cssClassUiEvent.getCssClass();
+        val out = "bg-dark";
+        cssClassUiEvent.setCssClass(out);
+        log.info("cssClassUiEvent: {}->{}", in, out);
+    }
+
+    @EventListener
+    void onLayoutUiEvent(final DomainObjectLayoutXxxUiEventVm.LayoutUiEvent layoutUiEvent) {
+        val in = layoutUiEvent.getLayout();
+        val out = "alternative";
+        layoutUiEvent.setLayout(out);
+        log.info("layoutUiEvent: {}->{}", in, out);
+    }
+
+}
+//end::class[]
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventVm-signature.svg b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventVm-signature.svg
new file mode 100644
index 0000000000..728c2470b8
--- /dev/null
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventVm-signature.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M192 128c0-17.7 14.3-32 32-32s32 14.3 32 32v7.8c0 27.7-2.4 55.3-7.1 82.5l-84.4 25.3c-40.6 12.2-68.4 49.6-68.4 92v71.9c0 40 32.5 72.5 72.5 72.5c26 0 50-13.9 62.9-36.5l13.9-24.3c26.8-47 46.5-97.7 58.4-150.5l94.4-28.3-12.5 37.5c-3.3 9.8-1.6 20.5 4.4 28.8s1 [...]
\ No newline at end of file
diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventVm.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventVm.java
index 57f9ab436e..881e55430c 100644
--- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventVm.java
+++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/xxxUiEvent/DomainObjectLayoutXxxUiEventVm.java
@@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.DomainObjectLayout;
 import org.apache.causeway.applib.annotation.Nature;
 import org.apache.causeway.applib.annotation.ObjectSupport;
 import org.apache.causeway.applib.annotation.Optionality;
@@ -42,10 +43,21 @@ import lombok.Setter;
 @Named("demo.DomainObjectLayoutXxxUiEventVm")
 @DomainObject(
         nature=Nature.VIEW_MODEL)
+@DomainObjectLayout(
+        titleUiEvent = DomainObjectLayoutXxxUiEventVm.TitleUiEvent.class,
+        iconUiEvent = DomainObjectLayoutXxxUiEventVm.IconUiEvent.class,
+        cssClassUiEvent = DomainObjectLayoutXxxUiEventVm.CssClassUiEvent.class,
+        layoutUiEvent = DomainObjectLayoutXxxUiEventVm.LayoutUiEvent.class
+        )
 public class DomainObjectLayoutXxxUiEventVm implements HasAsciiDocDescription {
 
+    public static class TitleUiEvent extends org.apache.causeway.applib.events.ui.TitleUiEvent<DomainObjectLayoutXxxUiEventVm> { }
+    public static class IconUiEvent extends org.apache.causeway.applib.events.ui.IconUiEvent<DomainObjectLayoutXxxUiEventVm> { }
+    public static class CssClassUiEvent extends org.apache.causeway.applib.events.ui.CssClassUiEvent<DomainObjectLayoutXxxUiEventVm> { }
+    public static class LayoutUiEvent extends org.apache.causeway.applib.events.ui.LayoutUiEvent<DomainObjectLayoutXxxUiEventVm> { }
+
     @ObjectSupport public String title() {
-        return "DomainObjectLayout#xxxUiEvent";
+        return "DomainObjectLayout#xxxUiEvent (should be overwritten by ui-title-event-listener)";
     }
 
     //TODO[CAUSEWAY-3309]