aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java8
-rw-r--r--server/src/com/vaadin/ui/Grid.java1
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java39
4 files changed, 40 insertions, 17 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index e10da5494a..ccc909465f 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -5582,6 +5582,14 @@ public class Grid<T> extends ResizeComposite implements
@Override
public void onStart() {
initialWidth = col.getWidthActual();
+
+ for (Column<?, T> c : getColumns()) {
+ if (c.getWidth() < 0) {
+ c.setWidth(c.getWidthActual());
+ fireEvent(new ColumnResizeEvent<T>(
+ c));
+ }
+ }
}
@Override
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 65d7d8e2d2..e80f703c16 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -4705,6 +4705,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
if (column != null && column.isResizable()) {
column.getState().width = pixels;
fireColumnResizeEvent(column, true);
+ markAsDirty();
}
}
});
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
index 2e4869cab0..94ee3ef348 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -363,10 +363,9 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
});
grid.addColumnResizeListener(new ColumnResizeListener() {
-
@Override
public void columnResize(ColumnResizeEvent event) {
- log("ColumnResizeEvent : isUserOriginated? "
+ log("ColumnResizeEvent: isUserOriginated? "
+ event.isUserOriginated());
}
});
@@ -1189,17 +1188,17 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}, c);
}
- createBooleanAction("All columns resizable", "Columns", false,
+ createClickAction("All columns auto width", "Columns",
new Command<Grid, Boolean>() {
@Override
public void execute(Grid c, Boolean value, Object data) {
for (Column col : grid.getColumns()) {
- col.setResizable(value);
+ col.setWidthUndefined();
}
}
- });
+ }, null);
createBooleanAction("All columns hidable", "Columns", false,
new Command<Grid, Boolean>() {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java
index 7c62571cb1..4345cc6f07 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java
@@ -77,6 +77,33 @@ public class GridColumnResizeTest extends GridBasicFeaturesTest {
}
}
+ @Test
+ public void testResizeFirstColumn() {
+ dragResizeColumn(0, -10);
+ assertTrue("Log should contain a resize event",
+ logContainsText("ColumnResizeEvent: isUserOriginated? true"));
+ }
+
+ @Test
+ public void testColumnPixelSizesSetOnResize() {
+ selectMenuPath("Component", "Columns", "All columns auto width");
+ dragResizeColumn(0, -10);
+ for (String msg : getLogs()) {
+ assertTrue("Log should contain a resize event",
+ msg.contains("ColumnResizeEvent: isUserOriginated? true"));
+ }
+ }
+
+ private void dragResizeColumn(int columnIndex, int offset) {
+ GridCellElement headerCell = getGridElement().getHeaderCell(0,
+ columnIndex);
+ Dimension size = headerCell.getSize();
+ new Actions(getDriver())
+ .moveToElement(headerCell, size.getWidth() - 1,
+ size.getHeight() / 2).clickAndHold()
+ .moveByOffset(offset, 0).release().perform();
+ }
+
private void assertResizable(int columnIndex, boolean resizable) {
assertResizable(getGridElement().getHeaderCell(0, columnIndex),
resizable);
@@ -87,16 +114,4 @@ public class GridColumnResizeTest extends GridBasicFeaturesTest {
cell.isElementPresent(By
.cssSelector("div.v-grid-column-resize-handle")));
}
-
- @Test
- public void testResizeFirstColumn() {
- GridCellElement headerCell = getGridElement().getHeaderCell(0, 0);
- Dimension size = headerCell.getSize();
- new Actions(getDriver())
- .moveToElement(headerCell, size.getWidth() - 1,
- size.getHeight() / 2).clickAndHold()
- .moveByOffset(-10, 0).release().perform();
- assertTrue("Log did not contain a resize event.",
- logContainsText("ColumnResizeEvent : isUserOriginated? true"));
- }
}