Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,45 @@

/** 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

Check warning on line 90 in src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelper.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add 'since' and/or 'forRemoval' arguments to the @Deprecated annotation.

See more on https://sonarcloud.io/project/issues?id=FlowingCode_GridHelpers&issues=AZ0uhgaHhrzf4po1ZDlA&open=AZ0uhgaHhrzf4po1ZDlA&pullRequest=175
public static final String DENSE_THEME = DENSE_THEME_NAME;

Check warning on line 91 in src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelper.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=FlowingCode_GridHelpers&issues=AZ0uhgaHhrzf4po1ZDlB&open=AZ0uhgaHhrzf4po1ZDlB&pullRequest=175

/**
* 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