diff options
Diffstat (limited to 'compatibility-client')
-rwxr-xr-x | compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java index 4a7265a525..abfe761d4a 100755 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java @@ -2940,6 +2940,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, private CheckBox selectAllCheckBox; private boolean userSelectionAllowed = true; private boolean enabled = true; + private HandlerRegistration headerClickHandler; SelectionColumn(final Renderer<Boolean> selectColumnRenderer) { super(selectColumnRenderer); @@ -2993,24 +2994,28 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, }); selectAllCheckBox.setValue(selected); - addHeaderClickHandler(new HeaderClickHandler() { - @Override - public void onClick(GridClickEvent event) { - if (!userSelectionAllowed) { - return; - } - - CellReference<?> targetCell = event.getTargetCell(); - int defaultRowIndex = getHeader().getRows() - .indexOf(getDefaultHeaderRow()); + headerClickHandler = addHeaderClickHandler( + new HeaderClickHandler() { + @Override + public void onClick(GridClickEvent event) { + if (!userSelectionAllowed) { + return; + } - if (targetCell.getColumnIndex() == 0 && targetCell - .getRowIndex() == defaultRowIndex) { - selectAllCheckBox.setValue( - !selectAllCheckBox.getValue(), true); - } - } - }); + CellReference<?> targetCell = event + .getTargetCell(); + int defaultRowIndex = getHeader().getRows() + .indexOf(getDefaultHeaderRow()); + + if (targetCell.getColumnIndex() == 0 + && targetCell + .getRowIndex() == defaultRowIndex) { + selectAllCheckBox.setValue( + !selectAllCheckBox.getValue(), + true); + } + } + }); // Select all with space when "select all" cell is active addHeaderKeyUpHandler(new HeaderKeyUpHandler() { @@ -3149,6 +3154,13 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, getEscalator().getBody().refreshRows(0, getEscalator().getBody().getRowCount()); } + + private void cleanup() { + if (headerClickHandler != null) { + headerClickHandler.removeHandler(); + headerClickHandler = null; + } + } } /** @@ -7927,6 +7939,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, return; } + if (this.selectionColumn != null) { + selectionColumn.cleanup(); + } + if (this.selectColumnRenderer != null) { if (this.selectColumnRenderer instanceof ComplexRenderer) { // End of Life for the old selection column renderer. |