summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2014-12-11 17:07:15 +0200
committerJohannes Dahlström <johannesd@vaadin.com>2014-12-11 17:35:40 +0200
commit4f41def1e6cae667d4c39bbff8664895e46d7a76 (patch)
tree80525f18ce0520074c0e2948b9e56403e8536343 /client/src
parentb8a38c38caea01eb21ab0e02b77f87bc6bf31214 (diff)
downloadvaadin-framework-4f41def1e6cae667d4c39bbff8664895e46d7a76.tar.gz
vaadin-framework-4f41def1e6cae667d4c39bbff8664895e46d7a76.zip
Remove editor row discard methods; rename "commit" to "save" (#13334)
Change-Id: Ic7cec3c3750db8a2e0b23a4d38f63e9642999e3e
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/connectors/GridConnector.java20
-rw-r--r--client/src/com/vaadin/client/ui/grid/EditorRowHandler.java22
-rw-r--r--client/src/com/vaadin/client/ui/grid/Grid.java64
3 files changed, 23 insertions, 83 deletions
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
@@ -196,12 +196,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements
}
@Override
- public void discard(int rowIndex) {
- serverInitiated = true;
- GridConnector.this.getWidget().discardEditorRow();
- }
-
- @Override
public void cancel(int rowIndex) {
serverInitiated = true;
GridConnector.this.getWidget().cancelEditorRow();
@@ -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<JSONObject> request) {
- if (!handleServerInitiated(request)) {
- startRequest(request);
- rpc.commit(request.getRowIndex());
- }
- }
-
- @Override
- public void discard(EditorRowRequest<JSONObject> request) {
+ public void save(EditorRowRequest<JSONObject> 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<T> {
public void cancel(EditorRowRequest<T> 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<T> request);
-
- /**
- * Discards any unsaved changes and reloads editor content from the data
- * source.
- * <p>
- * 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<T> request);
+ public void save(EditorRowRequest<T> 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<T> 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<T> grid;
@@ -1005,7 +1005,7 @@ public class Grid<T> 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,30 +1028,30 @@ public class Grid<T> 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<T>(grid, rowIndex,
+ handler.save(new EditorRowRequest<T>(grid, rowIndex,
new RequestCallback<T>() {
@Override
public void onResponse(EditorRowRequest<T> request) {
- if (state == State.COMMITTING) {
+ if (state == State.SAVING) {
state = State.ACTIVE;
}
}
@@ -1059,27 +1059,6 @@ public class Grid<T> extends ResizeComposite implements
}
/**
- * 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<T>(grid, rowIndex, null));
- }
-
- /**
* Returns the handler responsible for binding data and editor widgets
* to this editor row.
*
@@ -1244,8 +1223,8 @@ public class Grid<T> 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<T> 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