This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch CAUSEWAY-2485 in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 283d8ee2617f21599a045edf335f491775dc23a2 Author: danhaywood <[email protected]> AuthorDate: Tue Apr 4 16:28:21 2023 +0100 CAUSEWAY-2485: improves @DomainObjectLayout#cssClass --- .../src/main/java/demoapp/dom/DemoModuleJpa.java | 2 + ...ml => DomainObjectLayoutBookmarking.layout.xml} | 51 +++++++++++++--- ...ssPage.java => DomainObjectLayoutCssClass.java} | 44 ++++++++------ ...t.xml => DomainObjectLayoutCssClass.layout.xml} | 44 +++++++++++--- ...DomainObjectLayoutCssClassPage-description.adoc | 50 ++++++++++++++-- .../cssClass/DomainObjectLayoutCssClassPage.java | 10 ++-- .../DomainObjectLayoutCssClassPage.layout.xml | 9 +++ .../DomainObjectLayoutCssClassPage_objects.java | 30 ++++++++++ .../DomainObjectLayoutCssClassRepository.java | 26 ++++++++ .../DomainObjectLayoutCssClassSeeding.java | 38 ++++++++++++ ...inObjectLayoutCssClassPage.java => Status.java} | 17 ++---- ...DomainObjectLayoutCssClassJpa-description.adoc} | 12 ++-- .../jpa/DomainObjectLayoutCssClassJpa.java | 69 ++++++++++++++++++++++ .../jpa/DomainObjectLayoutCssClassJpaEntities.java | 55 +++++++++++++++++ .../src/main/java/demoapp/dom/menubars.layout.xml | 66 ++++++++++++--------- .../src/main/resources/static/css/application.css | 12 ++++ 16 files changed, 448 insertions(+), 87 deletions(-) diff --git a/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java b/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java index f04b4d2cfe..1c07881e93 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/DemoModuleJpa.java @@ -33,6 +33,7 @@ import demoapp.dom.domain.objects.DomainObject.nature.entity.jpa.DomainObjectNat import demoapp.dom.domain.objects.DomainObject.xxxLifecycleEvent.jpa.DomainObjectXxxLifecycleEventJpa; import demoapp.dom.domain.objects.DomainObjectLayout.bookmarking.jpa.DomainObjectLayoutBookmarkingChildJpa; import demoapp.dom.domain.objects.DomainObjectLayout.bookmarking.jpa.DomainObjectLayoutBookmarkingJpa; +import demoapp.dom.domain.objects.DomainObjectLayout.cssClass.jpa.DomainObjectLayoutCssClassJpa; import demoapp.dom.domain.objects.other.embedded.jpa.NumberConstantJpa; import demoapp.dom.domain.properties.Property.commandPublishing.jpa.PropertyCommandPublishingJpa; import demoapp.dom.domain.properties.Property.executionPublishing.jpa.PropertyExecutionPublishingJpa; @@ -110,6 +111,7 @@ import org.springframework.context.annotation.Profile; DomainObjectXxxLifecycleEventJpa.class, DomainObjectLayoutBookmarkingJpa.class, DomainObjectLayoutBookmarkingChildJpa.class, + DomainObjectLayoutCssClassJpa.class, CausewayBlobJpa.class, CausewayClobJpa.class, diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutBookmarking.layout.xml similarity index 60% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml copy to examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutBookmarking.layout.xml index b4f853de75..11b67b9496 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutBookmarking.layout.xml @@ -26,22 +26,59 @@ <bs3:row> <bs3:col span="6"> - <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/> + <bs3:tabGroup> + <bs3:tab name="General"> + <bs3:row> + <bs3:col span="12"> + <cpt:fieldSet name="General" id="general" > + <cpt:property id="name"/> + </cpt:fieldSet> + </bs3:col> + </bs3:row> + <bs3:row> + <bs3:col span="12"> + <cpt:collection id="children"> + <cpt:action id="addChildren"/> + </cpt:collection> + </bs3:col> + </bs3:row> + </bs3:tab> + <bs3:tab name="Metadata"> + <bs3:row> + <bs3:col span="12"> + <cpt:fieldSet name="Metadata" id="metadata" > + <cpt:property id="id"/> + <cpt:property id="logicalTypeName"/> + <cpt:property id="version"/> + </cpt:fieldSet> + </bs3:col> + </bs3:row> + </bs3:tab> + <bs3:tab name="Other"> + <bs3:row> + <bs3:col span="12"> + <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/> + </bs3:col> + </bs3:row> + </bs3:tab> + </bs3:tabGroup> </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="downloadLayout" 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="downloadMetamodelXml" position="PANEL_DROPDOWN"/> + <cpt:action id="downloadJdoMetamodel" position="PANEL_DROPDOWN"/> + <cpt:action id="recentCommands" position="PANEL_DROPDOWN"/> + <cpt:action id="recentExecutions" position="PANEL_DROPDOWN"/> + <cpt:action id="recentAuditTrailEntries" position="PANEL_DROPDOWN"/> + <cpt:action id="impersonateWithRoles" position="PANEL_DROPDOWN"/> <cpt:action id="openRestApi" position="PANEL_DROPDOWN" /> <cpt:property id="description"/> </cpt:fieldSet> - </bs3:col> - </bs3:row> + </bs3:col> </bs3:row> <bs3:row> <bs3:col span="12" unreferencedCollections="true"/> </bs3:row> diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClass.java similarity index 58% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java copy to examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClass.java index 8a701f8e71..a7232407e9 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClass.java @@ -19,32 +19,40 @@ package demoapp.dom.domain.objects.DomainObjectLayout.cssClass; import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription; +import demoapp.dom._infra.values.ValueHolder; +import demoapp.dom.domain.objects.DomainObjectLayout.bookmarking.DomainObjectLayoutBookmarkingChild; -import javax.inject.Named; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import java.util.Set; -import org.apache.causeway.applib.annotation.DomainObject; +import org.apache.causeway.applib.annotation.BookmarkPolicy; import org.apache.causeway.applib.annotation.DomainObjectLayout; -import org.apache.causeway.applib.annotation.Nature; -import org.apache.causeway.applib.annotation.ObjectSupport; //tag::class[] -@XmlRootElement(name = "root") -@XmlType -@XmlAccessorType(XmlAccessType.FIELD) -@Named("demo.DomainObjectLayoutCssClassVm") -@DomainObject( - nature=Nature.VIEW_MODEL) @DomainObjectLayout( - cssClass = "bg-dark") -public class DomainObjectLayoutCssClassPage implements HasAsciiDocDescription { + cssClass = "custom" // <.> +) +public abstract class DomainObjectLayoutCssClass +//end::class[] + implements + HasAsciiDocDescription, + ValueHolder<String> +//tag::class[] +{ + // ... +//end::class[] - @ObjectSupport public String title() { - return "DomainObjectLayout#cssClass"; + public String title() { + return value(); } + @Override + public String value() { + return getName(); + } + + public abstract String getName(); + public abstract void setName(String value); + +//tag::class[] } //end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClass.layout.xml similarity index 63% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml copy to examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClass.layout.xml index b4f853de75..1135efb565 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClass.layout.xml @@ -26,22 +26,52 @@ <bs3:row> <bs3:col span="6"> - <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/> + <bs3:tabGroup> + <bs3:tab name="General"> + <bs3:row> + <bs3:col span="12"> + <cpt:fieldSet name="General" id="general" > + <cpt:property id="name"/> + </cpt:fieldSet> + </bs3:col> + </bs3:row> + </bs3:tab> + <bs3:tab name="Metadata"> + <bs3:row> + <bs3:col span="12"> + <cpt:fieldSet name="Metadata" id="metadata" > + <cpt:property id="id"/> + <cpt:property id="logicalTypeName"/> + <cpt:property id="version"/> + </cpt:fieldSet> + </bs3:col> + </bs3:row> + </bs3:tab> + <bs3:tab name="Other"> + <bs3:row> + <bs3:col span="12"> + <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/> + </bs3:col> + </bs3:row> + </bs3:tab> + </bs3:tabGroup> </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="downloadLayout" 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="downloadMetamodelXml" position="PANEL_DROPDOWN"/> + <cpt:action id="downloadJdoMetamodel" position="PANEL_DROPDOWN"/> + <cpt:action id="recentCommands" position="PANEL_DROPDOWN"/> + <cpt:action id="recentExecutions" position="PANEL_DROPDOWN"/> + <cpt:action id="recentAuditTrailEntries" position="PANEL_DROPDOWN"/> + <cpt:action id="impersonateWithRoles" position="PANEL_DROPDOWN"/> <cpt:action id="openRestApi" position="PANEL_DROPDOWN" /> <cpt:property id="description"/> </cpt:fieldSet> - </bs3:col> - </bs3:row> + </bs3:col> </bs3:row> <bs3:row> <bs3:col span="12" unreferencedCollections="true"/> </bs3:row> diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage-description.adoc index c4e0b85fce..6c6a093fff 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage-description.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage-description.adoc @@ -1,8 +1,48 @@ :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 `cssClass` attribute indicates the CSS class -that a domain class (type) should have, -to allow more targeted styling in application.css. +The link:https://causeway.apache.org/refguide/2.0.0-SNAPSHOT/applib/index/annotation/DomainObjectLayout.html#cssclass[@DomainObjectLayout#cssClass] attribute indicates a CSS class which is added to the HTML wherever an instance of that domain class (type) is rendered. + +The idea is that corresponding styling is added to the `css/application.css` file that the framework's UI references in every response, so that certain domain classes -- perhaps the most important ones in the domain -- are always rendered with their own specific styling. + +=== How this demo works + +The collection on the left shows a list of entities where the `cssClass` attribute has been set to a value of "custom". + +Custom CSS in `application.css` shows that they are rendered in italics and also in green, quite differently from the lists you will see on other demo pages. + +Navigate into one of these entities and -- again -- the custom CSS is used to change the styling of their title as using italics and coloured green. + +In terms of code: + +* the attribute applied to the entity: ++ +[source,css] +.DomainObjectLayoutCssClass.java +---- +include::DomainObjectLayoutCssClass.java[tags=class] +---- +<.> specifies the "custom" CSS class + +* the following shows the changes that have been made to `application.css` to effect this: ++ +[source,css] +.application.css +---- +tr.even.custom > td, +tr.odd.custom > td, +.entityPage.custom .iconAndTitle span +{ + font-style: italic; + color: orangered; +} +---- + + +=== See also + +The link:https://causeway.apache.org/refguide/2.0.0-RC1/applib-methods/ui-hints/cssClass.html[cssClass()] method provides an alternative mechanism for specifying a custom CSS class for an object. +The difference though is that `cssClass()` is dynamic (whereas `@DomainObjectLayout#cssClass` attribute is static). + +A common use case for `cssClass()` is to reflect the state of an object that has a lifecycle, such as an `Order` with an `orderStatus`. +The colour used for a NEW order might be different from that for an CONFIRMED order, while a DISCARDED order might be rendered using [line-through]#strikethrough#. -For the purpose of demonstration, -the _Bootstrap_ predefined CSS class `bg-dark` is shown here. diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java index 8a701f8e71..4ae5f2d020 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java @@ -35,15 +35,15 @@ import org.apache.causeway.applib.annotation.ObjectSupport; @XmlRootElement(name = "root") @XmlType @XmlAccessorType(XmlAccessType.FIELD) -@Named("demo.DomainObjectLayoutCssClassVm") -@DomainObject( - nature=Nature.VIEW_MODEL) +@Named("demo.DomainObjectLayoutCssClassPage") +@DomainObject(nature=Nature.VIEW_MODEL) @DomainObjectLayout( - cssClass = "bg-dark") + cssClass = "green-title" // <.> +) public class DomainObjectLayoutCssClassPage implements HasAsciiDocDescription { @ObjectSupport public String title() { - return "DomainObjectLayout#cssClass"; + return "@DomainObjectLayout#cssClass"; } } diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml index b4f853de75..db8737c04a 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.layout.xml @@ -26,7 +26,16 @@ <bs3:row> <bs3:col span="6"> + <bs3:row> + <bs3:col span="12"> <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/> + </bs3:col> + </bs3:row> + <bs3:row> + <bs3:col span="12"> + <cpt:collection id="objects"/> + </bs3:col> + </bs3:row> </bs3:col> <bs3:col span="6"> <cpt:fieldSet name="Description" id="description" > diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage_objects.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage_objects.java new file mode 100644 index 0000000000..d1a244096e --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage_objects.java @@ -0,0 +1,30 @@ +package demoapp.dom.domain.objects.DomainObjectLayout.cssClass; + +import demoapp.dom._infra.values.ValueHolderRepository; +import demoapp.dom.domain.objects.DomainObjectLayout.bookmarking.DomainObjectLayoutBookmarkingPage; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +import javax.inject.Inject; + +import org.apache.causeway.applib.annotation.Collection; +import org.apache.causeway.applib.annotation.CollectionLayout; +import org.apache.causeway.applib.annotation.MemberSupport; + +@Collection() +@CollectionLayout() +@RequiredArgsConstructor +public class DomainObjectLayoutCssClassPage_objects { + + @SuppressWarnings("unused") + private final DomainObjectLayoutCssClassPage page; + + @MemberSupport + public List<? extends DomainObjectLayoutCssClass> coll() { + return objectRepository.all(); + } + + @Inject ValueHolderRepository<String, ? extends DomainObjectLayoutCssClass> objectRepository; + +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassRepository.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassRepository.java new file mode 100644 index 0000000000..9d557509df --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassRepository.java @@ -0,0 +1,26 @@ +/* + * 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.cssClass; + +import java.util.List; + +public interface DomainObjectLayoutCssClassRepository { + + List<? extends DomainObjectLayoutCssClass> allInstances(); +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassSeeding.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassSeeding.java new file mode 100644 index 0000000000..510ffccddf --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassSeeding.java @@ -0,0 +1,38 @@ +/* + * 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.cssClass; + +import demoapp.dom._infra.seed.SeedServiceAbstract; +import demoapp.dom._infra.values.ValueHolderRepository; + +import javax.inject.Inject; + +import org.springframework.stereotype.Service; + +@Service +public class DomainObjectLayoutCssClassSeeding +extends SeedServiceAbstract { + + @Inject + public DomainObjectLayoutCssClassSeeding( + ValueHolderRepository<String, ? extends DomainObjectLayoutCssClass> entities) { + super(entities); + } + +} diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/Status.java similarity index 78% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java copy to examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/Status.java index 8a701f8e71..65241c98a3 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage.java +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/Status.java @@ -32,19 +32,12 @@ import org.apache.causeway.applib.annotation.Nature; import org.apache.causeway.applib.annotation.ObjectSupport; //tag::class[] -@XmlRootElement(name = "root") -@XmlType -@XmlAccessorType(XmlAccessType.FIELD) -@Named("demo.DomainObjectLayoutCssClassVm") -@DomainObject( - nature=Nature.VIEW_MODEL) -@DomainObjectLayout( - cssClass = "bg-dark") -public class DomainObjectLayoutCssClassPage implements HasAsciiDocDescription { +public enum Status{ - @ObjectSupport public String title() { - return "DomainObjectLayout#cssClass"; - } + NEW, + IN_PROGRESS, + COMPLETE, + DISCARDED } //end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage-description.adoc b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpa-description.adoc similarity index 76% copy from examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage-description.adoc copy to examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpa-description.adoc index c4e0b85fce..efbe824eb8 100644 --- a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/DomainObjectLayoutCssClassPage-description.adoc +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpa-description.adoc @@ -1,8 +1,10 @@ :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 `cssClass` attribute indicates the CSS class -that a domain class (type) should have, -to allow more targeted styling in application.css. +This object is annotated with a CSS class of "custom": + +[source,java,indent=0] +---- +include::../DomainObjectLayoutCssClass.java[tags=class] +---- +<.> specifies "custom" CSS -For the purpose of demonstration, -the _Bootstrap_ predefined CSS class `bg-dark` is shown here. diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpa.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpa.java new file mode 100644 index 0000000000..512a9576f9 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpa.java @@ -0,0 +1,69 @@ +/* + * 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.cssClass.jpa; + +import demoapp.dom.domain.objects.DomainObjectLayout.bookmarking.jpa.DomainObjectLayoutBookmarkingChildJpa; +import demoapp.dom.domain.objects.DomainObjectLayout.cssClass.DomainObjectLayoutCssClass; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Set; +import java.util.TreeSet; + +import javax.inject.Named; +import javax.persistence.*; + +import org.apache.causeway.applib.annotation.Collection; +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.persistence.jpa.applib.integration.CausewayEntityListener; +import org.springframework.context.annotation.Profile; + +@Profile("demo-jpa") +@Entity +@Table( + schema = "demo", + name = "DomainObjectLayoutCssClassJpa" +) +@EntityListeners(CausewayEntityListener.class) +@Named("demo.DomainObjectLayoutCssClassJpa") +@NoArgsConstructor +//tag::class[] +// ... +@DomainObject(nature = Nature.ENTITY) +public class DomainObjectLayoutCssClassJpa extends DomainObjectLayoutCssClass { + // ... +//end::class[] + + public DomainObjectLayoutCssClassJpa(String value) { + setName(value); + } + + @Id + @GeneratedValue + private Long id; + + @Getter @Setter + private String name; + +//tag::class[] +} +//end::class[] diff --git a/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpaEntities.java b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpaEntities.java new file mode 100644 index 0000000000..bb2fd7d030 --- /dev/null +++ b/examples/demo/domain/src/main/java/demoapp/dom/domain/objects/DomainObjectLayout/cssClass/jpa/DomainObjectLayoutCssClassJpaEntities.java @@ -0,0 +1,55 @@ +/* + * 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.cssClass.jpa; + +import demoapp.dom._infra.values.ValueHolderRepository; +import demoapp.dom.domain.objects.DomainObjectLayout.cssClass.DomainObjectLayoutCssClass; +import demoapp.dom.domain.objects.DomainObjectLayout.cssClass.DomainObjectLayoutCssClassRepository; + +import java.util.List; + +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Service; + +@Profile("demo-jpa") +@Service +public class DomainObjectLayoutCssClassJpaEntities +extends ValueHolderRepository<String, DomainObjectLayoutCssClassJpa> implements DomainObjectLayoutCssClassRepository { + + protected DomainObjectLayoutCssClassJpaEntities() { + super(DomainObjectLayoutCssClassJpa.class); + } + + @Override + protected DomainObjectLayoutCssClassJpa newDetachedEntity(String value) { + return new DomainObjectLayoutCssClassJpa(value); + } + + @Override + public List<? extends DomainObjectLayoutCssClass> allInstances() { + return all(); + } + + public List<? extends DomainObjectLayoutCssClass> allMatches(final String s) { + return all(); + } + public List<? extends DomainObjectLayoutCssClass> allMatches() { + return all(); + } +} 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 2763dd021c..2d35fd09dd 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 @@ -23,7 +23,7 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto <mb3:primary> <mb3:menu> - <mb3:named>Domain Objects</mb3:named> + <mb3:named>@DomainObject</mb3:named> <mb3:section> <mb3:named>@DomainObject</mb3:named> <mb3:serviceAction objectType="demo.DomainObjectMenu" id="aliased"/> @@ -49,15 +49,10 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto <mb3:serviceAction objectType="demo.DomainObjectLayoutMenu" id="tableDecorator"/> <mb3:serviceAction objectType="demo.DomainObjectLayoutMenu" id="uiEvents"/> </mb3:section> - <mb3:section> - <mb3:named>Other</mb3:named> - <mb3:serviceAction objectType="demo.MixinMenu" id="mixins"/> - <mb3:serviceAction objectType="demo.EmbeddedTypeMenu" id="embeddedTypes"/> - </mb3:section> </mb3:menu> <mb3:menu> - <mb3:named>Actions</mb3:named> + <mb3:named>@Action</mb3:named> <mb3:section> <mb3:named>@Action</mb3:named> <mb3:serviceAction objectType="demo.ActionMenu" id="associateWith"/> @@ -84,17 +79,10 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto <mb3:serviceAction objectType="demo.ActionLayoutMenu" id="redirectPolicy"/> <mb3:serviceAction objectType="demo.ActionLayoutMenu" id="sequence"/> </mb3:section> - <mb3:section> - <mb3:named>Programming Model</mb3:named> - <mb3:serviceAction objectType="demo.AssociatedActionMenu" id="associatedActions"/> - <mb3:serviceAction objectType="demo.DependentArgsActionMenu" id="dependentArgsActions"> - <cpt:named>Dependent Arguments</cpt:named> - </mb3:serviceAction> - </mb3:section> </mb3:menu> <mb3:menu> - <mb3:named>Properties</mb3:named> + <mb3:named>@Property</mb3:named> <mb3:section> <mb3:named>@Property</mb3:named> <mb3:serviceAction objectType="demo.PropertyMenu" id="commandPublishing"/> @@ -127,7 +115,7 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto </mb3:menu> <mb3:menu> - <mb3:named>Collections</mb3:named> + <mb3:named>@Collection</mb3:named> <mb3:section> <mb3:named>@Collection</mb3:named> <mb3:serviceAction objectType="demo.CollectionMenu" id="domainEvent"/> @@ -148,6 +136,22 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto </mb3:section> </mb3:menu> + <mb3:menu> + <mb3:named>Prog Model</mb3:named> + <mb3:section> + <mb3:named>Domain Objects</mb3:named> + <mb3:serviceAction objectType="demo.MixinMenu" id="mixins"/> + <mb3:serviceAction objectType="demo.EmbeddedTypeMenu" id="embeddedTypes"/> + </mb3:section> + <mb3:section> + <mb3:named>Actions</mb3:named> + <mb3:serviceAction objectType="demo.AssociatedActionMenu" id="associatedActions"/> + <mb3:serviceAction objectType="demo.DependentArgsActionMenu" id="dependentArgsActions"> + <cpt:named>Dependent Arguments</cpt:named> + </mb3:serviceAction> + </mb3:section> + </mb3:menu> + <mb3:menu> <mb3:named>Basic Types</mb3:named> <mb3:section> @@ -229,7 +233,7 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto <mb3:serviceAction objectType="demo.JavaUtilTypesMenu" id="uuids"/> </mb3:section> <mb3:section> - <mb3:named>Apache Causeway Core</mb3:named> + <mb3:named>Causeway Core</mb3:named> <mb3:serviceAction objectType="demo.CausewayTypesMenu" id="blobs"/> <mb3:serviceAction objectType="demo.CausewayTypesMenu" id="clobs"/> <mb3:serviceAction objectType="demo.CausewayTypesMenu" id="localResourcePaths"/> @@ -237,19 +241,11 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto <mb3:serviceAction objectType="demo.CausewayTypesMenu" id="passwords"/> </mb3:section> <mb3:section> - <mb3:named>Apache Causeway Values</mb3:named> + <mb3:named>Causeway Values</mb3:named> <mb3:serviceAction objectType="demo.CausewayValTypesMenu" id="asciiDocs"/> <mb3:serviceAction objectType="demo.CausewayValTypesMenu" id="markdowns"/> <mb3:serviceAction objectType="demo.CausewayValTypesMenu" id="vegaCharts"/> </mb3:section> - <mb3:section> - <mb3:named>Apache Causeway Extensions</mb3:named> - <mb3:serviceAction objectType="demo.CausewayExtTypesMenu" id="calendarEvents"/> - <mb3:serviceAction objectType="demo.AsyncActionMenu" id="asyncActions"> - <cpt:named>SSE</cpt:named> - <cpt:describedAs>Background (Async) Actions</cpt:describedAs> - </mb3:serviceAction> - </mb3:section> </mb3:menu> <mb3:menu> @@ -262,8 +258,20 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto <mb3:serviceAction objectType="demo.ServicesMenu" id="wrapperFactory"/> <mb3:serviceAction objectType="demo.ServicesMenu" id="xmlSnapshot"/> </mb3:section> + </mb3:menu> + + <mb3:menu> + <mb3:named>Extensions</mb3:named> + <mb3:section> + <mb3:named>Wicket Viewer</mb3:named> + <mb3:serviceAction objectType="demo.CausewayExtTypesMenu" id="calendarEvents"/> + <mb3:serviceAction objectType="demo.AsyncActionMenu" id="asyncActions"> + <cpt:named>SSE</cpt:named> + <cpt:describedAs>Background (Async) Actions</cpt:describedAs> + </mb3:serviceAction> + </mb3:section> <mb3:section> - <mb3:named>Extensions - SecMan</mb3:named> + <mb3:named>SecMan</mb3:named> <mb3:serviceAction objectType="demo.ExtSecManMenu" id="appTenancy"/> </mb3:section> </mb3:menu> @@ -272,7 +280,9 @@ For latest we use: https://raw.githubusercontent.com/apache/causeway/master/anto <mb3:named>Featured</mb3:named> <mb3:section> <mb3:named>Layout</mb3:named> - <mb3:serviceAction objectType="demo.DescribedAsMenu" id="describedAs"/> + <mb3:serviceAction objectType="demo.DescribedAsMenu" id="describedAs"> + <mb3:named>Tool Tips</mb3:named> + </mb3:serviceAction> <mb3:serviceAction objectType="demo.TabMenu" id="tabDemo" /> </mb3:section> <mb3:section> diff --git a/examples/demo/domain/src/main/resources/static/css/application.css b/examples/demo/domain/src/main/resources/static/css/application.css index 01f8147763..a0b219319c 100644 --- a/examples/demo/domain/src/main/resources/static/css/application.css +++ b/examples/demo/domain/src/main/resources/static/css/application.css @@ -290,3 +290,15 @@ div.listingblock div.title { div.sectionbody > div.ulist { margin-left: 10px; } + +tr.even.custom > td, +tr.odd.custom > td, +.entityPage.custom .iconAndTitle span +{ + font-style: italic; + color: orangered; +} + +.line-through { + text-decoration: line-through; +}
