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 2024/10/31 06:46:17 UTC

(causeway) branch master updated: CAUSEWAY-3815: de-duplicate action decorator code

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 2d9054a6eef CAUSEWAY-3815: de-duplicate action decorator code
2d9054a6eef is described below

commit 2d9054a6eef2c192f26c3e4ec387ba7be24ce440
Author: andi-huber <ah...@apache.org>
AuthorDate: Thu Oct 31 07:46:11 2024 +0100

    CAUSEWAY-3815: de-duplicate action decorator code
---
 .../actionmenu/serviceactions/CssMenuItem.java        | 19 ++++---------------
 .../causeway/viewer/wicket/ui/util/WktDecorators.java | 19 -------------------
 2 files changed, 4 insertions(+), 34 deletions(-)

diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/actionmenu/serviceactions/CssMenuItem.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/actionmenu/serviceactions/CssMenuItem.java
index 4905e7683c1..c06855b287a 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/actionmenu/serviceactions/CssMenuItem.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/actionmenu/serviceactions/CssMenuItem.java
@@ -75,19 +75,12 @@ implements Menuable {
     }
 
     private final List<CssMenuItem> subMenuItems = _Lists.newArrayList();
-    protected void addSubMenuItem(final CssMenuItem cssMenuItem) {
+    protected final void addSubMenuItem(final CssMenuItem cssMenuItem) {
         subMenuItems.add(cssMenuItem);
     }
     public Can<CssMenuItem> getSubMenuItems() {
         return Can.ofCollection(subMenuItems);
     }
-    /**
-     * @param menuItems we assume these have the correct parent already set
-     */
-    public void replaceSubMenuItems(final List<CssMenuItem> menuItems) {
-        subMenuItems.clear();
-        subMenuItems.addAll(menuItems);
-    }
     public boolean hasSubMenuItems() {
         return subMenuItems.size() > 0;
     }
@@ -107,7 +100,7 @@ implements Menuable {
     private Component addMenuItemComponentTo(final MarkupContainer markupContainer) {
 
         var linkAndLabel = getLinkAndLabel();
-        var actionLink = getLinkAndLabel().getUiComponent();
+        var actionLink = linkAndLabel.getUiComponent();
 
         var label = Wkt.labelAdd(markupContainer, CssMenuItem.ID_MENU_LABEL, this::getName);
 
@@ -115,11 +108,9 @@ implements Menuable {
 
             // show link...
             markupContainer.add(actionLink);
-            actionLink.add(label);
 
-            WktDecorators.decorateCssMenuItem(
-                    linkAndLabel.getUiComponent(), 
-                    label, 
+            WktDecorators.decorateMenuAction(
+                    actionLink, actionLink, label, 
                     ActionDecorationModel.builder(linkAndLabel)
                         .actionStyle(ActionStyle.MENU_ITEM)
                         .build());
@@ -138,8 +129,6 @@ implements Menuable {
 
             label.add(new AttributeModifier("class", Model.of("disabled")));
 
-            markupContainer.add(label);
-
             return label;
         }
     }
diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/util/WktDecorators.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/util/WktDecorators.java
index b94c973eb93..04ea896a669 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/util/WktDecorators.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/util/WktDecorators.java
@@ -224,25 +224,6 @@ public class WktDecorators {
         decorateActionCommon(actionLink, actionLabel, decorationModel);
     }
 
-    public void decorateCssMenuItem(
-            AjaxLink<ManagedObject> actionLink,
-            Label actionLabel, 
-            ActionDecorationModel decorationModel) {
-
-        decorationModel.disabling()
-            .ifPresentOrElse(disableUiModel->{
-                //DISABLE
-                disable().decorate(actionLink, disableUiModel);
-            }, ()->{
-                //DESCRIBE
-                decorationModel
-                    .describedAs()
-                    .ifPresent(describedAs->WktTooltips.addTooltip(actionLink, describedAs));
-            });
-    
-        decorateActionCommon(actionLink, actionLabel, decorationModel);
-    }
-
     // -- ACTION DECORATION HELPER
     
     private void decorateActionCommon(