Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The class `GridHelper` provides several static methods that receive a `Grid` or

```
grid.setSelectionMode(SelectionMode.MULTI);
grid.addThemeName(GridHelper.DENSE_THEME);
GridHelper.setDenseTheme(grid, true);
GridHelper.setSelectOnClick(grid, true);
GridHelper.setArrowSelectionEnabled(grid, true);
GridHelper.setSelectionColumnHidden(grid, true);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.vaadin.addons.flowingcode</groupId>
<artifactId>grid-helpers</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<name>Grid Helpers Add-on</name>
<description>Grid Helpers Add-on for Vaadin Flow</description>
<url>https://www.flowingcode.com/en/open-source/</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,45 @@ public final class GridHelper<T> implements Serializable {

/** Compact row styling for Vaadin Grid */
// https://cookbook.vaadin.com/grid-dense-theme
public static final String DENSE_THEME = "fcGh-dense";
private static final String DENSE_THEME_NAME = "fcGh-dense";

/**
* Compact row styling for Vaadin Grid.
*
* @deprecated Use {@link #setDenseTheme(Grid, boolean)} instead. Direct use of this constant
* bypasses the bytecode reference to {@code GridHelper}, which prevents the Vaadin production
* bundle scanner from discovering the required {@code @CssImport} annotations.
*/
@Deprecated(since = "2.1.0", forRemoval = true)
public static final String DENSE_THEME = DENSE_THEME_NAME;

/**
* Adds or removes compact row styling on the given grid.
*
* <p>Prefer this method over {@code grid.addThemeName(GridHelper.DENSE_THEME)} because it
* creates a bytecode reference to {@code GridHelper}, ensuring that the Vaadin production
* bundle scanner discovers the required {@code @CssImport} annotations.
*
* @param grid the grid to style
* @param dense {@code true} to enable dense theme, {@code false} to remove it
*/
public static void setDenseTheme(Grid<?> grid, boolean dense) {
if (dense) {
grid.addThemeName(DENSE_THEME_NAME);
} else {
grid.removeThemeName(DENSE_THEME_NAME);
}
}

/**
* Returns whether the dense theme is currently applied to the given grid.
*
* @param grid the grid to check
* @return {@code true} if the dense theme is applied
*/
public static boolean isDenseTheme(Grid<?> grid) {
return grid.hasThemeName(DENSE_THEME_NAME);
}

@Getter(value = AccessLevel.PACKAGE)
private final Grid<T> grid;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,11 @@ private boolean hasSelectionFilter(Grid<Person> grid) {
}

private void setDenseTheme(Grid<Person> grid, boolean value) {
if (value) {
grid.addThemeName(GridHelper.DENSE_THEME);
} else {
grid.removeThemeName(GridHelper.DENSE_THEME);
}
GridHelper.setDenseTheme(grid, value);
}

private boolean hasDenseTheme(Grid<Person> grid) {
return grid.hasThemeName(GridHelper.DENSE_THEME);
return GridHelper.isDenseTheme(grid);
}

private void setHeaderHidden(Grid<Person> grid, boolean value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public DenseThemeDemo() {
grid.addColumn(Person::getLastName).setHeader("Last name");
grid.addColumn(Person::getCountry).setHeader("Country");

grid.addThemeName(GridHelper.DENSE_THEME);
GridHelper.setDenseTheme(grid, true);

grid.setHeightFull();
add(grid);
Expand Down
Loading