From 9b510d35a7ec6b1a9504343b2620110b77d4e5c3 Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Tue, 18 Mar 2014 16:36:10 +0200 Subject: Adds setHeightByRow support to Grid (#13297) Change-Id: I67f1bfb476a8af28c0ea1a03758684ca42d1ba48 --- .../src/com/vaadin/shared/ui/grid/GridState.java | 24 +++++++++++++ .../src/com/vaadin/shared/ui/grid/HeightMode.java | 42 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 shared/src/com/vaadin/shared/ui/grid/HeightMode.java (limited to 'shared/src') diff --git a/shared/src/com/vaadin/shared/ui/grid/GridState.java b/shared/src/com/vaadin/shared/ui/grid/GridState.java index 93e602a539..8fdd8c8ec5 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridState.java @@ -28,6 +28,14 @@ import com.vaadin.shared.AbstractComponentState; * @author Vaadin Ltd */ public class GridState extends AbstractComponentState { + + /** + * The default value for height-by-rows for both GWT widgets + * {@link com.vaadin.ui.components.grid Grid} and + * {@link com.vaadin.client.ui.grid.Escalator Escalator} + */ + public static final double DEFAULT_HEIGHT_BY_ROWS = 10.0d; + { // FIXME Grid currently does not support undefined size width = "400px"; @@ -61,4 +69,20 @@ public class GridState extends AbstractComponentState { */ public String lastFrozenColumnId = null; + /** The height of the Grid in terms of body rows. */ + // @DelegateToWidget + /* + * Annotation doesn't work because of http://dev.vaadin.com/ticket/12900. + * Remove manual code from Connector once fixed + */ + public double heightByRows = DEFAULT_HEIGHT_BY_ROWS; + + /** The mode by which Grid defines its height. */ + // @DelegateToWidget + /* + * Annotation doesn't work because of http://dev.vaadin.com/ticket/12900. + * Remove manual code from Connector once fixed + */ + public HeightMode heightMode = HeightMode.CSS; + } diff --git a/shared/src/com/vaadin/shared/ui/grid/HeightMode.java b/shared/src/com/vaadin/shared/ui/grid/HeightMode.java new file mode 100644 index 0000000000..0146e53e73 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/grid/HeightMode.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui.grid; + +/** + * The modes for height calculation that are supported by Grid ( + * {@link com.vaadin.client.ui.grid.Grid client} and + * {@link com.vaadin.ui.components.grid.Grid server}) / + * {@link com.vaadin.client.ui.grid.Escalator Escalator}. + * + * @since 7.2 + * @author Vaadin Ltd + * @see com.vaadin.client.ui.grid.Grid#setHeightMode(HeightMode) + * @see com.vaadin.ui.components.grid.Grid#setHeightMode(HeightMode) + * @see com.vaadin.client.ui.grid.Escalator#setHeightMode(HeightMode) + */ +public enum HeightMode { + /** + * The height of the Component or Widget is defined by a CSS-like value. + * (e.g. "100px", "50em" or "25%") + */ + CSS, + + /** + * The height of the Component or Widget in question is defined by a number + * of rows. + */ + ROW; +} -- cgit v1.2.3 From 300c94c4b39e100cb506b476e08aa5e6626653b5 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Thu, 20 Mar 2014 16:16:33 +0200 Subject: Made some Grid classes Serializable. Change-Id: If784192dbfd9b8d23597fce493f93a51bb7d4907 --- server/src/com/vaadin/ui/components/grid/Grid.java | 5 +++-- shared/src/com/vaadin/shared/ui/grid/GridConstants.java | 4 +++- shared/src/com/vaadin/shared/ui/grid/Range.java | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'shared/src') diff --git a/server/src/com/vaadin/ui/components/grid/Grid.java b/server/src/com/vaadin/ui/components/grid/Grid.java index 7544f2b497..503ef0a1c4 100644 --- a/server/src/com/vaadin/ui/components/grid/Grid.java +++ b/server/src/com/vaadin/ui/components/grid/Grid.java @@ -16,6 +16,7 @@ package com.vaadin.ui.components.grid; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -46,9 +47,9 @@ import com.vaadin.shared.ui.grid.GridClientRpc; import com.vaadin.shared.ui.grid.GridColumnState; import com.vaadin.shared.ui.grid.GridServerRpc; import com.vaadin.shared.ui.grid.GridState; +import com.vaadin.shared.ui.grid.HeightMode; import com.vaadin.shared.ui.grid.Range; import com.vaadin.shared.ui.grid.ScrollDestination; -import com.vaadin.shared.ui.grid.HeightMode; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Component; @@ -86,7 +87,7 @@ public class Grid extends AbstractComponent { * Component hierarchy. * */ - private final class ActiveRowHandler { + private final class ActiveRowHandler implements Serializable { /** * A map from itemId to the value change listener used for all of its * properties diff --git a/shared/src/com/vaadin/shared/ui/grid/GridConstants.java b/shared/src/com/vaadin/shared/ui/grid/GridConstants.java index 5b88fad5a8..d5fdd40120 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridConstants.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridConstants.java @@ -15,6 +15,8 @@ */ package com.vaadin.shared.ui.grid; +import java.io.Serializable; + /** * Container class for common constants and default values used by the Grid * component. @@ -22,7 +24,7 @@ package com.vaadin.shared.ui.grid; * @since 7.2 * @author Vaadin Ltd */ -public final class GridConstants { +public final class GridConstants implements Serializable { /** * Default padding in pixels when scrolling programmatically, without an diff --git a/shared/src/com/vaadin/shared/ui/grid/Range.java b/shared/src/com/vaadin/shared/ui/grid/Range.java index 3114a79c82..2593f7afd9 100644 --- a/shared/src/com/vaadin/shared/ui/grid/Range.java +++ b/shared/src/com/vaadin/shared/ui/grid/Range.java @@ -16,6 +16,8 @@ package com.vaadin.shared.ui.grid; +import java.io.Serializable; + /** * An immutable representation of a range, marked by start and end points. *

@@ -28,7 +30,7 @@ package com.vaadin.shared.ui.grid; * @since 7.2 * @author Vaadin Ltd */ -public final class Range { +public final class Range implements Serializable { private final int start; private final int end; -- cgit v1.2.3