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 2022/03/03 17:09:31 UTC

[isis] branch master updated: ISIS-2877: allow devs to hook into shallow component creation

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 be2e833  ISIS-2877: allow devs to hook into shallow component creation
be2e833 is described below

commit be2e833e58736aac70ca59372cae19739232377a
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Mar 3 18:08:16 2022 +0100

    ISIS-2877: allow devs to hook into shallow component creation
---
 .../ui/components/scalars/ScalarPanelAbstract.java   | 20 ++++++++++++++++++--
 .../scalars/ScalarPanelWithFormFieldAbstract.java    |  3 ---
 .../blobclob/IsisBlobOrClobPanelAbstract.java        | 14 ++++++++------
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
index 3fbc63a..09d0528 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
@@ -323,12 +323,12 @@ implements ScalarModelSubscriber, HasScalarModel {
         switch(scalarModel.getRenderingHint()) {
         case REGULAR:
             componentIfRegular = createComponentForRegular();
-            componentIfCompact = Wkt.container(ID_SCALAR_IF_COMPACT); // empty component
+            componentIfCompact = createShallowComponentForCompact();
             componentIfRegular.setVisible(true);
             componentIfCompact.setVisible(false);
             break;
         default:
-            componentIfRegular = Wkt.container(ID_SCALAR_IF_REGULAR); // empty component
+            componentIfRegular = createShallowComponentForRegular();
             componentIfCompact = createComponentForCompact();
             componentIfRegular.setVisible(false);
             componentIfCompact.setVisible(true);
@@ -417,6 +417,22 @@ implements ScalarModelSubscriber, HasScalarModel {
     }
 
     /**
+     * Builds the hidden REGULAR component when in COMPACT format.
+     * <p>Is added to {@link #scalarTypeContainer}.
+     */
+    protected MarkupContainer createShallowComponentForRegular() {
+        return Wkt.container(ID_SCALAR_IF_REGULAR); // empty component;
+    }
+
+    /**
+     * Builds the hidden COMPACT component when in REGULAR format.
+     * <p>Is added to {@link #scalarTypeContainer}.
+     */
+    protected Component createShallowComponentForCompact() {
+        return Wkt.container(ID_SCALAR_IF_COMPACT); // empty component
+    }
+
+    /**
      * The widget starts off in read-only, but should be possible to activate into edit mode.
      */
     protected void onInitializeNotEditable() {
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelWithFormFieldAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelWithFormFieldAbstract.java
index aa17489..36e3ca8 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelWithFormFieldAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelWithFormFieldAbstract.java
@@ -106,9 +106,6 @@ extends ScalarPanelAbstract {
     protected void onFormGroupCreated(final FormGroup formGroup) {
     }
 
-    protected void onFormGroupNotCreated(final MarkupContainer emptyContainer) {
-    }
-
     protected IValidator<Object> createValidator(final ScalarModel scalarModel) {
         return new IValidator<Object>() {
             private static final long serialVersionUID = 1L;
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/blobclob/IsisBlobOrClobPanelAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/blobclob/IsisBlobOrClobPanelAbstract.java
index d02212b..e25336e 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/blobclob/IsisBlobOrClobPanelAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/blobclob/IsisBlobOrClobPanelAbstract.java
@@ -108,6 +108,14 @@ extends ScalarPanelWithFormFieldAbstract<T> {
     // //////////////////////////////////////
 
     @Override
+    protected MarkupContainer createShallowComponentForRegular() {
+        val shallowRegular = super.createShallowComponentForRegular();
+        Components.permanentlyHide(shallowRegular,
+                ID_IMAGE, ID_SCALAR_NAME, ID_SCALAR_VALUE, "feedback");
+        return shallowRegular;
+    }
+
+    @Override
     protected Component createComponentForCompact() {
         final MarkupContainer scalarIfCompact = new WebMarkupContainer(ID_SCALAR_IF_COMPACT);
         updateDownloadLink(ID_SCALAR_IF_COMPACT_DOWNLOAD, scalarIfCompact);
@@ -115,12 +123,6 @@ extends ScalarPanelWithFormFieldAbstract<T> {
 //            updateFileNameLabel(ID_FILE_NAME_IF_COMPACT, downloadLink);
 //            Components.permanentlyHide(downloadLink, ID_FILE_NAME_IF_COMPACT);
 //        }
-
-        Components.permanentlyHide(getComponentForRegular(), ID_IMAGE);
-        Components.permanentlyHide(getComponentForRegular(), ID_SCALAR_NAME);
-        Components.permanentlyHide(getComponentForRegular(), ID_SCALAR_VALUE);
-        Components.permanentlyHide(getComponentForRegular(), "feedback");
-
         return scalarIfCompact;
     }