diff options
author | Denis <denis@vaadin.com> | 2017-02-02 22:07:21 +0200 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-02-02 22:07:21 +0200 |
commit | 6456428004199f7f4d887579b460df96530c42b0 (patch) | |
tree | b54ee2ce835e69859ddcd1f3cb407baa0d81cd6f /client | |
parent | ab207e8bbeb6f3bf5b6a45e01ca5a4fb0e0c4f6a (diff) | |
download | vaadin-framework-6456428004199f7f4d887579b460df96530c42b0.tar.gz vaadin-framework-6456428004199f7f4d887579b460df96530c42b0.zip |
Add Grid editor events. (#8365)
* Migrate v7 Grid tests. Next round.
Fixes #8419
* Add Grid editor events.
Fixes #8202.
Diffstat (limited to 'client')
3 files changed, 13 insertions, 5 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/EditorConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/EditorConnector.java index fb76bc8c03..50704c4262 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/EditorConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/EditorConnector.java @@ -103,11 +103,12 @@ public class EditorConnector extends AbstractExtensionConnector { } @Override - public void cancel(EditorRequest<JsonObject> request) { + public void cancel(EditorRequest<JsonObject> request, + boolean afterBeingSaved) { if (!handleServerInitiated(request)) { // No startRequest as we don't get (or need) // a confirmation from the server - rpc.cancel(); + rpc.cancel(afterBeingSaved); } } diff --git a/client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java b/client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java index 97e8cbf297..6c23d8af87 100644 --- a/client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java +++ b/client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java @@ -156,10 +156,13 @@ public interface EditorHandler<T> { * * @param request * the cancel request + * @param afterBeingSaved + * if {@code true} then this method is called to close editor + * after save action, otherwise it represents a cancel action * * @see Grid#cancelEditor() */ - public void cancel(EditorRequest<T> request); + public void cancel(EditorRequest<T> request, boolean afterBeingSaved); /** * Commits changes in the currently active edit to the data source. Called diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index 19dfb79df6..9974505bd4 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -1388,7 +1388,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, public void onSuccess(EditorRequest<T> request) { if (state == State.SAVING) { cleanup(); - cancel(); + cancel(true); grid.clearSortOrder(); } } @@ -1640,6 +1640,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, * if this editor is not in edit mode */ public void cancel() { + cancel(false); + } + + private void cancel(boolean afterSave) { if (!enabled) { throw new IllegalStateException( "Cannot cancel edit: editor is not enabled"); @@ -1649,7 +1653,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, "Cannot cancel edit: editor is not in edit mode"); } handler.cancel(new EditorRequestImpl<>(grid, rowIndex, - focusedColumnIndex, null)); + focusedColumnIndex, null), afterSave); doCancel(); } |