diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2015-03-23 13:42:07 +0200 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2015-03-31 13:51:09 +0000 |
commit | 0e7755958b46434185cb1e6e2ec8aa6932b32f34 (patch) | |
tree | 4e39eb62bcab3c2a03a3cc5d7b98e60e1ab943fb /client | |
parent | 844b2c6c41d57d4db1238eb6096f225c9fdb8314 (diff) | |
download | vaadin-framework-0e7755958b46434185cb1e6e2ec8aa6932b32f34.tar.gz vaadin-framework-0e7755958b46434185cb1e6e2ec8aa6932b32f34.zip |
API for column hiding toggle caption in Grid (#17272)
Fixes column toggle not getting a caption when a hidable column is added.
Fixes column toggle not getting a caption on columns with widget in header.
Change-Id: Ie10ada793a3635302603f684f232cadaef74a982
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/connectors/GridConnector.java | 1 | ||||
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 52 |
2 files changed, 42 insertions, 11 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 0e2ee0046b..5554664566 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -1197,6 +1197,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements column.setHidden(state.hidden); column.setHidable(state.hidable); + column.setHidingToggleCaption(state.hidingToggleCaption); column.setEditable(state.editable); column.setEditorConnector((AbstractFieldConnector) state.editorConnector); diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 20b8844623..f9c6ed28fe 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -3096,7 +3096,7 @@ public class Grid<T> extends ResizeComposite implements column.setHidden(!event.getValue(), true); } }); - updateColumnHidingToggleCaption(column, toggle); + updateHidingToggleCaption(column, toggle); columnToHidingToggleMap.put(column, toggle); return toggle; } @@ -3133,22 +3133,20 @@ public class Grid<T> extends ResizeComposite implements hasValue.setStyleName("hidden", hidden); } - private void updateColumnHidingToggleCaption(Column<?, T> column) { - updateColumnHidingToggleCaption(column, + private void updateHidingToggleCaption(Column<?, T> column) { + updateHidingToggleCaption(column, columnToHidingToggleMap.get(column)); } - private void updateColumnHidingToggleCaption(Column<?, T> column, + private void updateHidingToggleCaption(Column<?, T> column, ToggleButton toggle) { - String caption = column.headerCaption; - if (caption == null || caption.isEmpty()) { - // TODO what if the content is a widget? - HeaderCell cell = getDefaultHeaderRow().getCell(column); - caption = cell.getText(); + String caption = column.getHidingToggleCaption(); + if (caption == null) { + caption = column.headerCaption; + // the caption might still be null, but that is the users fault } toggle.setText(caption); } - } /** @@ -3782,6 +3780,8 @@ public class Grid<T> extends ResizeComposite implements private String headerCaption = ""; + private String hidingToggleCaption = null; + private double minimumWidthPx = GridConstants.DEFAULT_MIN_WIDTH; private double maximumWidthPx = GridConstants.DEFAULT_MAX_WIDTH; private int expandRatio = GridConstants.DEFAULT_EXPAND_RATIO; @@ -3891,7 +3891,7 @@ public class Grid<T> extends ResizeComposite implements if (row != null) { row.getCell(this).setText(headerCaption); if (isHidable()) { - grid.columnHider.updateColumnHidingToggleCaption(this); + grid.columnHider.updateHidingToggleCaption(this); } } } @@ -4143,6 +4143,36 @@ public class Grid<T> extends ResizeComposite implements return hidable; } + /** + * Sets the hiding toggle's caption for this column. Shown in the toggle + * for this column in the grid's sidebar when the column is + * {@link #isHidable() hidable}. + * <p> + * Defaults to <code>null</code>, when will use whatever is set with + * {@link #setHeaderCaption(String)}. + * + * @since + * @param hidingToggleCaption + * the caption for the hiding toggle for this column + */ + public void setHidingToggleCaption(String hidingToggleCaption) { + this.hidingToggleCaption = hidingToggleCaption; + if (isHidable()) { + grid.columnHider.updateHidingToggleCaption(this); + } + } + + /** + * Gets the hiding toggle caption for this column. + * + * @since + * @see #setHidingToggleCaption(String) + * @return the hiding toggle's caption for this column + */ + public String getHidingToggleCaption() { + return hidingToggleCaption; + } + @Override public String toString() { String details = ""; |