You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GridState.java 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.shared.ui.grid;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import com.vaadin.shared.annotations.DelegateToWidget;
  20. import com.vaadin.shared.data.sort.SortDirection;
  21. import com.vaadin.shared.ui.TabIndexState;
  22. import com.vaadin.shared.ui.label.ContentMode;
  23. /**
  24. * The shared state for the {@link com.vaadin.ui.components.grid.Grid} component
  25. *
  26. * @since 7.4
  27. * @author Vaadin Ltd
  28. */
  29. public class GridState extends TabIndexState {
  30. /**
  31. * A description of which of the three bundled SelectionModels is currently
  32. * in use.
  33. * <p>
  34. * Used as a data transfer object instead of the client/server ones, because
  35. * they don't know about each others classes.
  36. *
  37. * @see com.vaadin.ui.components.grid.Grid.SelectionMode
  38. * @see com.vaadin.client.ui.grid.Grid.SelectionMode
  39. */
  40. public enum SharedSelectionMode {
  41. /**
  42. * Representation of a single selection mode
  43. *
  44. * @see com.vaadin.ui.components.grid.Grid.SelectionMode#SINGLE
  45. * @see com.vaadin.client.ui.grid.Grid.SelectionMode#SINGLE
  46. */
  47. SINGLE,
  48. /**
  49. * Representation of a multiselection mode
  50. *
  51. * @see com.vaadin.ui.components.grid.Grid.SelectionMode#MULTI
  52. * @see com.vaadin.client.ui.grid.Grid.SelectionMode#MULTI
  53. */
  54. MULTI,
  55. /**
  56. * Representation of a no-selection mode
  57. *
  58. * @see com.vaadin.ui.components.grid.Grid.SelectionMode#NONE
  59. * @see com.vaadin.client.ui.grid.Grid.SelectionMode#NONE
  60. */
  61. NONE;
  62. }
  63. /**
  64. * The default value for height-by-rows for both GWT widgets
  65. * {@link com.vaadin.ui.components.grid Grid} and
  66. * {@link com.vaadin.client.ui.grid.Escalator Escalator}
  67. */
  68. public static final double DEFAULT_HEIGHT_BY_ROWS = 10.0d;
  69. /**
  70. * The key in which a row's data can be found
  71. *
  72. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  73. */
  74. public static final String JSONKEY_DATA = "d";
  75. /**
  76. * The key in which a row's own key can be found
  77. *
  78. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  79. */
  80. public static final String JSONKEY_ROWKEY = "k";
  81. /**
  82. * The key in which a row's generated style can be found
  83. *
  84. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  85. */
  86. public static final String JSONKEY_ROWSTYLE = "rs";
  87. /**
  88. * The key in which a generated styles for a row's cells can be found
  89. *
  90. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  91. */
  92. public static final String JSONKEY_CELLSTYLES = "cs";
  93. /**
  94. * The key in which a row's description can be found
  95. *
  96. * @since 7.6
  97. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  98. */
  99. public static final String JSONKEY_ROWDESCRIPTION = "rd";
  100. /**
  101. * The key in which a cell's description can be found
  102. *
  103. * @since 7.6
  104. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  105. */
  106. public static final String JSONKEY_CELLDESCRIPTION = "cd";
  107. /**
  108. * The key that tells whether details are visible for the row.
  109. *
  110. * @since 7.5.0
  111. *
  112. * @see com.vaadin.ui.Grid#setDetailsGenerator(com.vaadin.ui.Grid.DetailsGenerator)
  113. * @see com.vaadin.ui.Grid#setDetailsVisible(Object, boolean)
  114. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  115. * elemental.json.JsonArray)
  116. */
  117. public static final String JSONKEY_DETAILS_VISIBLE = "dv";
  118. /**
  119. * The key that tells whether row is selected.
  120. *
  121. * @since 7.6
  122. */
  123. public static final String JSONKEY_SELECTED = "s";
  124. {
  125. primaryStyleName = "v-grid";
  126. }
  127. /**
  128. * Column resize mode in grid.
  129. *
  130. * @since 7.7.5
  131. */
  132. public ColumnResizeMode columnResizeMode = ColumnResizeMode.ANIMATED;
  133. /**
  134. * Columns in grid.
  135. */
  136. public List<GridColumnState> columns = new ArrayList<GridColumnState>();
  137. /**
  138. * Column order in grid.
  139. */
  140. public List<String> columnOrder = new ArrayList<String>();
  141. public GridStaticSectionState header = new GridStaticSectionState();
  142. public GridStaticSectionState footer = new GridStaticSectionState();
  143. /** The number of frozen columns */
  144. public int frozenColumnCount = 0;
  145. /** The height of the Grid in terms of body rows. */
  146. @DelegateToWidget
  147. public double heightByRows = DEFAULT_HEIGHT_BY_ROWS;
  148. /** The mode by which Grid defines its height. */
  149. @DelegateToWidget
  150. public HeightMode heightMode = HeightMode.CSS;
  151. /** Keys of the currently sorted columns */
  152. public String[] sortColumns = new String[0];
  153. /** Directions for each sorted column */
  154. public SortDirection[] sortDirs = new SortDirection[0];
  155. /** The enabled state of the editor interface */
  156. public boolean editorEnabled = false;
  157. /**
  158. * Buffered editor mode
  159. *
  160. * @since 7.6
  161. */
  162. @DelegateToWidget
  163. public boolean editorBuffered = true;
  164. /**
  165. * Whether rows and/or cells have generated descriptions (tooltips)
  166. *
  167. * @since 7.6
  168. */
  169. public boolean hasDescriptions;
  170. /** The caption for the save button in the editor */
  171. @DelegateToWidget
  172. public String editorSaveCaption = GridConstants.DEFAULT_SAVE_CAPTION;
  173. /** The caption for the cancel button in the editor */
  174. @DelegateToWidget
  175. public String editorCancelCaption = GridConstants.DEFAULT_CANCEL_CAPTION;
  176. /** Whether the columns can be reordered */
  177. @DelegateToWidget
  178. public boolean columnReorderingAllowed;
  179. /**
  180. * The content mode used for cell tooltips.
  181. *
  182. * @since
  183. */
  184. /*
  185. * When porting this to the v7 version in Framework 8, the default should be
  186. * changed to PREFORMATTED to preserve the more secure default that has
  187. * accidentally been used there.
  188. */
  189. public ContentMode cellTooltipContentMode = ContentMode.HTML;
  190. /**
  191. * The content mode used for row tooltips.
  192. *
  193. * @since
  194. */
  195. /*
  196. * When porting this to the v7 version in Framework 8, the default should be
  197. * changed to PREFORMATTED to preserve the more secure default that has
  198. * accidentally been used there.
  199. */
  200. public ContentMode rowTooltipContentMode = ContentMode.HTML;
  201. }