From 4f41def1e6cae667d4c39bbff8664895e46d7a76 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 11 Dec 2014 17:07:15 +0200 Subject: Remove editor row discard methods; rename "commit" to "save" (#13334) Change-Id: Ic7cec3c3750db8a2e0b23a4d38f63e9642999e3e --- .../vaadin/client/connectors/GridConnector.java | 20 +------ .../vaadin/client/ui/grid/EditorRowHandler.java | 22 ++------ client/src/com/vaadin/client/ui/grid/Grid.java | 64 +++++----------------- 3 files changed, 23 insertions(+), 83 deletions(-) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index e68c936ace..6f6dffee8c 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -195,12 +195,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements GridConnector.this.getWidget().editRow(rowIndex); } - @Override - public void discard(int rowIndex) { - serverInitiated = true; - GridConnector.this.getWidget().discardEditorRow(); - } - @Override public void cancel(int rowIndex) { serverInitiated = true; @@ -213,7 +207,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements } @Override - public void confirmCommit() { + public void confirmSave() { endRequest(); } }); @@ -228,18 +222,10 @@ public class GridConnector extends AbstractHasComponentsConnector implements } @Override - public void commit(EditorRowRequest request) { - if (!handleServerInitiated(request)) { - startRequest(request); - rpc.commit(request.getRowIndex()); - } - } - - @Override - public void discard(EditorRowRequest request) { + public void save(EditorRowRequest request) { if (!handleServerInitiated(request)) { startRequest(request); - rpc.discard(request.getRowIndex()); + rpc.save(request.getRowIndex()); } } diff --git a/client/src/com/vaadin/client/ui/grid/EditorRowHandler.java b/client/src/com/vaadin/client/ui/grid/EditorRowHandler.java index 3d82f011d9..04ca7f6cf0 100644 --- a/client/src/com/vaadin/client/ui/grid/EditorRowHandler.java +++ b/client/src/com/vaadin/client/ui/grid/EditorRowHandler.java @@ -16,6 +16,7 @@ package com.vaadin.client.ui.grid; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ui.grid.Grid.EditorRow; /** * An interface for binding widgets and data to the editor row. Used by the @@ -149,26 +150,13 @@ public interface EditorRowHandler { public void cancel(EditorRowRequest request); /** - * Commits changes in the currently active edit to the data source. Called - * by the editor row when changes are saved. + * Saves changes in the currently active edit to the data source. Called by + * the editor row when changes are saved. * * @param request - * the commit request + * the save request */ - public void commit(EditorRowRequest request); - - /** - * Discards any unsaved changes and reloads editor content from the data - * source. - *

- * Implementation note: This method may simply call - * {@link #bind(EditorRowRequest) bind} if no other processing needs to be - * done. - * - * @param request - * the discard request - */ - public void discard(EditorRowRequest request); + public void save(EditorRowRequest request); /** * Returns a widget instance that is used to edit the values in the given diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java index e7f843b6ea..2ebe1b62a3 100644 --- a/client/src/com/vaadin/client/ui/grid/Grid.java +++ b/client/src/com/vaadin/client/ui/grid/Grid.java @@ -950,7 +950,7 @@ public class Grid extends ResizeComposite implements public static final int KEYCODE_HIDE = KeyCodes.KEY_ESCAPE; protected enum State { - INACTIVE, ACTIVATING, ACTIVE, COMMITTING + INACTIVE, ACTIVATING, ACTIVE, SAVING } private Grid grid; @@ -1005,7 +1005,7 @@ public class Grid extends ResizeComposite implements /** * Cancels the currently active edit and hides the editor. Any changes - * that are not {@link #commit() committed} are lost. + * that are not {@link #save() saved} are lost. * * @throws IllegalStateException * if this editor row is not enabled @@ -1028,57 +1028,36 @@ public class Grid extends ResizeComposite implements } /** - * Commits any unsaved changes to the data source. + * Saves any unsaved changes to the data source. * * @throws IllegalStateException * if this editor row is not enabled * @throws IllegalStateException * if this editor row is not in edit mode */ - public void commit() { + public void save() { if (!enabled) { throw new IllegalStateException( - "Cannot commit: EditorRow is not enabled"); + "Cannot save: EditorRow is not enabled"); } if (state != State.ACTIVE) { throw new IllegalStateException( - "Cannot commit: EditorRow is not in edit mode"); + "Cannot save: EditorRow is not in edit mode"); } - state = State.COMMITTING; + state = State.SAVING; - handler.commit(new EditorRowRequest(grid, rowIndex, + handler.save(new EditorRowRequest(grid, rowIndex, new RequestCallback() { @Override public void onResponse(EditorRowRequest request) { - if (state == State.COMMITTING) { + if (state == State.SAVING) { state = State.ACTIVE; } } })); } - /** - * Reloads row values from the data source, discarding any unsaved - * changes. - * - * @throws IllegalStateException - * if this editor row is not enabled - * @throws IllegalStateException - * if this editor row is not in edit mode - */ - public void discard() { - if (!enabled) { - throw new IllegalStateException( - "Cannot discard: EditorRow is not enabled"); - } - if (state != State.ACTIVE) { - throw new IllegalStateException( - "Cannot discard: EditorRow is not in edit mode"); - } - handler.discard(new EditorRowRequest(grid, rowIndex, null)); - } - /** * Returns the handler responsible for binding data and editor widgets * to this editor row. @@ -1244,8 +1223,8 @@ public class Grid extends ResizeComposite implements save.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { - // TODO should have a mechanism for handling failed commits - commit(); + // TODO should have a mechanism for handling failed save + save(); cancel(); } }); @@ -5013,33 +4992,20 @@ public class Grid extends ResizeComposite implements } /** - * Commits any unsaved changes to the data source. - * - * @throws IllegalStateException - * if the editor row is not enabled - * @throws IllegalStateException - * if the editor row is not in edit mode - */ - public void commitEditorRow() { - editorRow.commit(); - } - - /** - * Reloads values from the data source for the row being edited, discarding - * any unsaved changes. + * Saves any unsaved changes to the data source. * * @throws IllegalStateException * if the editor row is not enabled * @throws IllegalStateException * if the editor row is not in edit mode */ - public void discardEditorRow() { - editorRow.discard(); + public void saveEditorRow() { + editorRow.save(); } /** * Cancels the currently active edit and hides the editor. Any changes that - * are not {@link #commit() committed} are lost. + * are not {@link #saveEditorRow() saved} are lost. * * @throws IllegalStateException * if the editor row is not enabled -- cgit v1.2.3