diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2014-12-15 16:31:26 +0200 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2014-12-17 14:28:55 +0200 |
commit | 6ed909f2c61f7d434d1c91549dcda27cfa3698a8 (patch) | |
tree | ca0f593f146bf7d24e3747fe7cf764b82a4062ea | |
parent | 4a3a97c0d07861568d336ac7f3e0ed496dc8fcbb (diff) | |
download | vaadin-framework-6ed909f2c61f7d434d1c91549dcda27cfa3698a8.tar.gz vaadin-framework-6ed909f2c61f7d434d1c91549dcda27cfa3698a8.zip |
Change "editor row" to just "editor" in method names and javadoc (#13334)
Change-Id: Idafdbe3d71a38a979e1eeb07c527f66ce61ccfa9
17 files changed, 382 insertions, 376 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 061a6ac61e..ec25b57c45 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -44,7 +44,7 @@ import com.vaadin.client.ui.AbstractHasComponentsConnector; import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.widget.grid.CellReference; import com.vaadin.client.widget.grid.CellStyleGenerator; -import com.vaadin.client.widget.grid.EditorRowHandler; +import com.vaadin.client.widget.grid.EditorHandler; import com.vaadin.client.widget.grid.RowReference; import com.vaadin.client.widget.grid.RowStyleGenerator; import com.vaadin.client.widget.grid.events.SelectAllEvent; @@ -65,10 +65,10 @@ import com.vaadin.client.widgets.Grid.HeaderCell; import com.vaadin.client.widgets.Grid.HeaderRow; import com.vaadin.shared.data.sort.SortDirection; import com.vaadin.shared.ui.Connect; -import com.vaadin.shared.ui.grid.EditorRowClientRpc; -import com.vaadin.shared.ui.grid.EditorRowServerRpc; import com.vaadin.shared.ui.grid.GridClientRpc; import com.vaadin.shared.ui.grid.GridColumnState; +import com.vaadin.shared.ui.grid.EditorClientRpc; +import com.vaadin.shared.ui.grid.EditorServerRpc; import com.vaadin.shared.ui.grid.GridServerRpc; import com.vaadin.shared.ui.grid.GridState; import com.vaadin.shared.ui.grid.GridState.SharedSelectionMode; @@ -189,18 +189,17 @@ public class GridConnector extends AbstractHasComponentsConnector implements } /* - * An editor row handler using Vaadin RPC to manage the editor row state. + * An editor handler using Vaadin RPC to manage the editor state. */ - private class CustomEditorRowHandler implements - EditorRowHandler<JSONObject> { + private class CustomEditorHandler implements EditorHandler<JSONObject> { - private EditorRowServerRpc rpc = getRpcProxy(EditorRowServerRpc.class); + private EditorServerRpc rpc = getRpcProxy(EditorServerRpc.class); - private EditorRowRequest<?> currentRequest = null; + private EditorRequest<?> currentRequest = null; private boolean serverInitiated = false; - public CustomEditorRowHandler() { - registerRpc(EditorRowClientRpc.class, new EditorRowClientRpc() { + public CustomEditorHandler() { + registerRpc(EditorClientRpc.class, new EditorClientRpc() { @Override public void bind(final int rowIndex) { @@ -222,7 +221,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements @Override public void cancel(int rowIndex) { serverInitiated = true; - GridConnector.this.getWidget().cancelEditorRow(); + GridConnector.this.getWidget().cancelEditor(); } @Override @@ -246,7 +245,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements } @Override - public void bind(EditorRowRequest<JSONObject> request) { + public void bind(EditorRequest<JSONObject> request) { if (!handleServerInitiated(request)) { startRequest(request); rpc.bind(request.getRowIndex()); @@ -254,7 +253,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements } @Override - public void save(EditorRowRequest<JSONObject> request) { + public void save(EditorRequest<JSONObject> request) { if (!handleServerInitiated(request)) { startRequest(request); rpc.save(request.getRowIndex()); @@ -262,7 +261,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements } @Override - public void cancel(EditorRowRequest<JSONObject> request) { + public void cancel(EditorRequest<JSONObject> request) { if (!handleServerInitiated(request)) { // No startRequest as we don't get (or need) // a confirmation from the server @@ -285,7 +284,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements } /** - * Used to handle the case where EditorRow calls us because it was + * Used to handle the case where the editor calls us because it was * invoked by the server via RPC and not by the client. In that case, we * simply synchronously complete the request. * @@ -294,7 +293,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements * @return true if the request was originally triggered by the server, * false otherwise */ - private boolean handleServerInitiated(EditorRowRequest<?> request) { + private boolean handleServerInitiated(EditorRequest<?> request) { assert request != null; assert currentRequest == null; @@ -307,7 +306,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements } } - private void startRequest(EditorRowRequest<?> request) { + private void startRequest(EditorRequest<?> request) { currentRequest = request; } @@ -430,7 +429,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements }); - getWidget().setEditorRowHandler(new CustomEditorRowHandler()); + getWidget().setEditorHandler(new CustomEditorHandler()); getLayoutManager().registerDependency(this, getWidget().getElement()); layout(); } @@ -483,9 +482,8 @@ public class GridConnector extends AbstractHasComponentsConnector implements updateFooterFromState(getState().footer); } - if (stateChangeEvent.hasPropertyChanged("editorRowEnabled")) { - getWidget() - .setEditorRowEnabled(getState().editorRowEnabled); + if (stateChangeEvent.hasPropertyChanged("editorEnabled")) { + getWidget().setEditorEnabled(getState().editorEnabled); } if (stateChangeEvent.hasPropertyChanged("frozenColumnCount")) { diff --git a/client/src/com/vaadin/client/widget/grid/EditorRowHandler.java b/client/src/com/vaadin/client/widget/grid/EditorHandler.java index 14b494a3ae..2b609f5de3 100644 --- a/client/src/com/vaadin/client/widget/grid/EditorRowHandler.java +++ b/client/src/com/vaadin/client/widget/grid/EditorHandler.java @@ -19,9 +19,9 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.widgets.Grid; /** - * An interface for binding widgets and data to the editor row. Used by the - * editor row to support different row types, data sources and custom data - * binding mechanisms. + * An interface for binding widgets and data to the grid row editor. Used by the + * editor to support different row types, data sources and custom data binding + * mechanisms. * * @param <T> * the row data type @@ -29,7 +29,7 @@ import com.vaadin.client.widgets.Grid; * @since * @author Vaadin Ltd */ -public interface EditorRowHandler<T> { +public interface EditorHandler<T> { /** * A request class for handling asynchronous data binding. The request is @@ -38,14 +38,14 @@ public interface EditorRowHandler<T> { * <p> * TODO Should have a mechanism for signaling a failed request to the caller */ - public static class EditorRowRequest<T> { + public static class EditorRequest<T> { /** * A callback interface used to notify the caller about completed * requests. */ public interface RequestCallback<T> { - public void onResponse(EditorRowRequest<T> request); + public void onResponse(EditorRequest<T> request); } private Grid<T> grid; @@ -53,7 +53,7 @@ public interface EditorRowHandler<T> { private RequestCallback<T> callback; /** - * Creates a new editor row request. + * Creates a new editor request. * * @param rowIndex * the index of the edited row @@ -61,7 +61,7 @@ public interface EditorRowHandler<T> { * the callback invoked when the request is ready, or null if * no need to call back */ - public EditorRowRequest(Grid<T> grid, int rowIndex, + public EditorRequest(Grid<T> grid, int rowIndex, RequestCallback<T> callback) { this.grid = grid; this.rowIndex = rowIndex; @@ -87,7 +87,7 @@ public interface EditorRowHandler<T> { } /** - * Returns the grid instance related to this editor row request. + * Returns the grid instance related to this editor request. * * @return the grid instance */ @@ -96,7 +96,7 @@ public interface EditorRowHandler<T> { } /** - * Returns the editor row widget used to edit the values of the given + * Returns the editor widget used to edit the values of the given * column. * * @param column @@ -104,7 +104,7 @@ public interface EditorRowHandler<T> { * @return the widget related to the column */ public Widget getWidget(Grid.Column<?, T> column) { - Widget w = grid.getEditorRowWidget(column); + Widget w = grid.getEditorWidget(column); assert w != null; return w; } @@ -120,10 +120,10 @@ public interface EditorRowHandler<T> { } /** - * Binds row data to the editor row widgets. Called by the editor row when - * it is opened for editing. + * Binds row data to the editor widgets. Called by the editor when it is + * opened for editing. * <p> - * An implementation must call {@link EditorRowRequest#invokeCallback() + * An implementation must call {@link EditorRequest#invokeCallback() * request.invokeCallback()} when the binding is complete (possibly * asynchronously). * @@ -132,31 +132,31 @@ public interface EditorRowHandler<T> { * * @see Grid#editRow(int) */ - public void bind(EditorRowRequest<T> request); + public void bind(EditorRequest<T> request); /** - * Cancels a currently active edit if any. Called by the editor row when + * Cancels a currently active edit if any. Called by the grid editor when * editing is cancelled. * <p> - * An implementation must call {@link EditorRowRequest#invokeCallback() + * An implementation must call {@link EditorRequest#invokeCallback() * request.invokeCallback()} when the cancel is done (possibly * asynchronously). * * @param request * the cancel request * - * @see Grid#cancelEditorRow() + * @see Grid#cancelEditor() */ - public void cancel(EditorRowRequest<T> request); + public void cancel(EditorRequest<T> request); /** * Saves changes in the currently active edit to the data source. Called by - * the editor row when changes are saved. + * the grid editor when changes are saved. * * @param request * the save request */ - public void save(EditorRowRequest<T> request); + public void save(EditorRequest<T> request); /** * Returns a widget instance that is used to edit the values in the given diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 42da0ca90d..1708beba30 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -78,9 +78,9 @@ import com.vaadin.client.widget.grid.CellReference; import com.vaadin.client.widget.grid.CellStyleGenerator; import com.vaadin.client.widget.grid.DataAvailableEvent; import com.vaadin.client.widget.grid.DataAvailableHandler; -import com.vaadin.client.widget.grid.EditorRowHandler; -import com.vaadin.client.widget.grid.EditorRowHandler.EditorRowRequest; -import com.vaadin.client.widget.grid.EditorRowHandler.EditorRowRequest.RequestCallback; +import com.vaadin.client.widget.grid.EditorHandler; +import com.vaadin.client.widget.grid.EditorHandler.EditorRequest; +import com.vaadin.client.widget.grid.EditorHandler.EditorRequest.RequestCallback; import com.vaadin.client.widget.grid.GridUtil; import com.vaadin.client.widget.grid.RowReference; import com.vaadin.client.widget.grid.RowStyleGenerator; @@ -931,7 +931,7 @@ public class Grid<T> extends ResizeComposite implements * An editor UI for Grid rows. A single Grid row at a time can be opened for * editing. */ - protected static class EditorRow<T> { + protected static class Editor<T> { public static final int KEYCODE_SHOW = KeyCodes.KEY_ENTER; public static final int KEYCODE_HIDE = KeyCodes.KEY_ESCAPE; @@ -941,7 +941,7 @@ public class Grid<T> extends ResizeComposite implements } private Grid<T> grid; - private EditorRowHandler<T> handler; + private EditorHandler<T> handler; private DivElement editorOverlay = DivElement.as(DOM.createDiv()); @@ -965,18 +965,18 @@ public class Grid<T> extends ResizeComposite implements * the index of the row to be edited * * @throws IllegalStateException - * if this editor row is not enabled + * if this editor is not enabled * @throws IllegalStateException - * if this editor row is already in edit mode + * if this editor is already in edit mode */ public void editRow(int rowIndex) { if (!enabled) { throw new IllegalStateException( - "Cannot edit row: EditorRow is not enabled"); + "Cannot edit row: editor is not enabled"); } if (state != State.INACTIVE) { throw new IllegalStateException( - "Cannot edit row: EditorRow already in edit mode"); + "Cannot edit row: editor already in edit mode"); } this.rowIndex = rowIndex; @@ -995,22 +995,22 @@ public class Grid<T> extends ResizeComposite implements * that are not {@link #save() saved} are lost. * * @throws IllegalStateException - * if this editor row is not enabled + * if this editor is not enabled * @throws IllegalStateException - * if this editor row is not in edit mode + * if this editor is not in edit mode */ public void cancel() { if (!enabled) { throw new IllegalStateException( - "Cannot cancel edit: EditorRow is not enabled"); + "Cannot cancel edit: editor is not enabled"); } if (state == State.INACTIVE) { throw new IllegalStateException( - "Cannot cancel edit: EditorRow is not in edit mode"); + "Cannot cancel edit: editor is not in edit mode"); } hideOverlay(); grid.getEscalator().setScrollLocked(Direction.VERTICAL, false); - handler.cancel(new EditorRowRequest<T>(grid, rowIndex, null)); + handler.cancel(new EditorRequest<T>(grid, rowIndex, null)); state = State.INACTIVE; } @@ -1018,26 +1018,26 @@ public class Grid<T> extends ResizeComposite implements * Saves any unsaved changes to the data source. * * @throws IllegalStateException - * if this editor row is not enabled + * if this editor is not enabled * @throws IllegalStateException - * if this editor row is not in edit mode + * if this editor is not in edit mode */ public void save() { if (!enabled) { throw new IllegalStateException( - "Cannot save: EditorRow is not enabled"); + "Cannot save: editor is not enabled"); } if (state != State.ACTIVE) { throw new IllegalStateException( - "Cannot save: EditorRow is not in edit mode"); + "Cannot save: editor is not in edit mode"); } state = State.SAVING; - handler.save(new EditorRowRequest<T>(grid, rowIndex, + handler.save(new EditorRequest<T>(grid, rowIndex, new RequestCallback<T>() { @Override - public void onResponse(EditorRowRequest<T> request) { + public void onResponse(EditorRequest<T> request) { if (state == State.SAVING) { state = State.ACTIVE; } @@ -1047,28 +1047,28 @@ public class Grid<T> extends ResizeComposite implements /** * Returns the handler responsible for binding data and editor widgets - * to this editor row. + * to this editor. * - * @return the editor row handler or null if not set + * @return the editor handler or null if not set */ - public EditorRowHandler<T> getHandler() { + public EditorHandler<T> getHandler() { return handler; } /** * Sets the handler responsible for binding data and editor widgets to - * this editor row. + * this editor. * * @param rowHandler - * the new editor row handler + * the new editor handler * * @throws IllegalStateException - * if this editor row is currently in edit mode + * if this editor is currently in edit mode */ - public void setHandler(EditorRowHandler<T> rowHandler) { + public void setHandler(EditorHandler<T> rowHandler) { if (state != State.INACTIVE) { throw new IllegalStateException( - "Cannot set EditorRowHandler: EditorRow is currently in edit mode"); + "Cannot set EditorHandler: editor is currently in edit mode"); } handler = rowHandler; } @@ -1078,7 +1078,7 @@ public class Grid<T> extends ResizeComposite implements } /** - * Sets the enabled state of this editor row. + * Sets the enabled state of this editor. * * @param enabled * true if enabled, false otherwise @@ -1086,25 +1086,25 @@ public class Grid<T> extends ResizeComposite implements * @throws IllegalStateException * if in edit mode and trying to disable * @throws IllegalStateException - * if the editor row handler is not set + * if the editor handler is not set */ public void setEnabled(boolean enabled) { if (enabled == false && state != State.INACTIVE) { throw new IllegalStateException( - "Cannot disable: EditorRow is in edit mode"); + "Cannot disable: editor is in edit mode"); } else if (enabled == true && getHandler() == null) { throw new IllegalStateException( - "Cannot enable: EditorRowHandler not set"); + "Cannot enable: EditorHandler not set"); } this.enabled = enabled; } protected void show() { if (state == State.ACTIVATING) { - handler.bind(new EditorRowRequest<T>(grid, rowIndex, + handler.bind(new EditorRequest<T>(grid, rowIndex, new RequestCallback<T>() { @Override - public void onResponse(EditorRowRequest<T> request) { + public void onResponse(EditorRequest<T> request) { if (state == State.ACTIVATING) { state = State.ACTIVE; showOverlay(grid @@ -1121,7 +1121,7 @@ public class Grid<T> extends ResizeComposite implements protected void setGrid(final Grid<T> grid) { assert grid != null : "Grid cannot be null"; - assert this.grid == null : "Can only attach EditorRow to Grid once"; + assert this.grid == null : "Can only attach editor to Grid once"; this.grid = grid; @@ -1145,11 +1145,11 @@ public class Grid<T> extends ResizeComposite implements /** * Returns the editor widget associated with the given column. If the - * editor row is not active, returns null. + * editor is not active, returns null. * * @param column * the column - * @return the widget if the editor row is open, null otherwise + * @return the widget if the editor is open, null otherwise */ protected Widget getWidget(Column<?, T> column) { return columnToWidget.get(column); @@ -1252,13 +1252,13 @@ public class Grid<T> extends ResizeComposite implements } /** - * Creates an editor row cell corresponding to the given table cell. The + * Creates an editor cell corresponding to the given table cell. The * returned element is empty and has the same dimensions and position as * the table cell. * * @param td * the table cell used as a reference - * @return an editor row cell corresponding to the given cell + * @return an editor cell corresponding to the given cell */ protected Element createCell(TableCellElement td) { DivElement cell = DivElement.as(DOM.createDiv()); @@ -2402,7 +2402,7 @@ public class Grid<T> extends ResizeComposite implements private final UserSorter sorter = new UserSorter(); - private final EditorRow<T> editorRow = GWT.create(EditorRow.class); + private final Editor<T> editor = GWT.create(Editor.class); private boolean dataIsBeingFetched = false; @@ -3351,7 +3351,7 @@ public class Grid<T> extends ResizeComposite implements footer.setGrid(this); - editorRow.setGrid(this); + editor.setGrid(this); setSelectionMode(SelectionMode.MULTI); @@ -3415,7 +3415,7 @@ public class Grid<T> extends ResizeComposite implements public void setStylePrimaryName(String style) { super.setStylePrimaryName(style); escalator.setStylePrimaryName(style); - editorRow.setStylePrimaryName(style); + editor.setStylePrimaryName(style); String rowStyle = getStylePrimaryName() + "-row"; rowHasDataStyleName = rowStyle + "-has-data"; @@ -3987,8 +3987,8 @@ public class Grid<T> extends ResizeComposite implements return footer.isVisible(); } - protected EditorRow<T> getEditorRow() { - return editorRow; + protected Editor<T> getEditor() { + return editor; } protected Escalator getEscalator() { @@ -4421,8 +4421,8 @@ public class Grid<T> extends ResizeComposite implements assert cell != null : "received " + eventType + "-event with a null cell target"; - // Editor Row can steal focus from Grid and is still handled - if (handleEditorRowEvent(event, container, cell)) { + // Editor can steal focus from Grid and is still handled + if (handleEditorEvent(event, container, cell)) { return; } @@ -4470,26 +4470,26 @@ public class Grid<T> extends ResizeComposite implements return w != null; } - private boolean handleEditorRowEvent(Event event, RowContainer container, + private boolean handleEditorEvent(Event event, RowContainer container, Cell cell) { - if (editorRow.getState() != EditorRow.State.INACTIVE) { + if (editor.getState() != Editor.State.INACTIVE) { if (event.getTypeInt() == Event.ONKEYDOWN - && event.getKeyCode() == EditorRow.KEYCODE_HIDE) { - editorRow.cancel(); + && event.getKeyCode() == Editor.KEYCODE_HIDE) { + editor.cancel(); } return true; } - if (container == escalator.getBody() && editorRow.isEnabled()) { + if (container == escalator.getBody() && editor.isEnabled()) { if (event.getTypeInt() == Event.ONDBLCLICK) { if (cell != null) { - editorRow.editRow(cell.getRow()); + editor.editRow(cell.getRow()); return true; } } else if (event.getTypeInt() == Event.ONKEYDOWN - && event.getKeyCode() == EditorRow.KEYCODE_SHOW) { - editorRow.editRow(cellFocusHandler.rowWithFocus); + && event.getKeyCode() == Editor.KEYCODE_SHOW) { + editor.editRow(cellFocusHandler.rowWithFocus); return true; } } @@ -5434,74 +5434,74 @@ public class Grid<T> extends ResizeComposite implements * the index of the row to be edited * * @throws IllegalStateException - * if the editor row is not enabled + * if the editor is not enabled * @throws IllegalStateException - * if the editor row is already in edit mode + * if the editor is already in edit mode */ public void editRow(int rowIndex) { - editorRow.editRow(rowIndex); + editor.editRow(rowIndex); } /** - * Saves any unsaved changes to the data source. + * Saves any unsaved changes in the editor to the data source. * * @throws IllegalStateException - * if the editor row is not enabled + * if the editor is not enabled * @throws IllegalStateException - * if the editor row is not in edit mode + * if the editor is not in edit mode */ - public void saveEditorRow() { - editorRow.save(); + public void saveEditor() { + editor.save(); } /** * Cancels the currently active edit and hides the editor. Any changes that - * are not {@link #saveEditorRow() saved} are lost. + * are not {@link #saveEditor() saved} are lost. * * @throws IllegalStateException - * if the editor row is not enabled + * if the editor is not enabled * @throws IllegalStateException - * if the editor row is not in edit mode + * if the editor is not in edit mode */ - public void cancelEditorRow() { - editorRow.cancel(); + public void cancelEditor() { + editor.cancel(); } /** * Returns the handler responsible for binding data and editor widgets to - * the editor row. + * the editor. * - * @return the editor row handler or null if not set + * @return the editor handler or null if not set */ - public EditorRowHandler<T> getEditorRowHandler() { - return editorRow.getHandler(); + public EditorHandler<T> getEditorHandler() { + return editor.getHandler(); } /** * Sets the handler responsible for binding data and editor widgets to the - * editor row. + * editor. * * @param rowHandler - * the new editor row handler + * the new editor handler * * @throws IllegalStateException - * if the editor row is currently in edit mode + * if the editor is currently in edit mode */ - public void setEditorRowHandler(EditorRowHandler<T> handler) { - editorRow.setHandler(handler); + public void setEditorHandler(EditorHandler<T> handler) { + editor.setHandler(handler); } /** - * Returns the enabled state of the editor row. + * Returns the enabled state of the editor. * * @return true if editing is enabled, false otherwise */ - public boolean isEditorRowEnabled() { - return editorRow.isEnabled(); + public boolean isEditorEnabled() { + return editor.isEnabled(); } /** - * Sets the enabled state of the editor row. + * Sets the enabled state of the editor. * * @param enabled * true to enable editing, false to disable @@ -5509,22 +5509,22 @@ public class Grid<T> extends ResizeComposite implements * @throws IllegalStateException * if in edit mode and trying to disable * @throws IllegalStateException - * if the editor row handler is not set + * if the editor handler is not set */ - public void setEditorRowEnabled(boolean enabled) { - editorRow.setEnabled(enabled); + public void setEditorEnabled(boolean enabled) { + editor.setEnabled(enabled); } /** * Returns the editor widget associated with the given column. If the editor - * row is not active, returns null. + * is not active, returns null. * * @param column * the column - * @return the widget if the editor row is open, null otherwise + * @return the widget if the editor is open, null otherwise */ - public Widget getEditorRowWidget(Column<?, T> column) { - return editorRow.getWidget(column); + public Widget getEditorWidget(Column<?, T> column) { + return editor.getWidget(column); } @Override diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index 3daf63806d..a1403401c7 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -69,8 +69,8 @@ import com.vaadin.server.JsonCodec; import com.vaadin.server.KeyMapper; import com.vaadin.server.VaadinSession; import com.vaadin.shared.data.sort.SortDirection; -import com.vaadin.shared.ui.grid.EditorRowClientRpc; -import com.vaadin.shared.ui.grid.EditorRowServerRpc; +import com.vaadin.shared.ui.grid.EditorClientRpc; +import com.vaadin.shared.ui.grid.EditorServerRpc; import com.vaadin.shared.ui.grid.GridClientRpc; import com.vaadin.shared.ui.grid.GridColumnState; import com.vaadin.shared.ui.grid.GridServerRpc; @@ -2405,7 +2405,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, private final Footer footer = new Footer(this); private Object editedItemId = null; - private FieldGroup editorRowFieldGroup = new CustomFieldGroup(); + private FieldGroup editorFieldGroup = new CustomFieldGroup(); private CellStyleGenerator cellStyleGenerator; private RowStyleGenerator rowStyleGenerator; @@ -2596,14 +2596,14 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } }); - registerRpc(new EditorRowServerRpc() { + registerRpc(new EditorServerRpc() { @Override public void bind(int rowIndex) { try { Object id = getContainerDataSource().getIdByIndex(rowIndex); doEditItem(id); - getEditorRowRpc().confirmBind(); + getEditorRpc().confirmBind(); } catch (Exception e) { handleError(e); } @@ -2613,7 +2613,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, public void cancel(int rowIndex) { try { // For future proofing even though cannot currently fail - doCancelEditorRow(); + doCancelEditor(); } catch (Exception e) { handleError(e); } @@ -2622,8 +2622,8 @@ public class Grid extends AbstractComponent implements SelectionNotifier, @Override public void save(int rowIndex) { try { - saveEditorRow(); - getEditorRowRpc().confirmSave(); + saveEditor(); + getEditorRpc().confirmSave(); } catch (Exception e) { handleError(e); } @@ -2696,7 +2696,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, columnKeys.removeAll(); datasource = container; - resetEditorRow(); + resetEditor(); // // Adjust sort order @@ -2978,7 +2978,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * The property id of column to be removed */ public void removeColumn(Object propertyId) { - setEditorRowField(propertyId, null); + setEditorField(propertyId, null); header.removeColumn(propertyId); footer.removeColumn(propertyId); Column column = columns.remove(propertyId); @@ -3969,15 +3969,15 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } } - componentList.addAll(getEditorRowFields()); + componentList.addAll(getEditorFields()); return componentList.iterator(); } @Override public boolean isRendered(Component childComponent) { - if (getEditorRowFields().contains(childComponent)) { - // Only render editor row fields if the editor is open - return isEditorRowActive(); + if (getEditorFields().contains(childComponent)) { + // Only render editor fields if the editor is open + return isEditorActive(); } else { // TODO Header and footer components should also only be rendered if // the header/footer is visible @@ -3985,8 +3985,8 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } } - EditorRowClientRpc getEditorRowRpc() { - return getRpcProxy(EditorRowClientRpc.class); + EditorClientRpc getEditorRpc() { + return getRpcProxy(EditorClientRpc.class); } /** @@ -4113,36 +4113,41 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } /** - * Sets whether or not the editor row feature is enabled for this grid. + * Sets whether or not the item editor UI is enabled for this grid. When the + * editor is enabled, the user can open it by double-clicking a row or + * hitting enter when a row is focused. The editor can also be opened + * programmatically using the {@link #editItem(Object)} method. * * @param isEnabled * <code>true</code> to enable the feature, <code>false</code> * otherwise * @throws IllegalStateException * if an item is currently being edited + * * @see #getEditedItemId() */ - public void setEditorRowEnabled(boolean isEnabled) + public void setEditorEnabled(boolean isEnabled) throws IllegalStateException { - if (isEditorRowActive()) { + if (isEditorActive()) { throw new IllegalStateException( - "Cannot disable the editor row while an item (" - + getEditedItemId() + ") is being edited."); + "Cannot disable the editor while an item (" + + getEditedItemId() + ") is being edited"); } - if (isEditorRowEnabled() != isEnabled) { - getState().editorRowEnabled = isEnabled; + if (isEditorEnabled() != isEnabled) { + getState().editorEnabled = isEnabled; } } /** - * Checks whether the editor row feature is enabled for this grid. + * Checks whether the item editor UI is enabled for this grid. + * + * @return <code>true</code> iff the editor is enabled for this grid * - * @return <code>true</code> iff the editor row feature is enabled for this - * grid + * @see #setEditorEnabled(boolean) * @see #getEditedItemId() */ - public boolean isEditorRowEnabled() { - return getState(false).editorRowEnabled; + public boolean isEditorEnabled() { + return getState(false).editorEnabled; } /** @@ -4156,34 +4161,38 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } /** - * Gets the field group that is backing the editor row of this grid. + * Gets the field group that is backing the item editor of this grid. * * @return the backing field group */ - public FieldGroup getEditorRowFieldGroup() { - return editorRowFieldGroup; + public FieldGroup getEditorFieldGroup() { + return editorFieldGroup; } /** - * Sets the field group that is backing this editor row. + * Sets the field group that is backing the item editor of this grid. * * @param fieldGroup * the backing field group + * + * @throws IllegalStateException + * if the editor is currently active */ - public void setEditorRowFieldGroup(FieldGroup fieldGroup) { - editorRowFieldGroup = fieldGroup; - if (isEditorRowActive()) { - editorRowFieldGroup.setItemDataSource(getContainerDataSource() - .getItem(editedItemId)); + public void setEditorFieldGroup(FieldGroup fieldGroup) { + if (isEditorActive()) { + throw new IllegalStateException( + "Cannot change field group while an item (" + + getEditedItemId() + ") is being edited"); } + editorFieldGroup = fieldGroup; } /** - * Returns whether an item is currently being edited in the editor row. + * Returns whether an item is currently being edited in the editor. * - * @return true iff the editor row is editing an item + * @return true iff the editor is open */ - public boolean isEditorRowActive() { + public boolean isEditorActive() { return editedItemId != null; } @@ -4195,12 +4204,12 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } /** - * Gets the field component that represents a property in the editor row. + * Gets the field component that represents a property in the item editor. * <p> * When {@link #editItem(Object) editItem} is called, fields are * automatically created and bound for any unbound properties. * <p> - * Getting a field before the editor row has been opened depends on special + * Getting a field before the editor has been opened depends on special * support from the {@link FieldGroup} in use. Using this method with a * user-provided <code>FieldGroup</code> might cause {@link BindException} * to be thrown. @@ -4215,12 +4224,12 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * if no field has been configured and there is a problem * building or binding */ - public Field<?> getEditorRowField(Object propertyId) { + public Field<?> getEditorField(Object propertyId) { checkColumnExists(propertyId); - Field<?> editor = editorRowFieldGroup.getField(propertyId); + Field<?> editor = editorFieldGroup.getField(propertyId); if (editor == null) { - editor = editorRowFieldGroup.buildAndBind(propertyId); + editor = editorFieldGroup.buildAndBind(propertyId); } if (editor.getParent() != Grid.this) { @@ -4231,26 +4240,26 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } /** - * Opens the editor row for the provided item. + * Opens the editor interface for the provided item. * * @param itemId * the id of the item to edit * @throws IllegalStateException - * if the editor row is not enabled + * if the editor is not enabled * @throws IllegalArgumentException * if the {@code itemId} is not in the backing container - * @see #setEditorRowEnabled(boolean) + * @see #setEditorEnabled(boolean) */ public void editItem(Object itemId) throws IllegalStateException, IllegalArgumentException { doEditItem(itemId); - getEditorRowRpc().bind(getContainerDataSource().indexOfId(itemId)); + getEditorRpc().bind(getContainerDataSource().indexOfId(itemId)); } protected void doEditItem(Object itemId) { - if (!isEditorRowEnabled()) { - throw new IllegalStateException("Editor row is not enabled"); + if (!isEditorEnabled()) { + throw new IllegalStateException("Item editor is not enabled"); } Item item = getContainerDataSource().getItem(itemId); @@ -4259,13 +4268,13 @@ public class Grid extends AbstractComponent implements SelectionNotifier, + " not found in current container"); } - editorRowFieldGroup.setItemDataSource(item); + editorFieldGroup.setItemDataSource(item); editedItemId = itemId; for (Column column : getColumns()) { Object propertyId = column.getColumnProperty(); - Field<?> editor = getEditorRowField(propertyId); + Field<?> editor = getEditorField(propertyId); getColumn(propertyId).getState().editorConnector = editor; } @@ -4277,25 +4286,26 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * {@link #editItem(Object)}. * <p> * Setting the field to <code>null</code> clears any previously set field, - * causing a new field to be created the next time the editor row is opened. + * causing a new field to be created the next time the item editor is + * opened. * * @param field * The field to bind * @param propertyId * The propertyId to bind the field to */ - public void setEditorRowField(Object propertyId, Field<?> field) { + public void setEditorField(Object propertyId, Field<?> field) { checkColumnExists(propertyId); - Field<?> oldField = editorRowFieldGroup.getField(propertyId); + Field<?> oldField = editorFieldGroup.getField(propertyId); if (oldField != null) { - editorRowFieldGroup.unbind(oldField); + editorFieldGroup.unbind(oldField); oldField.setParent(null); } if (field != null) { field.setParent(this); - editorRowFieldGroup.bind(field, propertyId); + editorFieldGroup.bind(field, propertyId); } } @@ -4309,51 +4319,51 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * * @see FieldGroup#commit() */ - public void saveEditorRow() throws CommitException { - editorRowFieldGroup.commit(); + public void saveEditor() throws CommitException { + editorFieldGroup.commit(); } /** * Cancels the currently active edit if any. */ - public void cancelEditorRow() { - if (isEditorRowActive()) { - getEditorRowRpc().cancel( + public void cancelEditor() { + if (isEditorActive()) { + getEditorRpc().cancel( getContainerDataSource().indexOfId(editedItemId)); - doCancelEditorRow(); + doCancelEditor(); } } - protected void doCancelEditorRow() { + protected void doCancelEditor() { editedItemId = null; } - void resetEditorRow() { - if (isEditorRowActive()) { + void resetEditor() { + if (isEditorActive()) { /* * Simply force cancel the editing; throwing here would just make * Grid.setContainerDataSource semantics more complicated. */ - cancelEditorRow(); + cancelEditor(); } - for (Field<?> editor : getEditorRowFields()) { + for (Field<?> editor : getEditorFields()) { editor.setParent(null); } editedItemId = null; - editorRowFieldGroup = new CustomFieldGroup(); + editorFieldGroup = new CustomFieldGroup(); } /** - * Gets a collection of all fields bound to the editor row of this grid. + * Gets a collection of all fields bound to the item editor of this grid. * <p> * When {@link #editItem(Object) editItem} is called, fields are * automatically created and bound to any unbound properties. * - * @return a collection of all the fields bound to this editor row + * @return a collection of all the fields bound to the item editor */ - Collection<Field<?>> getEditorRowFields() { - Collection<Field<?>> fields = editorRowFieldGroup.getFields(); + Collection<Field<?>> getEditorFields() { + Collection<Field<?>> fields = editorFieldGroup.getFields(); assert allAttached(fields); return fields; } @@ -4376,7 +4386,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * @param fieldFactory * The field factory to use */ - public void setEditorRowFieldFactory(FieldGroupFieldFactory fieldFactory) { - editorRowFieldGroup.setFieldFactory(fieldFactory); + public void setEditorFieldFactory(FieldGroupFieldFactory fieldFactory) { + editorFieldGroup.setFieldFactory(fieldFactory); } } diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/EditorRowTests.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridEditorTest.java index 6252b6b568..c3817efc3f 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/EditorRowTests.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridEditorTest.java @@ -37,7 +37,7 @@ import com.vaadin.ui.Field; import com.vaadin.ui.Grid; import com.vaadin.ui.TextField; -public class EditorRowTests { +public class GridEditorTest { private static final Object PROPERTY_NAME = "name"; private static final Object PROPERTY_AGE = "age"; @@ -79,41 +79,41 @@ public class EditorRowTests { @Test public void initAssumptions() throws Exception { - assertFalse(grid.isEditorRowEnabled()); + assertFalse(grid.isEditorEnabled()); assertNull(grid.getEditedItemId()); - assertNotNull(grid.getEditorRowFieldGroup()); + assertNotNull(grid.getEditorFieldGroup()); } @Test public void setEnabled() throws Exception { - assertFalse(grid.isEditorRowEnabled()); - grid.setEditorRowEnabled(true); - assertTrue(grid.isEditorRowEnabled()); + assertFalse(grid.isEditorEnabled()); + grid.setEditorEnabled(true); + assertTrue(grid.isEditorEnabled()); } @Test public void setDisabled() throws Exception { - assertFalse(grid.isEditorRowEnabled()); - grid.setEditorRowEnabled(true); - grid.setEditorRowEnabled(false); - assertFalse(grid.isEditorRowEnabled()); + assertFalse(grid.isEditorEnabled()); + grid.setEditorEnabled(true); + grid.setEditorEnabled(false); + assertFalse(grid.isEditorEnabled()); } @Test public void setReEnabled() throws Exception { - assertFalse(grid.isEditorRowEnabled()); - grid.setEditorRowEnabled(true); - grid.setEditorRowEnabled(false); - grid.setEditorRowEnabled(true); - assertTrue(grid.isEditorRowEnabled()); + assertFalse(grid.isEditorEnabled()); + grid.setEditorEnabled(true); + grid.setEditorEnabled(false); + grid.setEditorEnabled(true); + assertTrue(grid.isEditorEnabled()); } @Test public void detached() throws Exception { - FieldGroup oldFieldGroup = grid.getEditorRowFieldGroup(); + FieldGroup oldFieldGroup = grid.getEditorFieldGroup(); grid.removeAllColumns(); grid.setContainerDataSource(new IndexedContainer()); - assertFalse(oldFieldGroup == grid.getEditorRowFieldGroup()); + assertFalse(oldFieldGroup == grid.getEditorFieldGroup()); } @Test(expected = IllegalStateException.class) @@ -129,7 +129,7 @@ public class EditorRowTests { @Test(expected = IllegalArgumentException.class) public void nonexistentEditItem() throws Exception { - grid.setEditorRowEnabled(true); + grid.setEditorEnabled(true); grid.editItem(new Object()); } @@ -137,36 +137,36 @@ public class EditorRowTests { public void getField() throws Exception { startEdit(); - assertNotNull(grid.getEditorRowField(PROPERTY_NAME)); + assertNotNull(grid.getEditorField(PROPERTY_NAME)); } @Test public void getFieldWithoutItem() throws Exception { - grid.setEditorRowEnabled(true); - assertNotNull(grid.getEditorRowField(PROPERTY_NAME)); + grid.setEditorEnabled(true); + assertNotNull(grid.getEditorField(PROPERTY_NAME)); } @Test public void customBinding() { TextField textField = new TextField(); - grid.setEditorRowField(PROPERTY_NAME, textField); + grid.setEditorField(PROPERTY_NAME, textField); startEdit(); - assertSame(textField, grid.getEditorRowField(PROPERTY_NAME)); + assertSame(textField, grid.getEditorField(PROPERTY_NAME)); } @Test(expected = IllegalStateException.class) public void disableWhileEditing() { startEdit(); - grid.setEditorRowEnabled(false); + grid.setEditorEnabled(false); } @Test public void fieldIsNotReadonly() { startEdit(); - Field<?> field = grid.getEditorRowField(PROPERTY_NAME); + Field<?> field = grid.getEditorField(PROPERTY_NAME); assertFalse(field.isReadOnly()); } @@ -174,14 +174,14 @@ public class EditorRowTests { public void fieldIsReadonlyWhenFieldGroupIsReadonly() { startEdit(); - grid.getEditorRowFieldGroup().setReadOnly(true); - Field<?> field = grid.getEditorRowField(PROPERTY_NAME); + grid.getEditorFieldGroup().setReadOnly(true); + Field<?> field = grid.getEditorField(PROPERTY_NAME); assertTrue(field.isReadOnly()); } @Test public void columnRemoved() { - Field<?> field = grid.getEditorRowField(PROPERTY_NAME); + Field<?> field = grid.getEditorField(PROPERTY_NAME); assertSame("field should be attached to grid.", grid, field.getParent()); @@ -193,17 +193,17 @@ public class EditorRowTests { @Test public void setFieldAgain() { TextField field = new TextField(); - grid.setEditorRowField(PROPERTY_NAME, field); + grid.setEditorField(PROPERTY_NAME, field); field = new TextField(); - grid.setEditorRowField(PROPERTY_NAME, field); + grid.setEditorField(PROPERTY_NAME, field); assertSame("new field should be used.", field, - grid.getEditorRowField(PROPERTY_NAME)); + grid.getEditorField(PROPERTY_NAME)); } private void startEdit() { - grid.setEditorRowEnabled(true); + grid.setEditorEnabled(true); grid.editItem(ITEM_ID); } } diff --git a/shared/src/com/vaadin/shared/ui/grid/EditorRowClientRpc.java b/shared/src/com/vaadin/shared/ui/grid/EditorClientRpc.java index c72f767f3c..c083252754 100644 --- a/shared/src/com/vaadin/shared/ui/grid/EditorRowClientRpc.java +++ b/shared/src/com/vaadin/shared/ui/grid/EditorClientRpc.java @@ -18,15 +18,15 @@ package com.vaadin.shared.ui.grid; import com.vaadin.shared.communication.ClientRpc; /** - * An RPC interface for the grid editor row server-to-client communications. + * An RPC interface for the grid editor server-to-client communications. * * @since * @author Vaadin Ltd */ -public interface EditorRowClientRpc extends ClientRpc { +public interface EditorClientRpc extends ClientRpc { /** - * Tells the client to open the editor row and bind data to it. + * Tells the client to open the editor and bind data to it. * * @param rowIndex * the index of the edited row @@ -34,7 +34,7 @@ public interface EditorRowClientRpc extends ClientRpc { void bind(int rowIndex); /** - * Tells the client to cancel editing and hide the editor row. + * Tells the client to cancel editing and hide the editor. * * @param rowIndex * the index of the edited row @@ -42,14 +42,14 @@ public interface EditorRowClientRpc extends ClientRpc { void cancel(int rowIndex); /** - * Confirms a pending {@link EditorRowServerRpc#bind(int) bind request} sent - * by the client. + * Confirms a pending {@link EditorServerRpc#bind(int) bind request} + * sent by the client. */ void confirmBind(); /** - * Confirms a pending {@link EditorRowServerRpc#save(int) save request} sent - * by the client. + * Confirms a pending {@link EditorServerRpc#save(int) save request} + * sent by the client. */ void confirmSave(); } diff --git a/shared/src/com/vaadin/shared/ui/grid/EditorRowServerRpc.java b/shared/src/com/vaadin/shared/ui/grid/EditorServerRpc.java index 8215e8963c..57df691547 100644 --- a/shared/src/com/vaadin/shared/ui/grid/EditorRowServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/grid/EditorServerRpc.java @@ -18,17 +18,17 @@ package com.vaadin.shared.ui.grid; import com.vaadin.shared.communication.ServerRpc; /** - * An RPC interface for the grid editor row client-to-server communications. + * An RPC interface for the grid editor client-to-server communications. * * @since * @author Vaadin Ltd */ -public interface EditorRowServerRpc extends ServerRpc { +public interface EditorServerRpc extends ServerRpc { /** - * Asks the server to open the editor row and bind data to it. When a bind + * Asks the server to open the editor and bind data to it. When a bind * request is sent, it must be acknowledged with a - * {@link EditorRowClientRpc#confirmBind() confirm call} before the client + * {@link EditorClientRpc#confirmBind() confirm call} before the client * can open the editor. * * @param rowIndex @@ -37,9 +37,9 @@ public interface EditorRowServerRpc extends ServerRpc { void bind(int rowIndex); /** - * Asks the server to save unsaved changes in the editor row to the data - * source. When a save request is sent, it must be acknowledged with a - * {@link EditorRowClientRpc#confirmSave() confirm call}. + * Asks the server to save unsaved changes in the editor to the data source. + * When a save request is sent, it must be acknowledged with a + * {@link EditorClientRpc#confirmSave() confirm call}. * * @param rowIndex * the index of the edited row @@ -49,7 +49,7 @@ public interface EditorRowServerRpc extends ServerRpc { /** * Tells the server to cancel editing. When sending a cancel request, the * client does not need to wait for confirmation by the server before hiding - * the editor row. + * the editor. * * @param rowIndex * the index of the edited row diff --git a/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java b/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java index 34e6fb4cfd..11cb133fa5 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java @@ -53,7 +53,7 @@ public class GridColumnState implements Serializable { /** * The connector for the field used to edit cells in this column when the - * editor row is active. + * editor interface is active. */ public Connector editorConnector; diff --git a/shared/src/com/vaadin/shared/ui/grid/GridState.java b/shared/src/com/vaadin/shared/ui/grid/GridState.java index 4cf834c4f0..1f98431caf 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridState.java @@ -138,8 +138,8 @@ public class GridState extends AbstractComponentState { /** Directions for each sorted column */ public SortDirection[] sortDirs = new SortDirection[0]; - /** The enabled state of the editor row */ - public boolean editorRowEnabled = false; + /** The enabled state of the editor interface */ + public boolean editorEnabled = false; /** Whether row data might contain generated row styles */ public boolean hasRowStyleGenerator; diff --git a/uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java b/uitest/src/com/vaadin/tests/components/grid/GridEditorUI.java index 3891583098..fe4b4342a2 100644 --- a/uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridEditorUI.java @@ -22,7 +22,7 @@ import com.vaadin.ui.Grid; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; -public class EditorRowUI extends AbstractTestUI { +public class GridEditorUI extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { @@ -33,15 +33,15 @@ public class EditorRowUI extends AbstractTestUI { // Don't use address since there's no converter grid.removeColumn("address"); - grid.setEditorRowEnabled(true); + grid.setEditorEnabled(true); - grid.setEditorRowField("firstName", new PasswordField()); + grid.setEditorField("firstName", new PasswordField()); TextField lastNameField = (TextField) grid - .getEditorRowField("lastName"); + .getEditorField("lastName"); lastNameField.setMaxLength(50); - grid.getEditorRowField("phoneNumber").setReadOnly(true); + grid.getEditorField("phoneNumber").setReadOnly(true); addComponent(grid); } diff --git a/uitest/src/com/vaadin/tests/components/grid/EditorRowUITest.java b/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java index 269f997c95..6c386eec03 100644 --- a/uitest/src/com/vaadin/tests/components/grid/EditorRowUITest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java @@ -30,29 +30,29 @@ import com.vaadin.tests.annotations.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @TestCategory("grid") -public class EditorRowUITest extends MultiBrowserTest { +public class GridEditorUITest extends MultiBrowserTest { @Test - public void testEditorRow() { + public void testEditor() { setDebug(true); openTestURL(); assertFalse("Sanity check", isElementPresent(PasswordFieldElement.class)); - openEditorRow(5); + openEditor(5); new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); - openEditorRow(10); + openEditor(10); - assertTrue("Edtor row should be opened with a password field", + assertTrue("Edtor should be opened with a password field", isElementPresent(PasswordFieldElement.class)); assertFalse("Notification was present", isElementPresent(NotificationElement.class)); } - private void openEditorRow(int rowIndex) { + private void openEditor(int rowIndex) { GridElement grid = $(GridElement.class).first(); GridCellElement cell = grid.getCell(rowIndex, 1); 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 62f3488447..9aceef70bb 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -189,7 +189,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { grid.setSelectionMode(SelectionMode.NONE); - grid.getEditorRowField(getColumnProperty(3)).setReadOnly(true); + grid.getEditorField(getColumnProperty(3)).setReadOnly(true); createGridActions(); @@ -203,7 +203,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { createRowActions(); - createEditorRowActions(); + createEditorActions(); addHeightActions(); @@ -853,48 +853,46 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { }, null); } - protected void createEditorRowActions() { - createBooleanAction("Enabled", "Editor row", false, + protected void createEditorActions() { + createBooleanAction("Enabled", "Editor", false, new Command<Grid, Boolean>() { @Override public void execute(Grid c, Boolean value, Object data) { - c.setEditorRowEnabled(value); + c.setEditorEnabled(value); } }); - createClickAction("Edit item 5", "Editor row", - new Command<Grid, String>() { - @Override - public void execute(Grid c, String value, Object data) { - c.editItem(5); - } - }, null); + createClickAction("Edit item 5", "Editor", new Command<Grid, String>() { + @Override + public void execute(Grid c, String value, Object data) { + c.editItem(5); + } + }, null); - createClickAction("Edit item 100", "Editor row", + createClickAction("Edit item 100", "Editor", new Command<Grid, String>() { @Override public void execute(Grid c, String value, Object data) { c.editItem(100); } }, null); - createClickAction("Save", "Editor row", new Command<Grid, String>() { + createClickAction("Save", "Editor", new Command<Grid, String>() { @Override public void execute(Grid c, String value, Object data) { try { - c.saveEditorRow(); + c.saveEditor(); } catch (CommitException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, null); - createClickAction("Cancel edit", "Editor row", - new Command<Grid, String>() { - @Override - public void execute(Grid c, String value, Object data) { - c.cancelEditorRow(); - } - }, null); + createClickAction("Cancel edit", "Editor", new Command<Grid, String>() { + @Override + public void execute(Grid c, String value, Object data) { + c.cancelEditor(); + } + }, null); } @SuppressWarnings("boxing") diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java index 50e1034b50..279f75492e 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java @@ -90,11 +90,11 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest { return footerCells; } - protected WebElement getEditorRow() { + protected WebElement getEditor() { List<WebElement> elems = getGridElement().findElements( By.className("v-grid-editor-row")); - assertLessThanOrEqual("number of editor rows", elems.size(), 1); + assertLessThanOrEqual("number of editors", elems.size(), 1); return elems.isEmpty() ? null : elems.get(0); } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorRowTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorTest.java index 1fa8549b1c..29e6fed68c 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorRowTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorTest.java @@ -2,7 +2,7 @@ package com.vaadin.tests.components.grid.basicfeatures.client; import org.junit.Before; -public class GridClientCompositeEditorRowTest extends GridEditorRowClientTest { +public class GridClientCompositeEditorTest extends GridEditorClientTest { @Override @Before diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorRowClientTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java index f3c49db39e..5db7f3a0b9 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorRowClientTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java @@ -34,34 +34,34 @@ import org.openqa.selenium.interactions.Actions; import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; -public class GridEditorRowClientTest extends GridBasicClientFeaturesTest { +public class GridEditorClientTest extends GridBasicClientFeaturesTest { @Before public void setUp() { openTestURL(); - selectMenuPath("Component", "Editor row", "Enabled"); + selectMenuPath("Component", "Editor", "Enabled"); } @Test public void testProgrammaticOpeningClosing() { - selectMenuPath("Component", "Editor row", "Edit row 5"); - assertNotNull(getEditorRow()); + selectMenuPath("Component", "Editor", "Edit row 5"); + assertNotNull(getEditor()); - selectMenuPath("Component", "Editor row", "Cancel edit"); - assertNull(getEditorRow()); + selectMenuPath("Component", "Editor", "Cancel edit"); + assertNull(getEditor()); assertEquals("Row 5 edit cancelled", - findElement(By.className("editor-row-log")).getText()); + findElement(By.className("grid-editor-log")).getText()); } @Test public void testProgrammaticOpeningWithScroll() { - selectMenuPath("Component", "Editor row", "Edit row 100"); - assertNotNull(getEditorRow()); + selectMenuPath("Component", "Editor", "Edit row 100"); + assertNotNull(getEditor()); } @Test(expected = NoSuchElementException.class) public void testVerticalScrollLocking() { - selectMenuPath("Component", "Editor row", "Edit row 5"); + selectMenuPath("Component", "Editor", "Edit row 5"); getGridElement().getCell(200, 0); } @@ -72,27 +72,27 @@ public class GridEditorRowClientTest extends GridBasicClientFeaturesTest { new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); - assertNotNull(getEditorRow()); + assertNotNull(getEditor()); new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); - assertNull(getEditorRow()); + assertNull(getEditor()); assertEquals("Row 4 edit cancelled", - findElement(By.className("editor-row-log")).getText()); + findElement(By.className("grid-editor-log")).getText()); - // Disable editor row - selectMenuPath("Component", "Editor row", "Enabled"); + // Disable editor + selectMenuPath("Component", "Editor", "Enabled"); getGridElement().getCell(5, 0).click(); new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); - assertNull(getEditorRow()); + assertNull(getEditor()); } @Test public void testWidgetBinding() throws Exception { - selectMenuPath("Component", "Editor row", "Edit row 100"); - WebElement editorRow = getEditorRow(); + selectMenuPath("Component", "Editor", "Edit row 100"); + WebElement editor = getEditor(); - List<WebElement> widgets = editorRow.findElements(By + List<WebElement> widgets = editor.findElements(By .className("gwt-TextBox")); assertEquals(GridBasicFeatures.COLUMNS, widgets.size()); @@ -108,10 +108,10 @@ public class GridEditorRowClientTest extends GridBasicClientFeaturesTest { @Test public void testWithSelectionColumn() throws Exception { selectMenuPath("Component", "State", "Selection mode", "multi"); - selectMenuPath("Component", "State", "Editor row", "Edit row 5"); + selectMenuPath("Component", "State", "Editor", "Edit row 5"); - WebElement editorRow = getEditorRow(); - List<WebElement> selectorDivs = editorRow.findElements(By + WebElement editor = getEditor(); + List<WebElement> selectorDivs = editor.findElements(By .cssSelector("div")); assertTrue("selector column cell should've been empty", selectorDivs @@ -122,15 +122,15 @@ public class GridEditorRowClientTest extends GridBasicClientFeaturesTest { @Test public void testSave() { - selectMenuPath("Component", "Editor row", "Edit row 100"); + selectMenuPath("Component", "Editor", "Edit row 100"); - WebElement textField = getEditorRow().findElements( + WebElement textField = getEditor().findElements( By.className("gwt-TextBox")).get(0); textField.clear(); textField.sendKeys("Changed"); - WebElement saveButton = getEditorRow().findElement( + WebElement saveButton = getEditor().findElement( By.className("v-editor-row-save")); saveButton.click(); @@ -140,15 +140,15 @@ public class GridEditorRowClientTest extends GridBasicClientFeaturesTest { @Test public void testProgrammaticSave() { - selectMenuPath("Component", "Editor row", "Edit row 100"); + selectMenuPath("Component", "Editor", "Edit row 100"); - WebElement textField = getEditorRow().findElements( + WebElement textField = getEditor().findElements( By.className("gwt-TextBox")).get(0); textField.clear(); textField.sendKeys("Changed"); - selectMenuPath("Component", "Editor row", "Save"); + selectMenuPath("Component", "Editor", "Save"); assertEquals("Changed", getGridElement().getCell(100, 0).getText()); } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorRowTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java index f07d33080d..2afa9ec04e 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorRowTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java @@ -18,6 +18,7 @@ package com.vaadin.tests.components.grid.basicfeatures.server; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.util.List; @@ -32,53 +33,52 @@ import org.openqa.selenium.interactions.Actions; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; -public class GridEditorRowTest extends GridBasicFeaturesTest { +public class GridEditorTest extends GridBasicFeaturesTest { @Before public void setUp() { openTestURL(); - selectMenuPath("Component", "Editor row", "Enabled"); + selectMenuPath("Component", "Editor", "Enabled"); } @Test public void testProgrammaticOpeningClosing() { - selectMenuPath("Component", "Editor row", "Edit item 5"); - assertEditorRowOpen(); + selectMenuPath("Component", "Editor", "Edit item 5"); + assertEditorOpen(); - selectMenuPath("Component", "Editor row", "Cancel edit"); - assertEditorRowClosed(); + selectMenuPath("Component", "Editor", "Cancel edit"); + assertEditorClosed(); } @Test public void testProgrammaticOpeningWhenDisabled() { - selectMenuPath("Component", "Editor row", "Enabled"); - selectMenuPath("Component", "Editor row", "Edit item 5"); - assertEditorRowClosed(); - assertEquals( - "5. Exception occured, java.lang.IllegalStateExceptionEditor row is not enabled", - getLogRow(0)); + selectMenuPath("Component", "Editor", "Enabled"); + selectMenuPath("Component", "Editor", "Edit item 5"); + assertEditorClosed(); + boolean thrown = getLogRow(0).startsWith( + "5. Exception occured, java.lang.IllegalStateException"); + assertTrue("IllegalStateException thrown", thrown); } @Test public void testDisablingWhileOpen() { - selectMenuPath("Component", "Editor row", "Edit item 5"); - selectMenuPath("Component", "Editor row", "Enabled"); - assertEditorRowOpen(); - assertEquals( - "5. Exception occured, java.lang.IllegalStateExceptionCannot disable the editor row while an item (5) is being edited.", - getLogRow(0)); - + selectMenuPath("Component", "Editor", "Edit item 5"); + selectMenuPath("Component", "Editor", "Enabled"); + assertEditorOpen(); + boolean thrown = getLogRow(0).startsWith( + "5. Exception occured, java.lang.IllegalStateException"); + assertTrue("IllegalStateException thrown", thrown); } @Test public void testProgrammaticOpeningWithScroll() { - selectMenuPath("Component", "Editor row", "Edit item 100"); - assertEditorRowOpen(); + selectMenuPath("Component", "Editor", "Edit item 100"); + assertEditorOpen(); } @Test(expected = NoSuchElementException.class) public void testVerticalScrollLocking() { - selectMenuPath("Component", "Editor row", "Edit item 5"); + selectMenuPath("Component", "Editor", "Edit item 5"); getGridElement().getCell(200, 0); } @@ -86,24 +86,24 @@ public class GridEditorRowTest extends GridBasicFeaturesTest { public void testKeyboardOpeningClosing() { getGridElement().getCell(4, 0).click(); - assertEditorRowClosed(); + assertEditorClosed(); new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); - assertEditorRowOpen(); + assertEditorOpen(); new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); - assertEditorRowClosed(); + assertEditorClosed(); - // Disable editor row - selectMenuPath("Component", "Editor row", "Enabled"); + // Disable Editor + selectMenuPath("Component", "Editor", "Enabled"); getGridElement().getCell(5, 0).click(); new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); - assertEditorRowClosed(); + assertEditorClosed(); } @Test public void testComponentBinding() { - selectMenuPath("Component", "State", "Editor row", "Edit item 100"); + selectMenuPath("Component", "State", "Editor", "Edit item 100"); List<WebElement> widgets = getEditorWidgets(); assertEquals("Number of widgets", GridBasicFeatures.COLUMNS, @@ -117,7 +117,7 @@ public class GridEditorRowTest extends GridBasicFeaturesTest { @Test public void testSave() { - selectMenuPath("Component", "Editor row", "Edit item 100"); + selectMenuPath("Component", "Editor", "Edit item 100"); WebElement textField = getEditorWidgets().get(0); @@ -125,7 +125,7 @@ public class GridEditorRowTest extends GridBasicFeaturesTest { textField.sendKeys(" changed"); - WebElement saveButton = getEditorRow().findElement( + WebElement saveButton = getEditor().findElement( By.className("v-editor-row-save")); saveButton.click(); @@ -136,7 +136,7 @@ public class GridEditorRowTest extends GridBasicFeaturesTest { @Test public void testProgrammaticSave() { - selectMenuPath("Component", "Editor row", "Edit item 100"); + selectMenuPath("Component", "Editor", "Edit item 100"); WebElement textField = getEditorWidgets().get(0); @@ -144,25 +144,25 @@ public class GridEditorRowTest extends GridBasicFeaturesTest { textField.sendKeys(" changed"); - selectMenuPath("Component", "Editor row", "Save"); + selectMenuPath("Component", "Editor", "Save"); assertEquals("(100, 0) changed", getGridElement().getCell(100, 0) .getText()); } - private void assertEditorRowOpen() { - assertNotNull("Editor row open", getEditorRow()); + private void assertEditorOpen() { + assertNotNull("Editor open", getEditor()); assertEquals("Number of widgets", GridBasicFeatures.COLUMNS, getEditorWidgets().size()); } - private void assertEditorRowClosed() { - assertNull("Editor row closed", getEditorRow()); + private void assertEditorClosed() { + assertNull("Editor closed", getEditor()); } private List<WebElement> getEditorWidgets() { - assertNotNull(getEditorRow()); - return getEditorRow().findElements(By.className("v-textfield")); + assertNotNull(getEditor()); + return getEditor().findElements(By.className("v-textfield")); } } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java index 71fc47277f..f66347bd2d 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java @@ -46,7 +46,7 @@ import com.vaadin.client.widget.escalator.Cell; import com.vaadin.client.widget.escalator.FlyweightCell; import com.vaadin.client.widget.grid.CellReference; import com.vaadin.client.widget.grid.CellStyleGenerator; -import com.vaadin.client.widget.grid.EditorRowHandler; +import com.vaadin.client.widget.grid.EditorHandler; import com.vaadin.client.widget.grid.RowReference; import com.vaadin.client.widget.grid.RowStyleGenerator; import com.vaadin.client.widget.grid.datasources.ListDataSource; @@ -92,19 +92,19 @@ public class GridBasicClientFeaturesWidget extends TEXT_RENDERER, HTML_RENDERER, NUMBER_RENDERER, DATE_RENDERER; } - private class TestEditorRowHandler implements EditorRowHandler<List<Data>> { + private class TestEditorHandler implements EditorHandler<List<Data>> { private Map<Grid.Column<?, ?>, TextBox> widgets = new HashMap<Grid.Column<?, ?>, TextBox>(); private Label log = new Label(); { - log.addStyleName("editor-row-log"); + log.addStyleName("grid-editor-log"); addSouth(log, 20); } @Override - public void bind(EditorRowRequest<List<Data>> request) { + public void bind(EditorRequest<List<Data>> request) { List<Data> rowData = ds.getRow(request.getRowIndex()); boolean hasSelectionColumn = !(grid.getSelectionModel() instanceof None); @@ -117,13 +117,13 @@ public class GridBasicClientFeaturesWidget extends } @Override - public void cancel(EditorRowRequest<List<Data>> request) { + public void cancel(EditorRequest<List<Data>> request) { log.setText("Row " + request.getRowIndex() + " edit cancelled"); request.invokeCallback(); } @Override - public void save(EditorRowRequest<List<Data>> request) { + public void save(EditorRequest<List<Data>> request) { log.setText("Row " + request.getRowIndex() + " edit committed"); List<Data> rowData = ds.getRow(request.getRowIndex()); @@ -252,7 +252,7 @@ public class GridBasicClientFeaturesWidget extends grid.setDataSource(ds); grid.addSelectAllHandler(ds.getSelectAllHandler()); grid.setSelectionMode(SelectionMode.NONE); - grid.setEditorRowHandler(new TestEditorRowHandler()); + grid.setEditorHandler(new TestEditorHandler()); sorter = new ListSorter<List<Data>>(grid); @@ -377,7 +377,7 @@ public class GridBasicClientFeaturesWidget extends createColumnsMenu(); createHeaderMenu(); createFooterMenu(); - createEditorRowMenu(); + createEditorMenu(); createInternalsMenu(); createDataSourceMenu(); @@ -906,41 +906,41 @@ public class GridBasicClientFeaturesWidget extends }, menuPath); } - private void createEditorRowMenu() { + private void createEditorMenu() { addMenuCommand("Enabled", new ScheduledCommand() { @Override public void execute() { - grid.setEditorRowEnabled(!grid.isEditorRowEnabled()); + grid.setEditorEnabled(!grid.isEditorEnabled()); } - }, "Component", "Editor row"); + }, "Component", "Editor"); addMenuCommand("Edit row 5", new ScheduledCommand() { @Override public void execute() { grid.editRow(5); } - }, "Component", "Editor row"); + }, "Component", "Editor"); addMenuCommand("Edit row 100", new ScheduledCommand() { @Override public void execute() { grid.editRow(100); } - }, "Component", "Editor row"); + }, "Component", "Editor"); addMenuCommand("Save", new ScheduledCommand() { @Override public void execute() { - grid.saveEditorRow(); + grid.saveEditor(); } - }, "Component", "Editor row"); + }, "Component", "Editor"); addMenuCommand("Cancel edit", new ScheduledCommand() { @Override public void execute() { - grid.cancelEditorRow(); + grid.cancelEditor(); } - }, "Component", "Editor row"); + }, "Component", "Editor"); } |