diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-11-10 15:46:57 +0100 |
---|---|---|
committer | Péter Török <31210544+torok-peter@users.noreply.github.com> | 2017-11-10 16:46:57 +0200 |
commit | 37bd6b1a32c9d5d6a53755de8bb1a94556b4471b (patch) | |
tree | be2f97ccada0e6c261536450da29e62bf5d871c9 /client | |
parent | fe2b4d941fdfe06fbb79d3e9168618592136c337 (diff) | |
download | vaadin-framework-37bd6b1a32c9d5d6a53755de8bb1a94556b4471b.tar.gz vaadin-framework-37bd6b1a32c9d5d6a53755de8bb1a94556b4471b.zip |
Add ContentMode for row and cell descriptions in Grid (#10282)
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java | 31 | ||||
-rw-r--r-- | client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java | 12 |
2 files changed, 37 insertions, 6 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java index e46a01c1ae..4112a29e6b 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java @@ -23,6 +23,7 @@ import com.vaadin.client.widgets.Grid.Column; import com.vaadin.client.widgets.Grid.HeaderCell; import com.vaadin.shared.data.DataCommunicatorConstants; import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.ContentMode; import com.vaadin.shared.ui.grid.ColumnState; import elemental.json.JsonObject; @@ -41,6 +42,7 @@ public class ColumnConnector extends AbstractExtensionConnector { extends Column<Object, JsonObject> { private final String connectorId; + private ContentMode contentMode; CustomColumn(String connectorId) { this.connectorId = connectorId; @@ -54,6 +56,29 @@ public class ColumnConnector extends AbstractExtensionConnector { protected void setDefaultHeaderContent(HeaderCell cell) { // NO-OP, Server takes care of header contents. } + + /** + * Gets the content mode for tooltips in this column. + * + * @return the content mode. + * + * @since 8.2 + */ + public ContentMode getContentMode() { + return contentMode; + } + + /** + * Sets the content mode for tooltips in this column. + * + * @param contentMode + * the content mode for tooltips + * + * @since 8.2 + */ + public void setContentMode(ContentMode contentMode) { + this.contentMode = contentMode; + } } private CustomColumn column; @@ -164,6 +189,11 @@ public class ColumnConnector extends AbstractExtensionConnector { column.setEditable(getState().editable); } + @OnStateChange("contentMode") + void updateContentMode() { + column.setContentMode(getState().contentMode); + } + @Override public void onUnregister() { super.onUnregister(); @@ -186,5 +216,4 @@ public class ColumnConnector extends AbstractExtensionConnector { public ColumnState getState() { return (ColumnState) super.getState(); } - } diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java index eb7277af54..14d5b297eb 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java @@ -256,8 +256,7 @@ public class GridConnector extends AbstractListingConnector grid.setRowStyleGenerator(rowRef -> { JsonObject json = rowRef.getRow(); return json.hasKey(GridState.JSONKEY_ROWSTYLE) - ? json.getString(GridState.JSONKEY_ROWSTYLE) - : null; + ? json.getString(GridState.JSONKEY_ROWSTYLE) : null; }); grid.setCellStyleGenerator(cellRef -> { JsonObject row = cellRef.getRow(); @@ -631,12 +630,15 @@ public class GridConnector extends AbstractListingConnector .getObject(GridState.JSONKEY_CELLDESCRIPTION); String id = ((CustomColumn) column).getConnectorId(); + if (cellDescriptions != null && cellDescriptions.hasKey(id)) { - return new TooltipInfo(cellDescriptions.getString(id)); + return new TooltipInfo(cellDescriptions.getString(id), + ((CustomColumn) column).getContentMode()); } else if (row.hasKey(GridState.JSONKEY_ROWDESCRIPTION)) { - return new TooltipInfo(row - .getString(GridState.JSONKEY_ROWDESCRIPTION)); + return new TooltipInfo( + row.getString(GridState.JSONKEY_ROWDESCRIPTION), + getState().rowDescriptionContentMode); } } } |