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
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
@JsModule("./flow-component-renderer.js")
@JsModule("./gridConnector.ts")
@JsModule("@vaadin/tooltip/src/vaadin-tooltip.js")
public class Grid<T> extends Component implements HasStyle, HasSize,

Check warning on line 225 in vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this “Monster Class” into smaller and more specialized ones to reduce its dependencies on other classes from 40 to the maximum authorized 20 or less.

See more on https://sonarcloud.io/project/issues?id=vaadin_flow-components&issues=AZ8nZZ7yU-ygzfhgD9FB&open=AZ8nZZ7yU-ygzfhgD9FB&pullRequest=9667
Focusable<Grid<T>>, SortNotifier<Grid<T>, GridSortOrder<T>>, HasTheme,
HasDataGenerators<T>, HasListDataView<T, GridListDataView<T>>,
HasDataView<T, Void, GridDataView<T>>,
Expand Down Expand Up @@ -1356,6 +1356,8 @@

private final CompositeDataGenerator<T> gridDataGenerator;
private final DataCommunicator<T> dataCommunicator;
@SuppressWarnings("rawtypes")
private DataCommunicatorBuilder dataCommunicatorBuilder;

Check warning on line 1360 in vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this variable to comply with Java Code Conventions.

See more on https://sonarcloud.io/project/issues?id=vaadin_flow-components&issues=AZ8nZZ7yU-ygzfhgD9FC&open=AZ8nZZ7yU-ygzfhgD9FC&pullRequest=9667

Check warning on line 1360 in vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this call to a deprecated class, it has been marked for removal.

See more on https://sonarcloud.io/project/issues?id=vaadin_flow-components&issues=AZ8nZZ7yU-ygzfhgD9FD&open=AZ8nZZ7yU-ygzfhgD9FD&pullRequest=9667

private int nextColumnId = 0;

