Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement multi selection in Grid #2522

Merged
merged 17 commits into from
Oct 10, 2017
Merged

Implement multi selection in Grid #2522

merged 17 commits into from
Oct 10, 2017

Conversation

ahie
Copy link
Contributor

@ahie ahie commented Sep 27, 2017

Additionally adds shorthand methods to Grid
for managing selection.

Closes #2424


This change is Reviewable

@ahie
Copy link
Contributor Author

ahie commented Sep 27, 2017

Review status: 0 of 11 files reviewed at latest revision, 1 unresolved discussion.


a discussion (no related file):
Still WIP tests and select all support. Otherwise ready for review.


Comments from Reviewable

@denis-anisimov
Copy link
Contributor

Reviewed 11 of 11 files at r1.
Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


flow-components-parent/flow-components/src/main/java/com/vaadin/ui/grid/Grid.java, line 321 at r1 (raw file):

grid.getDataCommunicator().reset();

Why ?
DataCommunicator will update data on reset. How does it relate to the selection update ?


flow-components-parent/flow-components/src/main/java/com/vaadin/ui/grid/GridNoneSelectionModel.java, line 78 at r1 (raw file):

throw new UnsupportedOperationException(
"This selection model doesn't allow selection, cannot add selection listeners to it"

Does it confirm to the FW8 code ?

I don't see why I can't add a listener to the model. I will never get events - that's the only difference.
(I can have a code that change the model on the fly from one to another. They have common interface, so I can just add a listener regardless of the real model implementation. And I don't want to catch an exception in this case).


flow-data/src/main/java/com/vaadin/data/selection/SingleSelectionListener.java, line 48 at r1 (raw file):

     */
    public void selectionChange(SingleSelectionEvent<L, T> event);
}

new line


Comments from Reviewable

@denis-anisimov
Copy link
Contributor

Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks failed.


flow-data/src/main/java/com/vaadin/data/selection/MultiSelectionEvent.java, line 133 at r1 (raw file):

        return copy;
    }
}

new line


Comments from Reviewable

Additionally adds shorthand methods to Grid
for managing selection.

Closes #2424
@ahie
Copy link
Contributor Author

ahie commented Sep 28, 2017

Review status: 9 of 11 files reviewed at latest revision, 5 unresolved discussions.


flow-components-parent/flow-components/src/main/java/com/vaadin/ui/grid/Grid.java, line 321 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…

grid.getDataCommunicator().reset();

Why ?
DataCommunicator will update data on reset. How does it relate to the selection update ?

Rows will get pushed again to the client, with the updated selection information. After #2524 is implemented this should really only call refreshItem on the items whose selection changed.


flow-components-parent/flow-components/src/main/java/com/vaadin/ui/grid/GridNoneSelectionModel.java, line 78 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…

