diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-08-30 12:30:37 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2016-08-30 10:11:56 +0000 |
commit | e65a1d80f11c4b98e0fb92aa25c1db9f4bd5ff0a (patch) | |
tree | a1ea891034a6ee14f525298184d53c759236e697 /compatibility-shared/src | |
parent | d40910015746be496ba1ded4c12a019d801adb5e (diff) | |
download | vaadin-framework-e65a1d80f11c4b98e0fb92aa25c1db9f4bd5ff0a.tar.gz vaadin-framework-e65a1d80f11c4b98e0fb92aa25c1db9f4bd5ff0a.zip |
Duplicate shared classes of the Vaadin 7 Grid
Change-Id: I50cdcef0beb2f384636eb40c2f3f7493db52ac87
Diffstat (limited to 'compatibility-shared/src')
18 files changed, 1314 insertions, 0 deletions
diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ColumnGroupState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ColumnGroupState.java new file mode 100644 index 0000000000..f3751f449a --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ColumnGroupState.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.v7.shared.ui.grid; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * The column group data shared between the server and the client + * + * @since 7.4 + * @author Vaadin Ltd + */ +public class ColumnGroupState implements Serializable { + + /** + * The columns that is included in the group + */ + public List<String> columns = new ArrayList<String>(); + + /** + * The header text of the group + */ + public String header; + + /** + * The footer text of the group + */ + public String footer; +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/DetailsConnectorChange.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/DetailsConnectorChange.java new file mode 100644 index 0000000000..ff274ca432 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/DetailsConnectorChange.java @@ -0,0 +1,189 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +import java.io.Serializable; +import java.util.Comparator; + +import com.vaadin.shared.Connector; + +/** + * A description of an indexing modification for a connector. This is used by + * Grid for internal bookkeeping updates. + * + * @since 7.5.0 + * @author Vaadin Ltd + */ +public class DetailsConnectorChange implements Serializable { + + public static final Comparator<DetailsConnectorChange> REMOVED_FIRST_COMPARATOR = new Comparator<DetailsConnectorChange>() { + @Override + public int compare(DetailsConnectorChange a, DetailsConnectorChange b) { + boolean deleteA = a.getNewIndex() == null; + boolean deleteB = b.getNewIndex() == null; + if (deleteA && !deleteB) { + return -1; + } else if (!deleteA && deleteB) { + return 1; + } else { + return 0; + } + } + }; + + private Connector connector; + private Integer oldIndex; + private Integer newIndex; + private boolean shouldStillBeVisible; + + /** Create a new connector index change */ + public DetailsConnectorChange() { + } + + /** + * Convenience constructor for setting all the fields in one line. + * <p> + * Calling this constructor will also assert that the state of the pojo is + * consistent by internal assumptions. + * + * @param connector + * the changed connector + * @param oldIndex + * the old index + * @param newIndex + * the new index + * @param shouldStillBeVisible + * details should be visible regardless of {@code connector} + */ + public DetailsConnectorChange(Connector connector, Integer oldIndex, + Integer newIndex, boolean shouldStillBeVisible) { + this.connector = connector; + this.oldIndex = oldIndex; + this.newIndex = newIndex; + this.shouldStillBeVisible = shouldStillBeVisible; + + assert assertStateIsOk(); + } + + private boolean assertStateIsOk() { + boolean connectorAndNewIndexIsNotNull = connector != null + && newIndex != null; + boolean connectorAndNewIndexIsNullThenOldIndexIsSet = connector == null + && newIndex == null && oldIndex != null; + + assert (connectorAndNewIndexIsNotNull + || connectorAndNewIndexIsNullThenOldIndexIsSet) : "connector: " + + nullityString(connector) + ", oldIndex: " + + nullityString(oldIndex) + ", newIndex: " + + nullityString(newIndex); + return true; + } + + private static String nullityString(Object object) { + return object == null ? "null" : "non-null"; + } + + /** + * Gets the old index for the connector. + * <p> + * If <code>null</code>, the connector is recently added. This means that + * {@link #getConnector()} is expected not to return <code>null</code>. + * + * @return the old index for the connector + */ + public Integer getOldIndex() { + assert assertStateIsOk(); + return oldIndex; + } + + /** + * Gets the new index for the connector. + * <p> + * If <code>null</code>, the connector should be removed. This means that + * {@link #getConnector()} is expected to return <code>null</code> as well. + * + * @return the new index for the connector + */ + public Integer getNewIndex() { + assert assertStateIsOk(); + return newIndex; + } + + /** + * Gets the changed connector. + * + * @return the changed connector. Might be <code>null</code> + */ + public Connector getConnector() { + assert assertStateIsOk(); + return connector; + } + + /** + * Sets the changed connector. + * + * @param connector + * the changed connector. May be <code>null</code> + */ + public void setConnector(Connector connector) { + this.connector = connector; + } + + /** + * Sets the old index + * + * @param oldIndex + * the old index. May be <code>null</code> if a new connector is + * being inserted + */ + public void setOldIndex(Integer oldIndex) { + this.oldIndex = oldIndex; + } + + /** + * Sets the new index + * + * @param newIndex + * the new index. May be <code>null</code> if a connector is + * being removed + */ + public void setNewIndex(Integer newIndex) { + this.newIndex = newIndex; + } + + /** + * Checks whether whether the details should remain open, even if connector + * might be <code>null</code>. + * + * @return <code>true</code> iff the details should remain open, even if + * connector might be <code>null</code> + */ + public boolean isShouldStillBeVisible() { + return shouldStillBeVisible; + } + + /** + * Sets whether the details should remain open, even if connector might be + * <code>null</code>. + * + * @param shouldStillBeVisible + * <code>true</code> iff the details should remain open, even if + * connector might be <code>null</code> + */ + public void setShouldStillBeVisible(boolean shouldStillBeVisible) { + this.shouldStillBeVisible = shouldStillBeVisible; + } +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/EditorClientRpc.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/EditorClientRpc.java new file mode 100644 index 0000000000..72c7c83af6 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/EditorClientRpc.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +import java.util.List; + +import com.vaadin.shared.communication.ClientRpc; + +/** + * An RPC interface for the grid editor server-to-client communications. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public interface EditorClientRpc extends ClientRpc { + + /** + * Tells the client to open the editor and bind data to it. + * + * @param rowIndex + * the index of the edited row + */ + void bind(int rowIndex); + + /** + * Tells the client to cancel editing and hide the editor. + * + * @param rowIndex + * the index of the edited row + */ + void cancel(int rowIndex); + + /** + * Confirms a pending {@link EditorServerRpc#bind(int) bind request} sent by + * the client. + * + * @param bindSucceeded + * <code>true</code> iff the bind action was successful + */ + void confirmBind(boolean bindSucceeded); + + /** + * Confirms a pending {@link EditorServerRpc#save(int) save request} sent by + * the client. + * + * @param saveSucceeded + * <code>true</code> iff the save action was successful + * @param errorMessage + * the error message to show the user + * @param errorColumnsIds + * a list of column keys that should get error markers, or + * <code>null</code> if there should be no error markers + */ + void confirmSave(boolean saveSucceeded, String errorMessage, + List<String> errorColumnsIds); +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/EditorServerRpc.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/EditorServerRpc.java new file mode 100644 index 0000000000..df7b090f91 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/EditorServerRpc.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +import com.vaadin.shared.communication.ServerRpc; + +/** + * An RPC interface for the grid editor client-to-server communications. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public interface EditorServerRpc extends ServerRpc { + + /** + * 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 EditorClientRpc#confirmBind() confirm call} before the client can + * open the editor. + * + * @param rowIndex + * the index of the edited row + */ + void bind(int rowIndex); + + /** + * 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 + */ + void save(int rowIndex); + + /** + * 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. + * + * @param rowIndex + * the index of the edited row + */ + void cancel(int rowIndex); +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridClientRpc.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridClientRpc.java new file mode 100644 index 0000000000..64515d2205 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridClientRpc.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +import com.vaadin.shared.communication.ClientRpc; + +/** + * Server-to-client RPC interface for the Grid component. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public interface GridClientRpc extends ClientRpc { + + /** + * Command client Grid to scroll to a specific data row and its (optional) + * details. + * + * @param row + * zero-based row index. If the row index is below zero or above + * the row count of the client-side data source, a client-side + * exception will be triggered. Since this exception has no + * handling by default, an out-of-bounds value will cause a + * client-side crash. + * @param destination + * desired placement of scrolled-to row. See the documentation + * for {@link ScrollDestination} for more information. + */ + public void scrollToRow(int row, ScrollDestination destination); + + /** + * Command client Grid to scroll to the first row. + */ + public void scrollToStart(); + + /** + * Command client Grid to scroll to the last row. + */ + public void scrollToEnd(); + + /** + * Command client Grid to recalculate column widths. + */ + public void recalculateColumnWidths(); +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridColumnState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridColumnState.java new file mode 100644 index 0000000000..b1bf1844e6 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridColumnState.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +import java.io.Serializable; + +import com.vaadin.shared.Connector; + +/** + * Column state DTO for transferring column properties from the server to the + * client + * + * @since 7.4 + * @author Vaadin Ltd + */ +public class GridColumnState implements Serializable { + + /** + * Id used by grid connector to map server side column with client side + * column + */ + public String id; + + /** + * Column width in pixels. Default column width is + * {@value GridConstants#DEFAULT_COLUMN_WIDTH_PX}. + */ + public double width = GridConstants.DEFAULT_COLUMN_WIDTH_PX; + + /** + * The connector for the renderer used to render the cells in this column. + */ + public Connector rendererConnector; + + /** + * Whether the values in this column are editable when the editor interface + * is active. + */ + public boolean editable = true; + + /** + * The connector for the field used to edit cells in this column when the + * editor interface is active. + */ + public Connector editorConnector; + + /** + * Whether this column is sortable by the user + */ + public boolean sortable = false; + + /** How much of the remaining space this column will reserve. */ + public int expandRatio = GridConstants.DEFAULT_EXPAND_RATIO; + + /** + * The maximum expansion width of this column. -1 for "no maximum". If + * maxWidth is less than the calculated width, maxWidth is ignored. + */ + public double maxWidth = GridConstants.DEFAULT_MAX_WIDTH; + + /** + * The minimum expansion width of this column. -1 for "no minimum". If + * minWidth is less than the calculated width, minWidth will win. + */ + public double minWidth = GridConstants.DEFAULT_MIN_WIDTH; + + /** Whether this column is currently hidden. */ + public boolean hidden = false; + + /** Whether the column can be hidden by the user. */ + public boolean hidable = false; + + /** The caption for the column hiding toggle. */ + public String hidingToggleCaption; + + /** Column header caption */ + public String headerCaption; + + /** Whether this column is resizable by the user. */ + public boolean resizable = true; +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridConstants.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridConstants.java new file mode 100644 index 0000000000..dc9b2207e5 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridConstants.java @@ -0,0 +1,101 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +import java.io.Serializable; + +/** + * Container class for common constants and default values used by the Grid + * component. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public final class GridConstants implements Serializable { + + /** + * Enum describing different sections of Grid. + * + * @since 7.6 + */ + public enum Section { + HEADER, BODY, FOOTER + } + + /** + * Default padding in pixels when scrolling programmatically, without an + * explicitly defined padding value. + */ + public static final int DEFAULT_PADDING = 0; + + /** + * Delay before a long tap action is triggered. Number in milliseconds. + */ + public static final int LONG_TAP_DELAY = 500; + + /** + * The threshold in pixels a finger can move while long tapping. + */ + public static final int LONG_TAP_THRESHOLD = 3; + + /* Column constants */ + + /** + * Default maximum width for columns. + */ + public static final double DEFAULT_MAX_WIDTH = -1; + + /** + * Default minimum width for columns. + */ + public static final double DEFAULT_MIN_WIDTH = 10.0d; + + /** + * Default expand ratio for columns. + */ + public static final int DEFAULT_EXPAND_RATIO = -1; + + /** + * Default width for columns. + */ + public static final double DEFAULT_COLUMN_WIDTH_PX = -1; + + /** + * Event ID for item click events + */ + public static final String ITEM_CLICK_EVENT_ID = "itemClick"; + + /** The default save button caption in the editor */ + public static final String DEFAULT_SAVE_CAPTION = "Save"; + + /** The default cancel button caption in the editor */ + public static final String DEFAULT_CANCEL_CAPTION = "Cancel"; + + /** + * Event ID constant for editor open event + */ + public static final String EDITOR_OPEN_EVENT_ID = "editorOpen"; + + /** + * Event ID constant for editor move event + */ + public static final String EDITOR_MOVE_EVENT_ID = "editorMove"; + + /** + * Event ID constant for editor close event + */ + public static final String EDITOR_CLOSE_EVENT_ID = "editorClose"; +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridServerRpc.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridServerRpc.java new file mode 100644 index 0000000000..7fcf461244 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridServerRpc.java @@ -0,0 +1,103 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +import java.util.List; + +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.data.sort.SortDirection; +import com.vaadin.v7.shared.ui.grid.GridConstants.Section; + +/** + * Client-to-server RPC interface for the Grid component + * + * @since 7.4 + * @author Vaadin Ltd + */ +public interface GridServerRpc extends ServerRpc { + + void sort(String[] columnIds, SortDirection[] directions, + boolean userOriginated); + + /** + * Informs the server that an item has been clicked in Grid. + * + * @param rowKey + * a key identifying the clicked item + * @param columnId + * column id identifying the clicked property + * @param details + * mouse event details + */ + void itemClick(String rowKey, String columnId, MouseEventDetails details); + + /** + * Informs the server that a context click has happened inside of Grid. + * + * @since 7.6 + * @param rowIndex + * index of clicked row in Grid section + * @param rowKey + * a key identifying the clicked item + * @param columnId + * column id identifying the clicked property + * @param section + * grid section (header, footer, body) + * @param details + * mouse event details + */ + void contextClick(int rowIndex, String rowKey, String columnId, + Section section, MouseEventDetails details); + + /** + * Informs the server that the columns of the Grid have been reordered. + * + * @since 7.5.0 + * @param newColumnOrder + * a list of column ids in the new order + * @param oldColumnOrder + * a list of column ids in order before the change + */ + void columnsReordered(List<String> newColumnOrder, + List<String> oldColumnOrder); + + /** + * Informs the server that a column's visibility has been changed. + * + * @since 7.5.0 + * @param id + * the id of the column + * @param hidden + * <code>true</code> if hidden, <code>false</code> if unhidden + * @param userOriginated + * <code>true</code> if triggered by user, <code>false</code> if + * by code + */ + void columnVisibilityChanged(String id, boolean hidden, + boolean userOriginated); + + /** + * Informs the server that a column has been resized by the user. + * + * @since 7.6 + * @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/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridState.java new file mode 100644 index 0000000000..4befc1fe09 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridState.java @@ -0,0 +1,205 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.v7.shared.ui.grid; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.shared.annotations.DelegateToWidget; +import com.vaadin.shared.data.sort.SortDirection; +import com.vaadin.shared.ui.TabIndexState; + +/** + * The shared state for the {@link com.vaadin.ui.components.grid.Grid} component + * + * @since 7.4 + * @author Vaadin Ltd + */ +public class GridState extends TabIndexState { + + /** + * A description of which of the three bundled SelectionModels is currently + * in use. + * <p> + * Used as a data transfer object instead of the client/server ones, because + * they don't know about each others classes. + * + * @see com.vaadin.ui.components.grid.Grid.SelectionMode + * @see com.vaadin.client.ui.grid.Grid.SelectionMode + */ + public enum SharedSelectionMode { + /** + * Representation of a single selection mode + * + * @see com.vaadin.ui.components.grid.Grid.SelectionMode#SINGLE + * @see com.vaadin.client.ui.grid.Grid.SelectionMode#SINGLE + */ + SINGLE, + + /** + * Representation of a multiselection mode + * + * @see com.vaadin.ui.components.grid.Grid.SelectionMode#MULTI + * @see com.vaadin.client.ui.grid.Grid.SelectionMode#MULTI + */ + MULTI, + + /** + * Representation of a no-selection mode + * + * @see com.vaadin.ui.components.grid.Grid.SelectionMode#NONE + * @see com.vaadin.client.ui.grid.Grid.SelectionMode#NONE + */ + NONE; + } + + /** + * The default value for height-by-rows for both GWT widgets + * {@link com.vaadin.ui.components.grid Grid} and + * {@link com.vaadin.client.ui.grid.Escalator Escalator} + */ + public static final double DEFAULT_HEIGHT_BY_ROWS = 10.0d; + + /** + * The key in which a row's data can be found + * + * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String) + */ + public static final String JSONKEY_DATA = "d"; + + /** + * The key in which a row's own key can be found + * + * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String) + */ + public static final String JSONKEY_ROWKEY = "k"; + + /** + * The key in which a row's generated style can be found + * + * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String) + */ + public static final String JSONKEY_ROWSTYLE = "rs"; + + /** + * The key in which a generated styles for a row's cells can be found + * + * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String) + */ + public static final String JSONKEY_CELLSTYLES = "cs"; + + /** + * The key in which a row's description can be found + * + * @since 7.6 + * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String) + */ + public static final String JSONKEY_ROWDESCRIPTION = "rd"; + + /** + * The key in which a cell's description can be found + * + * @since 7.6 + * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String) + */ + public static final String JSONKEY_CELLDESCRIPTION = "cd"; + + /** + * The key that tells whether details are visible for the row. + * + * @since 7.5.0 + * + * @see com.vaadin.ui.Grid#setDetailsGenerator(com.vaadin.ui.Grid.DetailsGenerator) + * @see com.vaadin.ui.Grid#setDetailsVisible(Object, boolean) + * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, + * elemental.json.JsonArray) + */ + public static final String JSONKEY_DETAILS_VISIBLE = "dv"; + + /** + * The key that tells whether row is selected. + * + * @since 7.6 + */ + public static final String JSONKEY_SELECTED = "s"; + + { + primaryStyleName = "v-grid"; + } + + /** + * Columns in grid. + */ + public List<GridColumnState> columns = new ArrayList<GridColumnState>(); + + /** + * Column order in grid. + */ + public List<String> columnOrder = new ArrayList<String>(); + + public GridStaticSectionState header = new GridStaticSectionState(); + + public GridStaticSectionState footer = new GridStaticSectionState(); + + /** The number of frozen columns */ + public int frozenColumnCount = 0; + + /** The height of the Grid in terms of body rows. */ + @DelegateToWidget + public double heightByRows = DEFAULT_HEIGHT_BY_ROWS; + + /** The mode by which Grid defines its height. */ + @DelegateToWidget + public HeightMode heightMode = HeightMode.CSS; + + /** Keys of the currently sorted columns */ + public String[] sortColumns = new String[0]; + + /** Directions for each sorted column */ + public SortDirection[] sortDirs = new SortDirection[0]; + + /** The enabled state of the editor interface */ + public boolean editorEnabled = false; + + /** + * Buffered editor mode + * + * @since 7.6 + */ + @DelegateToWidget + public boolean editorBuffered = true; + + /** + * Whether rows and/or cells have generated descriptions (tooltips) + * + * @since 7.6 + */ + public boolean hasDescriptions; + + /** The caption for the save button in the editor */ + @DelegateToWidget + public String editorSaveCaption = GridConstants.DEFAULT_SAVE_CAPTION; + + /** The caption for the cancel button in the editor */ + @DelegateToWidget + public String editorCancelCaption = GridConstants.DEFAULT_CANCEL_CAPTION; + + /** Whether the columns can be reordered */ + @DelegateToWidget + public boolean columnReorderingAllowed; + +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridStaticCellType.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridStaticCellType.java new file mode 100644 index 0000000000..70da93f573 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridStaticCellType.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +/** + * Enumeration, specifying the content type of a Cell in a GridStaticSection. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public enum GridStaticCellType { + /** + * Text content + */ + TEXT, + + /** + * HTML content + */ + HTML, + + /** + * Widget content + */ + WIDGET; +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridStaticSectionState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridStaticSectionState.java new file mode 100644 index 0000000000..560f0f17d1 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/GridStaticSectionState.java @@ -0,0 +1,68 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.vaadin.shared.Connector; + +/** + * Shared state for Grid headers and footers. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public class GridStaticSectionState implements Serializable { + + public static class CellState implements Serializable { + public String text = ""; + + public String html = ""; + + public Connector connector = null; + + public GridStaticCellType type = GridStaticCellType.TEXT; + + public String columnId; + + public String styleName = null; + } + + public static class RowState implements Serializable { + public List<CellState> cells = new ArrayList<CellState>(); + + public boolean defaultRow = false; + + /** + * Map from column id set to cell state for merged state. + */ + public Map<Set<String>, CellState> cellGroups = new HashMap<Set<String>, CellState>(); + + /** + * The style name for the row. Null if none. + */ + public String styleName = null; + } + + public List<RowState> rows = new ArrayList<RowState>(); + + public boolean visible = true; +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/HeightMode.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/HeightMode.java new file mode 100644 index 0000000000..2647a17abd --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/HeightMode.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +/** + * The modes for height calculation that are supported by Grid ( + * {@link com.vaadin.client.ui.grid.Grid client} and + * {@link com.vaadin.ui.components.grid.Grid server}) / + * {@link com.vaadin.client.ui.grid.Escalator Escalator}. + * + * @since 7.4 + * @author Vaadin Ltd + * @see com.vaadin.client.ui.grid.Grid#setHeightMode(HeightMode) + * @see com.vaadin.ui.components.grid.Grid#setHeightMode(HeightMode) + * @see com.vaadin.client.ui.grid.Escalator#setHeightMode(HeightMode) + */ +public enum HeightMode { + /** + * The height of the Component or Widget is defined by a CSS-like value. + * (e.g. "100px", "50em" or "25%") + */ + CSS, + + /** + * The height of the Component or Widget in question is defined by a number + * of rows. + */ + ROW, + + /** + * The height of the Component or Widget in question is defined by its + * contents. + */ + UNDEFINED; +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ScrollDestination.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ScrollDestination.java new file mode 100644 index 0000000000..faa212c5ad --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ScrollDestination.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid; + +/** + * Enumeration, specifying the destinations that are supported when scrolling + * rows or columns into view. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public enum ScrollDestination { + + /** + * Scroll as little as possible to show the target element. If the element + * fits into view, this works as START or END depending on the current + * scroll position. If the element does not fit into view, this works as + * START. + */ + ANY, + + /** + * Scrolls so that the element is shown at the start of the viewport. The + * viewport will, however, not scroll beyond its contents. + */ + START, + + /** + * Scrolls so that the element is shown in the middle of the viewport. The + * viewport will, however, not scroll beyond its contents, given more + * elements than what the viewport is able to show at once. Under no + * circumstances will the viewport scroll before its first element. + */ + MIDDLE, + + /** + * Scrolls so that the element is shown at the end of the viewport. The + * viewport will, however, not scroll before its first element. + */ + END + +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/renderers/RendererClickRpc.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/renderers/RendererClickRpc.java new file mode 100644 index 0000000000..cad4a1a76d --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/renderers/RendererClickRpc.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid.renderers; + +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.ServerRpc; + +public interface RendererClickRpc extends ServerRpc { + /** + * Called when a click event has occurred and there are server side + * listeners for the event. + * + * @param mouseDetails + * Details about the mouse when the event took place + */ + public void click(String rowKey, String columnId, + MouseEventDetails mouseDetails); +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelServerRpc.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelServerRpc.java new file mode 100644 index 0000000000..ba8ed0f3a5 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelServerRpc.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid.selection; + +import java.util.List; + +import com.vaadin.shared.communication.ServerRpc; + +/** + * ServerRpc for MultiSelectionModel. + * + * @since 7.6 + * @author Vaadin Ltd + */ +public interface MultiSelectionModelServerRpc extends ServerRpc { + + /** + * Select a list of rows based on their row keys on the server-side. + * + * @param rowKeys + * list of row keys to select + */ + public void select(List<String> rowKeys); + + /** + * Deselect a list of rows based on their row keys on the server-side. + * + * @param rowKeys + * list of row keys to deselect + */ + public void deselect(List<String> rowKeys); + + /** + * Selects all rows on the server-side. + */ + public void selectAll(); + + /** + * Deselects all rows on the server-side. + */ + public void deselectAll(); +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelState.java new file mode 100644 index 0000000000..c04d9aaff5 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelState.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid.selection; + +import com.vaadin.shared.communication.SharedState; + +/** + * SharedState object for MultiSelectionModel. + * + * @since 7.6 + * @author Vaadin Ltd + */ +public class MultiSelectionModelState extends SharedState { + + /* Select All -checkbox status */ + public boolean allSelected; + +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelServerRpc.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelServerRpc.java new file mode 100644 index 0000000000..a5561f4665 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelServerRpc.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid.selection; + +import com.vaadin.shared.communication.ServerRpc; + +/** + * ServerRpc for SingleSelectionModel. + * + * @since 7.6 + * @author Vaadin Ltd + */ +public interface SingleSelectionModelServerRpc extends ServerRpc { + + /** + * Selects a row on server-side. + * + * @param rowKey + * row key of selected row; {@code null} if deselect + */ + public void select(String rowKey); +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelState.java new file mode 100644 index 0000000000..a9fb816449 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelState.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.shared.ui.grid.selection; + +import com.vaadin.shared.communication.SharedState; + +/** + * SharedState object for SingleSelectionModel. + * + * @since 7.6 + * @author Vaadin Ltd + */ +public class SingleSelectionModelState extends SharedState { + + /* Allow deselecting rows */ + public boolean deselectAllowed = true; +} |