Expand Down Expand Up @@ -1564,7 +1566,10 @@
* the data communicator builder type
* @param <U>
* the GridArrayUpdater type
* @deprecated Override {@link #createDataCommunicator()} instead. This
* constructor will be removed in Vaadin 26.
*/
@Deprecated(since = "25.3", forRemoval = true)
protected <U extends GridArrayUpdater, B extends DataCommunicatorBuilder<T, U>> Grid(
Class<T> beanType, B dataCommunicatorBuilder) {
this(beanType, dataCommunicatorBuilder, true);
Expand Down Expand Up @@ -1597,7 +1602,10 @@
* @param autoCreateColumns
* when <code>true</code>, columns are created automatically for
* the properties of the beanType
* @deprecated Override {@link #createDataCommunicator()} instead. This
* constructor will be removed in Vaadin 26.
*/
@Deprecated(since = "25.3", forRemoval = true)
protected <U extends GridArrayUpdater, B extends DataCommunicatorBuilder<T, U>> Grid(
Class<T> beanType, B dataCommunicatorBuilder,
boolean autoCreateColumns) {
Expand Down Expand Up @@ -1625,12 +1633,15 @@
* the data communicator builder type
* @param <U>
* the GridArrayUpdater type
* @deprecated Override {@link #createDataCommunicator()} instead. This
* constructor will be removed in Vaadin 26.
*/
@SuppressWarnings("unchecked")
@Deprecated(since = "25.3", forRemoval = true)
protected <U extends GridArrayUpdater, B extends DataCommunicatorBuilder<T, U>> Grid(
int pageSize, B dataCommunicatorBuilder) {
Objects.requireNonNull(dataCommunicatorBuilder,
"Data communicator builder can't be null");
this.dataCommunicatorBuilder = dataCommunicatorBuilder;
arrayUpdater = createDefaultArrayUpdater();
gridDataGenerator = new CompositeDataGenerator<>();
gridDataGenerator.addDataGenerator(this::generateUniqueKeyData);
Expand All @@ -1640,9 +1651,7 @@
gridDataGenerator.addDataGenerator(this::generateDragData);
gridDataGenerator.addDataGenerator(this::generateSelectableData);

dataCommunicator = dataCommunicatorBuilder.build(getElement(),
gridDataGenerator, (U) arrayUpdater,
this::getUniqueKeyProvider);
dataCommunicator = createDataCommunicator();

detailsManager = new DetailsManager(this);
setPageSize(pageSize);
Expand Down Expand Up @@ -1725,6 +1734,20 @@
getElement());
}

/**
* Creates the {@link DataCommunicator} that this Grid uses to handle all
* data communication.
*
* @return the new data communicator
*
* @since 25.3
*/
Comment on lines +1737 to +1744

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a @since 25.3 mention here and in the other method below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added.

protected DataCommunicator<T> createDataCommunicator() {
return dataCommunicatorBuilder.build(getElement(),

Check warning on line 1746 in vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this call to a deprecated method, it has been marked for removal.

See more on https://sonarcloud.io/project/issues?id=vaadin_flow-components&issues=AZ8ncWjrXO-nRr9hvHWq&open=AZ8ncWjrXO-nRr9hvHWq&pullRequest=9667
getCompositeDataGenerator(), getArrayUpdater(),
this::getUniqueKeyProvider);
}

/**
* Builder for {@link DataCommunicator} object.
*
Expand All @@ -1733,7 +1756,11 @@
*
* @param <U>
* the ArrayUpdater type
* @deprecated Override {@link #createDataCommunicator()} instead. This
* class and the constructors that accept it will be removed in
* Vaadin 26.
*/
@Deprecated(since = "25.3", forRemoval = true)
protected static class DataCommunicatorBuilder<T, U extends ArrayUpdater>
implements Serializable {

Expand All @@ -1753,6 +1780,7 @@
* communicator
* @return the build data communicator object
*/
@Deprecated(since = "25.3", forRemoval = true)
protected DataCommunicator<T> build(Element element,
CompositeDataGenerator<T> dataGenerator, U arrayUpdater,
SerializableSupplier<ValueProvider<T, String>> uniqueKeyProviderSupplier) {
Expand Down Expand Up @@ -4494,6 +4522,18 @@
return arrayUpdater;
}

/**
* Gets the {@link CompositeDataGenerator} that this Grid uses to generate
* data for the client side.
*
* @return the composite data generator
*
* @since 25.3
*/
protected CompositeDataGenerator<T> getCompositeDataGenerator() {
return gridDataGenerator;
}

/**
* Callback which is called if a new data provider is set or any change
* happen in the current data provider (an {@link DataChangeEvent} event is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ public TreeGrid() {
* @param dataCommunicatorBuilder
* Builder for {@link DataCommunicator} implementation this Grid
* uses to handle all data communication.
* @deprecated Override {@link #createDataCommunicator()} instead. This
* constructor will be removed in Vaadin 26.
*/
@Deprecated(since = "25.3", forRemoval = true)
protected TreeGrid(int pageSize,
DataCommunicatorBuilder<T, GridArrayUpdater> dataCommunicatorBuilder) {
super(pageSize, dataCommunicatorBuilder);
Expand Down Expand Up @@ -186,12 +189,16 @@ public TreeGrid(Class<T> beanType, boolean autoCreateColumns) {
* @param dataCommunicatorBuilder
* Builder for {@link DataCommunicator} implementation this Grid
* uses to handle all data communication.
* @deprecated Override {@link #createDataCommunicator()} instead. This
* constructor will be removed in Vaadin 26.
*/
@Deprecated(since = "25.3", forRemoval = true)
protected TreeGrid(Class<T> beanType,
DataCommunicatorBuilder<T, GridArrayUpdater> dataCommunicatorBuilder) {
this(beanType, dataCommunicatorBuilder, true);
}

@Deprecated(since = "25.3", forRemoval = true)
private TreeGrid(Class<T> beanType,
DataCommunicatorBuilder<T, GridArrayUpdater> dataCommunicatorBuilder,
boolean autoCreateColumns) {
Expand Down
Loading