summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/connectors/GridConnector.java8
-rw-r--r--client/src/com/vaadin/client/ui/dd/DragHandle.java3
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java13
-rw-r--r--server/src/com/vaadin/ui/Grid.java9
-rw-r--r--shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java13
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java11
6 files changed, 49 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java
index 82fe3d9279..60a9aacb88 100644
--- a/client/src/com/vaadin/client/connectors/GridConnector.java
+++ b/client/src/com/vaadin/client/connectors/GridConnector.java
@@ -193,6 +193,14 @@ public class GridConnector extends AbstractHasComponentsConnector implements
return null;
}
+ @Override
+ protected void setWidth(double pixels, boolean userOriginated) {
+ super.setWidth(pixels, userOriginated);
+ if (userOriginated) {
+ getRpcProxy(GridServerRpc.class).columnResized(id, pixels);
+ }
+ }
+
private AbstractFieldConnector getEditorConnector() {
return editorConnector;
}
diff --git a/client/src/com/vaadin/client/ui/dd/DragHandle.java b/client/src/com/vaadin/client/ui/dd/DragHandle.java
index c3a0768a72..ef4f94d18f 100644
--- a/client/src/com/vaadin/client/ui/dd/DragHandle.java
+++ b/client/src/com/vaadin/client/ui/dd/DragHandle.java
@@ -127,8 +127,7 @@ public class DragHandle {
@Override
public void onDragEnd() {
- removeDraggingStyle();
- userCallback.onComplete();
+ // NOP, handled in onDrop and onDragCancel
}
@Override
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index 1e1c89234b..e01edcddd7 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -2798,6 +2798,7 @@ public class Grid<T> extends ResizeComposite implements
setWidth(-1);
setEditable(false);
+ setResizable(false);
initDone = true;
}
@@ -4759,13 +4760,17 @@ public class Grid<T> extends ResizeComposite implements
* the width in pixels or negative for auto sizing
*/
public Column<C, T> setWidth(double pixels) {
+ setWidth(pixels, false);
+ return this;
+ }
+
+ protected void setWidth(double pixels, boolean userOriginated) {
if (!WidgetUtil.pixelValuesEqual(widthUser, pixels)) {
widthUser = pixels;
if (!isHidden()) {
scheduleColumnWidthRecalculator();
}
}
- return this;
}
void doSetWidth(double pixels) {
@@ -5572,7 +5577,7 @@ public class Grid<T> extends ResizeComposite implements
@Override
public void onUpdate(double deltaX,
double deltaY) {
- col.setWidth(initialWidth + deltaX);
+ col.setWidth(initialWidth + deltaX, false);
}
@Override
@@ -5582,12 +5587,12 @@ public class Grid<T> extends ResizeComposite implements
@Override
public void onComplete() {
- // NOP
+ col.setWidth(col.getWidthActual(), true);
}
@Override
public void onCancel() {
- col.setWidth(initialWidth);
+ col.setWidth(initialWidth, false);
}
});
dragger.addTo(td);
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 8aa3e90929..8d8b0fe8e3 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -4267,11 +4267,18 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
if (rowKey != null) {
itemId = getKeyMapper().get(rowKey);
}
-
fireEvent(new GridContextClickEvent(Grid.this, details,
section, rowIndex, itemId,
getPropertyIdByColumnId(columnId)));
}
+
+ @Override
+ public void columnResized(String id, double pixels) {
+ final Column column = getColumnByColumnId(id);
+ if (column != null && column.isResizable()) {
+ column.getState().width = pixels;
+ }
+ }
});
registerRpc(new EditorServerRpc() {
diff --git a/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java b/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java
index b129cbf051..efcb9427b0 100644
--- a/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java
+++ b/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java
@@ -76,7 +76,7 @@ public interface GridServerRpc extends ServerRpc {
List<String> oldColumnOrder);
/**
- * Informs the server that the column's visibility has been changed.
+ * Informs the server that a column's visibility has been changed.
*
* @since 7.5.0
* @param id
@@ -89,4 +89,15 @@ public interface GridServerRpc extends ServerRpc {
*/
void columnVisibilityChanged(String id, boolean hidden,
boolean userOriginated);
+
+ /**
+ * Informs the server that a column has been resized by the user.
+ *
+ * @since
+ * @param id
+ * the id of the column
+ * @param pixels
+ * the new width of the column in pixels
+ */
+ void columnResized(String id, double pixels);
}
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 e761df2b20..30cc8a2b13 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -1201,6 +1201,17 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
});
+ createBooleanAction("All columns resizable", "Columns", false,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid c, Boolean value, Object data) {
+ for (Column col : grid.getColumns()) {
+ col.setResizable(value);
+ }
+
+ }
+ });
createClickAction("All columns expanding, Col 0 has max width of 30px",
"Columns", new Command<Grid, Boolean>() {