From e749242ad6d9d5e2704a94b1d4b243d362222803 Mon Sep 17 00:00:00 2001 From: Andi Huber Date: Tue, 26 Nov 2024 10:27:06 +0100 Subject: [PATCH] CAUSEWAY-3833: polishing prev. commits (renaming) --- .../tableoption/SelectOperationChoice.java | 9 ++++++++- .../tableoption/SelectOperationChoiceKey.java | 9 +++++++++ .../ajaxtable/columns/ToggleboxColumn.java | 4 ++-- .../table/DataTableWithPagesAndFilter.java | 4 ++-- .../SelectOperationChooser.html} | 8 ++++---- .../SelectOperationChooser.java} | 20 +++++++++---------- 6 files changed, 35 insertions(+), 19 deletions(-) rename viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/nav/{pageact/PageActionChooser.html => selop/SelectOperationChooser.html} (86%) rename viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/nav/{pageact/PageActionChooser.java => selop/SelectOperationChooser.java} (81%) diff --git a/viewers/wicket/model/src/main/java/org/apache/causeway/viewer/wicket/model/tableoption/SelectOperationChoice.java b/viewers/wicket/model/src/main/java/org/apache/causeway/viewer/wicket/model/tableoption/SelectOperationChoice.java index 34e8afb3b96..e2e17880f56 100644 --- a/viewers/wicket/model/src/main/java/org/apache/causeway/viewer/wicket/model/tableoption/SelectOperationChoice.java +++ b/viewers/wicket/model/src/main/java/org/apache/causeway/viewer/wicket/model/tableoption/SelectOperationChoice.java @@ -27,5 +27,12 @@ public record SelectOperationChoice( SelectOperationChoiceKey key, String translatedTitle, String cssClass) -implements Serializable{ +implements Serializable { + + public SelectOperationChoice( + final SelectOperationChoiceKey key, + final String translatedTitle) { + this(key, translatedTitle, ""); + } + } \ No newline at end of file diff --git a/viewers/wicket/model/src/main/java/org/apache/causeway/viewer/wicket/model/tableoption/SelectOperationChoiceKey.java b/viewers/wicket/model/src/main/java/org/apache/causeway/viewer/wicket/model/tableoption/SelectOperationChoiceKey.java index d3a6afdf726..3938408954e 100644 --- a/viewers/wicket/model/src/main/java/org/apache/causeway/viewer/wicket/model/tableoption/SelectOperationChoiceKey.java +++ b/viewers/wicket/model/src/main/java/org/apache/causeway/viewer/wicket/model/tableoption/SelectOperationChoiceKey.java @@ -18,6 +18,8 @@ */ package org.apache.causeway.viewer.wicket.model.tableoption; +import java.util.function.Predicate; + import lombok.RequiredArgsConstructor; /** @@ -38,4 +40,11 @@ public boolean isPageSpecific() { return this==PAGE_SEL || this == PAGE_UNSEL; } + + public static Predicate isAvailableWhen(final boolean isTablePaged) { + return (final SelectOperationChoiceKey key)->isTablePaged + ? true + : !key.isPageSpecific(); + } + } \ No newline at end of file diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collectioncontents/ajaxtable/columns/ToggleboxColumn.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collectioncontents/ajaxtable/columns/ToggleboxColumn.java index 11cd2a4b624..bad1212cd37 100644 --- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collectioncontents/ajaxtable/columns/ToggleboxColumn.java +++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/collectioncontents/ajaxtable/columns/ToggleboxColumn.java @@ -27,7 +27,7 @@ import org.apache.causeway.viewer.wicket.model.models.interaction.coll.DataRowToggleWkt; import org.apache.causeway.viewer.wicket.model.models.interaction.coll.DataRowWkt; import org.apache.causeway.viewer.wicket.ui.components.table.DataTableWithPagesAndFilter; -import org.apache.causeway.viewer.wicket.ui.components.table.nav.pageact.PageActionChooser; +import org.apache.causeway.viewer.wicket.ui.components.table.nav.selop.SelectOperationChooser; import org.apache.causeway.viewer.wicket.ui.components.widgets.checkbox.ContainedToggleboxPanel; import org.apache.causeway.viewer.wicket.ui.util.Wkt; @@ -60,7 +60,7 @@ protected Component createCellComponent(final String componentId, final DataRowW @Override public Component getHeader(final String componentId) { - var pageActionChooser = new PageActionChooser(componentId, table); + var pageActionChooser = new SelectOperationChooser(componentId, table); Wkt.cssAppend(pageActionChooser, "togglebox-column"); return pageActionChooser; } diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/DataTableWithPagesAndFilter.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/DataTableWithPagesAndFilter.java index 3b481249b93..7753ed5782f 100644 --- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/DataTableWithPagesAndFilter.java +++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/DataTableWithPagesAndFilter.java @@ -184,8 +184,8 @@ public List getPagesizeChoices() { public List getSelectOperationChoices() { return isRowSelectionEnabled() ? Stream.of(SelectOperationChoiceKey.values()) - .filter(key->isPaged() ? true : !key.isPageSpecific()) - .map(key->new SelectOperationChoice(key, translate(key.englishTitle), "")) + .filter(SelectOperationChoiceKey.isAvailableWhen(isPaged())) + .map(key->new SelectOperationChoice(key, translate(key.englishTitle))) .toList() : Collections.emptyList(); } diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/nav/pageact/PageActionChooser.html b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/nav/selop/SelectOperationChooser.html similarity index 86% rename from viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/nav/pageact/PageActionChooser.html rename to viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/nav/selop/SelectOperationChooser.html index f40c77d10c6..c750cc792a6 100644 --- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/nav/pageact/PageActionChooser.html +++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/table/nav/selop/SelectOperationChooser.html @@ -21,7 +21,7 @@