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 5f90a5b896 ISIS-3112: implement poor man html rendering for standalone 
value panels
5f90a5b896 is described below

commit 5f90a5b89698e4e758468b9182805cb56b018915
Author: andi-huber <[email protected]>
AuthorDate: Mon Aug 8 15:39:51 2022 +0200

    ISIS-3112: implement poor man html rendering for standalone value panels
    
    - yet this is not sufficient for more complex value-types
---
 .../ui/components/value/StandaloneValuePanel.java  | 33 +++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/value/StandaloneValuePanel.java
 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/value/StandaloneValuePanel.java
index 7d5fb66f5e..bd0ea693d0 100644
--- 
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/value/StandaloneValuePanel.java
+++ 
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/value/StandaloneValuePanel.java
@@ -18,12 +18,20 @@
  */
 package org.apache.isis.viewer.wicket.ui.components.value;
 
+import java.net.URL;
+import java.util.UUID;
+
+import 
org.apache.isis.applib.services.bookmark.idstringifiers.PredefinedSerializables;
+import org.apache.isis.applib.value.LocalResourcePath;
 import org.apache.isis.core.metamodel.spec.ManagedObject;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.viewer.wicket.model.models.ValueModel;
 import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelAbstract;
 import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
 import org.apache.isis.viewer.wicket.ui.util.Wkt;
 
+import lombok.val;
+
 /**
  * Panel for rendering any value types that do not have their own custom
  * {@link ScalarPanelAbstract panel} to render them.
@@ -36,7 +44,30 @@ extends PanelAbstract<ManagedObject, ValueModel> {
 
     public StandaloneValuePanel(final String id, final ValueModel valueModel) {
         super(id, valueModel);
-        Wkt.labelAdd(this, ID_STANDALONE_VALUE, 
()->getModel().getObject().titleString());
+
+        //XXX StandaloneValuePanel has its limitations compared to the 
ScalarPanel infrastructure,
+        // which has far better rendering support
+        // (we probably need to remove StandaloneValuePanel and utilize the 
ScalarPanel for standalone values instead)
+        
if(isProbablySimpleInlineHtml(valueModel.getObjectMember().getElementType())) {
+            Wkt.markupAdd(this, ID_STANDALONE_VALUE, ()->
+                
getModel().getObject().htmlString(getModel().getObjectMember()));
+        } else {
+            // resort to (textual) title rendering
+            Wkt.labelAdd(this, ID_STANDALONE_VALUE, ()->
+                getModel().getObject().titleString());
+        }
+    }
+
+    // -- HELPER
+
+    private boolean isProbablySimpleInlineHtml(final ObjectSpecification 
valueSpec) {
+        val cls = valueSpec.getCorrespondingClass();
+
+        return PredefinedSerializables.isPredefinedSerializable(cls)
+                || UUID.class.equals(cls)
+                || URL.class.equals(cls)
+                || LocalResourcePath.class.equals(cls);
     }
 
+
 }

Reply via email to