You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2017/11/14 23:40:10 UTC

[isis] branch master updated: ISIS-1759: adds special casing so that @DomainObject#cssClass does not trump cssClass() method, but still allowing @DomainObject#cssClassUiEvent to have priority over them both

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

danhaywood 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 80c72bd  ISIS-1759: adds special casing so that @DomainObject#cssClass does not trump cssClass() method, but still allowing @DomainObject#cssClassUiEvent to have priority over them both
80c72bd is described below

commit 80c72bdb567a1c4321457f09b53c4f2291af88ac
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Nov 14 23:39:51 2017 +0000

    ISIS-1759: adds special casing so that @DomainObject#cssClass does not trump cssClass() method, but still allowing @DomainObject#cssClassUiEvent to have priority over them both
---
 .../CssClassFacetForDomainObjectLayoutAnnotation.java        | 12 ++++++++++++
 .../src/main/java/domainapp/application/isis.properties      |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/domainobjectlayout/CssClassFacetForDomainObjectLayoutAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/domainobjectlayout/CssClassFacetForDomainObjectLayoutAnnotation.java
index 36060df..2de276b 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/domainobjectlayout/CssClassFacetForDomainObjectLayoutAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/domainobjectlayout/CssClassFacetForDomainObjectLayoutAnnotation.java
@@ -22,6 +22,7 @@ import org.apache.isis.applib.annotation.DomainObjectLayout;
 import org.apache.isis.core.metamodel.facetapi.FacetHolder;
 import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
 import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.cssclass.method.CssClassFacetMethod;
 
 public class CssClassFacetForDomainObjectLayoutAnnotation extends CssClassFacetAbstract {
 
@@ -29,6 +30,17 @@ public class CssClassFacetForDomainObjectLayoutAnnotation extends CssClassFacetA
         if (domainObjectLayout == null) {
             return null;
         }
+        CssClassFacet facet = holder.getFacet(CssClassFacet.class);
+        // this is a bit hacky, explicitly checking whether a different implementation is already added.
+        // normally we would just re-order the list of facet factories in ProgrammingModelsFacetJava5, however in
+        // this case @DomainObjectLayout is responsible for two different variations of CssClassFacet, either as
+        // a result of the cssClass attribute, but also as a result of the cssClassUiEvent.  The former has lower
+        // "priority" to the cssClass() method, but the latter has *higher* priority.  Hence the special casing
+        // that is required here.
+        if(facet != null && facet instanceof CssClassFacetMethod) {
+            // don't overwrite
+            return null;
+        }
         final String cssClass = Strings.emptyToNull(domainObjectLayout.cssClass());
         return cssClass != null ? new CssClassFacetForDomainObjectLayoutAnnotation(cssClass, holder) : null;
     }
diff --git a/example/application/helloworld/src/main/java/domainapp/application/isis.properties b/example/application/helloworld/src/main/java/domainapp/application/isis.properties
index 2451b83..e2a8199 100644
--- a/example/application/helloworld/src/main/java/domainapp/application/isis.properties
+++ b/example/application/helloworld/src/main/java/domainapp/application/isis.properties
@@ -26,6 +26,9 @@ isis.reflector.validator.explicitObjectType=true
 isis.reflector.validator.serviceActionsOnly=true
 isis.reflector.validator.mixinsOnly=true
 
+#isis.reflector.facet.domainObjectLayoutAnnotation.titleUiEvent.postForDefault=true
+#isis.reflector.facet.domainObjectLayoutAnnotation.iconUiEvent.postForDefault=true
+#isis.reflector.facet.domainObjectLayoutAnnotation.cssClassUiEvent.postForDefault=true
 
 isis.reflector.facet.cssClassFa.patterns=\
                         new.*:fa-plus,\

-- 
To stop receiving notification emails like this one, please contact
['"commits@isis.apache.org" <co...@isis.apache.org>'].