grid) {
this.grid = grid;
- helperClassNameGenerator = new GridHelperClassNameGenerator<>();
- setClassNameGenerator(grid.getClassNameGenerator());
+ helperPartNameGenerator = new GridHelperPartNameGenerator<>();
+ setPartNameGenerator(grid.getPartNameGenerator());
grid.addItemClickListener(this::onItemClick);
grid.addAttachListener(this::onAttach);
if (grid.isAttached()) {
@@ -161,26 +161,24 @@ public static SelectionMode getSelectionMode(Grid> grid) {
}
/**
- * Sets the function that is used for generating CSS class names for all the cells in the rows in
- * this grid. Returning {@code null} from the generator results in no custom class name being set.
- * Multiple class names can be returned from the generator as space-separated.
+ * Sets the function that is used for generating CSS part names for all the cells in the rows in
+ * this grid. Returning {@code null} from the generator results in no custom part name being set.
+ * Multiple part names can be returned from the generator as space-separated.
*
- * If {@link Column#setClassNameGenerator(SerializableFunction)} is used together with this
- * method, resulting class names from both methods will be effective. Class names generated by
- * grid are applied to the cells before the class names generated by column. This means that if
- * the classes contain conflicting style properties, column's classes will win.
+ *
+ * If {@link Column#setPartNameGenerator(SerializableFunction)} is used together with this method,
+ * resulting part names from both methods will be effective.
*
- * @param classNameGenerator the class name generator to set, not {@code null}
- * @throws NullPointerException if {@code classNameGenerator} is {@code null}
- * @see Column#setClassNameGenerator(SerializableFunction)
+ * @param partNameGenerator the part name generator to set.
+ * @see Column#setPartNameGenerator(SerializableFunction)
*/
- public void setClassNameGenerator(SerializableFunction classNameGenerator) {
- grid.setClassNameGenerator(helperClassNameGenerator);
- if (classNameGenerator instanceof GridHelperClassNameGenerator) {
- helperClassNameGenerator.setGridClassNameGenerator(
- ((GridHelperClassNameGenerator) classNameGenerator).getGridClassNameGenerator());
+ public void setPartNameGenerator(SerializableFunction partNameGenerator) {
+ grid.setPartNameGenerator(helperPartNameGenerator);
+ if (partNameGenerator instanceof GridHelperPartNameGenerator) {
+ helperPartNameGenerator.setGridPartNameGenerator(
+ ((GridHelperPartNameGenerator) partNameGenerator).getGridPartNameGenerator());
} else {
- helperClassNameGenerator.setGridClassNameGenerator(classNameGenerator);
+ helperPartNameGenerator.setGridPartNameGenerator(partNameGenerator);
}
}
@@ -435,18 +433,54 @@ public static boolean isFooterVisible(Grid> grid) {
private final HeaderFooterStylesHelper headerFooterStylesHelper =
new HeaderFooterStylesHelper(this);
+ /**
+ * Returns a helper for managing CSS styles on cells within a header row.
+ *
+ * @param grid the grid containing the header row
+ * @param row the header row to style
+ * @return a {@link GridStylesHelper} for managing styles on the header row's cells
+ * @deprecated Use {@link HeaderCell#setPartName(String)} and {@link HeaderCell#getPartName()}
+ */
+ @Deprecated
public static GridStylesHelper getHeaderStyles(Grid> grid, HeaderRow row) {
return getHelper(grid).headerFooterStylesHelper.getStyles(row);
}
+ /**
+ * Returns a helper for managing CSS styles on cells within a footer row.
+ *
+ * @param grid the grid containing the footer row
+ * @param row the footer row to style
+ * @return a {@link GridStylesHelper} for managing styles on the footer row's cells
+ * @deprecated Use {@link FooterCell#setPartName(String)} and {@link FooterCell#getPartName()}
+ */
+ @Deprecated
public static GridStylesHelper getFooterStyles(Grid> grid, FooterRow row) {
return getHelper(grid).headerFooterStylesHelper.getStyles(row);
}
+ /**
+ * Returns a helper for managing CSS styles on a specific header cell.
+ *
+ * @param grid the grid containing the header cell
+ * @param cell the header cell to style
+ * @return a {@link GridStylesHelper} for managing styles on the header cell
+ * @deprecated Use {@link HeaderCell#setPartName(String)} and {@link HeaderCell#getPartName()}
+ */
+ @Deprecated
public static GridStylesHelper getHeaderStyles(Grid> grid, HeaderCell cell) {
return getHelper(grid).headerFooterStylesHelper.getStyles(cell);
}
+ /**
+ * Returns a helper for managing CSS styles on a specific footer cell.
+ *
+ * @param grid the grid containing the footer cell
+ * @param cell the footer cell to style
+ * @return a {@link GridStylesHelper} for managing styles on the footer cell
+ * @deprecated Use {@link FooterCell#setPartName(String)} and {@link FooterCell#getPartName()}
+ */
+ @Deprecated
public static GridStylesHelper getFooterStyles(Grid> grid, FooterCell cell) {
return getHelper(grid).headerFooterStylesHelper.getStyles(cell);
}
diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperClassNameGenerator.java b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperPartNameGenerator.java
similarity index 72%
rename from src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperClassNameGenerator.java
rename to src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperPartNameGenerator.java
index e72e97d..c8619dd 100644
--- a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperClassNameGenerator.java
+++ b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperPartNameGenerator.java
@@ -2,7 +2,7 @@
* #%L
* Grid Helpers Add-on
* %%
- * Copyright (C) 2022 - 2024 Flowing Code
+ * Copyright (C) 2022 - 2025 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,27 +31,30 @@
import lombok.Setter;
@SuppressWarnings("serial")
-final class GridHelperClassNameGenerator implements SerializableFunction {
+final class GridHelperPartNameGenerator implements SerializableFunction {
- private Map, SerializableFunction> helperClassNameGenerators =
+ private Map, SerializableFunction> helperPartNameGenerators =
new HashMap<>();
- @Getter @Setter private SerializableFunction gridClassNameGenerator;
+ @Getter
+ @Setter
+ private SerializableFunction gridPartNameGenerator;
private transient boolean invoked;
- void setHelperClassNameGenerator(Class> clazz, SerializableFunction generator) {
+ void setHelperPartNameGenerator(Class> clazz, SerializableFunction generator) {
if (generator != null) {
- helperClassNameGenerators.put(clazz, generator);
+ helperPartNameGenerators.put(clazz, generator);
} else {
- helperClassNameGenerators.remove(clazz);
+ helperPartNameGenerators.remove(clazz);
}
}
private Stream> generators() {
+
return Stream.concat(
- Optional.ofNullable(gridClassNameGenerator).map(Stream::of).orElseGet(Stream::empty),
- helperClassNameGenerators.values().stream());
+ Optional.ofNullable(gridPartNameGenerator).map(Stream::of).orElseGet(Stream::empty),
+ helperPartNameGenerators.values().stream());
}
@Override
diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/SelectionFilterHelper.java b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/SelectionFilterHelper.java
index 1af2867..40fbc83 100644
--- a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/SelectionFilterHelper.java
+++ b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/SelectionFilterHelper.java
@@ -2,7 +2,7 @@
* #%L
* Grid Helpers Add-on
* %%
- * Copyright (C) 2022 - 2024 Flowing Code
+ * Copyright (C) 2022 - 2025 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,11 +59,11 @@ public void setSelectionFilter(SerializablePredicate predicate) {
currentSingleSelectedItem = null;
if (predicate != null) {
deselectIf(predicate.negate());
- helper.setHelperClassNameGenerator(
+ helper.setHelperPartNameGenerator(
this.getClass(), row -> predicate.test(row) ? null : "fcGh-noselect");
selectionListenerRegistration = grid.addSelectionListener(this::onSelection);
} else {
- helper.setHelperClassNameGenerator(this.getClass(), null);
+ helper.setHelperPartNameGenerator(this.getClass(), null);
}
}
diff --git a/src/main/resources/META-INF/frontend/fcGridHelper/vaadin-grid.css b/src/main/resources/META-INF/frontend/fcGridHelper/vaadin-grid.css
index 7c56831..0c64597 100644
--- a/src/main/resources/META-INF/frontend/fcGridHelper/vaadin-grid.css
+++ b/src/main/resources/META-INF/frontend/fcGridHelper/vaadin-grid.css
@@ -2,7 +2,7 @@
* #%L
* Grid Helpers Add-on
* %%
- * Copyright (C) 2022 - 2024 Flowing Code
+ * Copyright (C) 2022 - 2025 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@
--fcgh-toggle-right: 24px;
}
-table[aria-multiselectable="true"] .fcGh-noselect[first-column] ::slotted(*) {
+table[aria-multiselectable="true"] [part~="fcGh-noselect"][first-column] ::slotted(*) {
opacity: var(--fcgh-noselect-opacity, 0.5);
pointer-events: none;
}