throw new UnsupportedOperationException(
"This selection model doesn't allow selection, cannot add selection listeners to it"

Does it confirm to the FW8 code ?

I don't see why I can't add a listener to the model. I will never get events - that's the only difference.
(I can have a code that change the model on the fly from one to another. They have common interface, so I can just add a listener regardless of the real model implementation. And I don't want to catch an exception in this case).

Yes, FW8 also behaves in this way. You are right, but I don't think we should change it, especially with addSelectionListener convenience method being directly in Grid.


flow-data/src/main/java/com/vaadin/data/selection/MultiSelectionEvent.java, line 133 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…

new line

Done.


flow-data/src/main/java/com/vaadin/data/selection/SingleSelectionListener.java, line 48 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…

new line

Done.


Comments from Reviewable

@denis-anisimov
Copy link
Contributor

Reviewed 4 of 4 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


flow-components-parent/flow-components/src/main/java/com/vaadin/ui/grid/Grid.java, line 321 at r1 (raw file):

Previously, ahie (Aleksi Hietanen) wrote…

Rows will get pushed again to the client, with the updated selection information. After #2524 is implemented this should really only call refreshItem on the items whose selection changed.

So the selection is a part of the item DTO ?
It's not a separate call with only selected items ?


Comments from Reviewable

@ahie
Copy link
Contributor Author

ahie commented Sep 28, 2017

Review status: 9 of 13 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


a discussion (no related file):

Previously, ahie (Aleksi Hietanen) wrote…

Still WIP tests and select all support. Otherwise ready for review.

Considering creating a separate issue for select all and dynamically adding/removing a selection column on the client side. Currently the client side grid just blows up if you attempt to add a <grid-selection-column> dynamically. Better to have at least some form of multi selection than none at all I would say.


flow-components-parent/flow-components/src/main/java/com/vaadin/ui/grid/Grid.java, line 321 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…

So the selection is a part of the item DTO ?
It's not a separate call with only selected items ?

That's correct and also closer to how it was done in FW8 with data generators.


Comments from Reviewable

@ahie ahie changed the title [WIP] Implement multi selection in Grid Implement multi selection in Grid Sep 28, 2017
@denis-anisimov
Copy link
Contributor

Reviewed 4 of 5 files at r3.
Review status: 13 of 14 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable

@denis-anisimov
Copy link
Contributor

Reviewed 1 of 5 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable

@denis-anisimov
Copy link
Contributor

Reviewed 3 of 4 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable


@Override
public MultiSelect<Grid<T>, T> asMultiSelect() {
return new MultiSelect<Grid<T>, T>() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

MAJOR Reduce this anonymous class number of lines from 34 to at most 20, or make it a named class. rule

@@ -215,7 +257,170 @@ public Registration addValueChangeListener(
MULTI {
@Override
protected <T> GridSelectionModel<T> createModel(Grid<T> grid) {
throw new UnsupportedOperationException("Not implemented yet.");
return new GridMultiSelectionModel<T>() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

MAJOR Reduce this anonymous class number of lines from 142 to at most 20, or make it a named class. rule

throw new UnsupportedOperationException("Not implemented yet.");
return new GridMultiSelectionModel<T>() {

Set<T> selected = new LinkedHashSet<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

MAJOR Make "selected" transient or serializable. rule

@@ -191,6 +199,8 @@ public T getValue() {
@Override
public Registration addValueChangeListener(
ValueChangeListener<Grid<T>, T> listener) {
Objects.requireNonNull(listener,
"listener cannot be null");
Copy link
Collaborator

Choose a reason for hiding this comment

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

CRITICAL Define a constant instead of duplicating this literal "listener cannot be null" 6 times. rule

@ahie
Copy link
Contributor Author

ahie commented Sep 29, 2017

Review status: 10 of 15 files reviewed at latest revision, 5 unresolved discussions, some commit checks broke.


a discussion (no related file):

Previously, ahie (Aleksi Hietanen) wrote…

Considering creating a separate issue for select all and dynamically adding/removing a selection column on the client side. Currently the client side grid just blows up if you attempt to add a <grid-selection-column> dynamically. Better to have at least some form of multi selection than none at all I would say.

Created a new issue about this: #2546.


Comments from Reviewable

@denis-anisimov
Copy link
Contributor

Reviewed 5 of 5 files at r5.
Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks broke.


Comments from Reviewable

@vaadin-bot
Copy link
Collaborator

SonarQube analysis reported 5 issues

  • CRITICAL 1 critical
  • MAJOR 3 major
  • INFO 1 info

Watch the comments in this conversation to review them.

1 extra issue

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. INFO Grid.java#L165: Potentially ambiguous invocation of either an outer or inherited method com.vaadin.ui.grid.Grid$SelectionMode$1$1.deselectAll() in com.vaadin.ui.grid.Grid$SelectionMode$1$1.remove() rule

@denis-anisimov
Copy link
Contributor

Reviewed 1 of 2 files at r6.
Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks broke.


Comments from Reviewable

@ahie ahie merged commit 78d6bbb into master Oct 10, 2017
@ahie ahie deleted the 2424-grid-multi-select branch October 10, 2017 12:34
@ahie ahie removed the in progress label Oct 10, 2017
@ZheSun88 ZheSun88 modified the milestone: 1.0.0.alpha5 Oct 12, 2017
@SomeoneToIgnore SomeoneToIgnore added this to the 1.0.0.alpha6 milestone Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants