Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

GridState.java 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * Copyright 2000-2016 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.v7.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.ContentMode;
  22. import com.vaadin.shared.ui.TabIndexState;
  23. /**
  24. * The shared state for the {@link com.vaadin.ui.components.grid.Grid}
  25. * component.
  26. *
  27. * @since 7.4
  28. * @author Vaadin Ltd
  29. */
  30. public class GridState extends TabIndexState {
  31. /**
  32. * A description of which of the three bundled SelectionModels is currently
  33. * in use.
  34. * <p>
  35. * Used as a data transfer object instead of the client/server ones, because
  36. * they don't know about each others classes.
  37. *
  38. * @see com.vaadin.ui.components.grid.Grid.SelectionMode
  39. * @see com.vaadin.client.ui.grid.Grid.SelectionMode
  40. */
  41. public enum SharedSelectionMode {
  42. /**
  43. * Representation of a single selection mode.
  44. *
  45. * @see com.vaadin.ui.components.grid.Grid.SelectionMode#SINGLE
  46. * @see com.vaadin.client.ui.grid.Grid.SelectionMode#SINGLE
  47. */
  48. SINGLE,
  49. /**
  50. * Representation of a multiselection mode.
  51. *
  52. * @see com.vaadin.ui.components.grid.Grid.SelectionMode#MULTI
  53. * @see com.vaadin.client.ui.grid.Grid.SelectionMode#MULTI
  54. */
  55. MULTI,
  56. /**
  57. * Representation of a no-selection mode.
  58. *
  59. * @see com.vaadin.ui.components.grid.Grid.SelectionMode#NONE
  60. * @see com.vaadin.client.ui.grid.Grid.SelectionMode#NONE
  61. */
  62. NONE;
  63. }
  64. /**
  65. * The default value for height-by-rows for both GWT widgets
  66. * {@link com.vaadin.ui.components.grid Grid} and
  67. * {@link com.vaadin.client.ui.grid.Escalator Escalator}.
  68. */
  69. public static final double DEFAULT_HEIGHT_BY_ROWS = 10.0d;
  70. /**
  71. * The key in which a row's data can be found.
  72. *
  73. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  74. */
  75. public static final String JSONKEY_DATA = "d";
  76. /**
  77. * The key in which a row's own key can be found.
  78. *
  79. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  80. */
  81. public static final String JSONKEY_ROWKEY = "k";
  82. /**
  83. * The key in which a row's generated style can be found.
  84. *
  85. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  86. */
  87. public static final String JSONKEY_ROWSTYLE = "rs";
  88. /**
  89. * The key in which a generated styles for a row's cells can be found.
  90. *
  91. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  92. */
  93. public static final String JSONKEY_CELLSTYLES = "cs";
  94. /**
  95. * The key in which a row's description can be found.
  96. *
  97. * @since 7.6
  98. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  99. */
  100. public static final String JSONKEY_ROWDESCRIPTION = "rd";
  101. /**
  102. * The key in which a cell's description can be found.
  103. *
  104. * @since 7.6
  105. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, String)
  106. */
  107. public static final String JSONKEY_CELLDESCRIPTION = "cd";
  108. /**
  109. * The key that tells whether details are visible for the row.
  110. *
  111. * @since 7.5.0
  112. *
  113. * @see com.vaadin.ui.Grid#setDetailsGenerator(com.vaadin.ui.Grid.DetailsGenerator)
  114. * @see com.vaadin.ui.Grid#setDetailsVisible(Object, boolean)
  115. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  116. * elemental.json.JsonArray)
  117. */
  118. public static final String JSONKEY_DETAILS_VISIBLE = "dv";
  119. /**
  120. * The key that tells whether row is selected.
  121. *
  122. * @since 7.6
  123. */
  124. public static final String JSONKEY_SELECTED = "s";
  125. {
  126. primaryStyleName = "v-grid";
  127. }
  128. /**
  129. * Column resize mode in grid.
  130. *
  131. * @since 7.7.5
  132. */
  133. public ColumnResizeMode columnResizeMode = ColumnResizeMode.ANIMATED;
  134. /**
  135. * Columns in grid.
  136. */
  137. public List<GridColumnState> columns = new ArrayList<GridColumnState>();
  138. /**
  139. * Column order in grid.
  140. */
  141. public List<String> columnOrder = new ArrayList<String>();
  142. public GridStaticSectionState header = new GridStaticSectionState();
  143. public GridStaticSectionState footer = new GridStaticSectionState();
  144. /** The number of frozen columns. */
  145. public int frozenColumnCount = 0;
  146. /** The height of the Grid in terms of body rows. */
  147. @DelegateToWidget
  148. public double heightByRows = DEFAULT_HEIGHT_BY_ROWS;
  149. /** The mode by which Grid defines its height. */
  150. @DelegateToWidget
  151. public HeightMode heightMode = HeightMode.CSS;
  152. /** Keys of the currently sorted columns. */
  153. public String[] sortColumns = new String[0];
  154. /** Directions for each sorted column. */
  155. public SortDirection[] sortDirs = new SortDirection[0];
  156. /** The enabled state of the editor interface. */
  157. public boolean editorEnabled = false;
  158. /**
  159. * Buffered editor mode.
  160. *
  161. * @since 7.6
  162. */
  163. @DelegateToWidget
  164. public boolean editorBuffered = true;
  165. /**
  166. * Whether rows and/or cells have generated descriptions (tooltips).
  167. *
  168. * @since 7.6
  169. */
  170. public boolean hasDescriptions;
  171. /** The caption for the save button in the editor. */
  172. @DelegateToWidget
  173. public String editorSaveCaption = GridConstants.DEFAULT_SAVE_CAPTION;
  174. /** The caption for the cancel button in the editor. */
  175. @DelegateToWidget
  176. public String editorCancelCaption = GridConstants.DEFAULT_CANCEL_CAPTION;
  177. /** Whether the columns can be reordered. */
  178. @DelegateToWidget
  179. public boolean columnReorderingAllowed;
  180. /**
  181. * The content mode used for cell tooltips.
  182. *
  183. * @since
  184. */
  185. public ContentMode cellTooltipContentMode = ContentMode.PREFORMATTED;
  186. /**
  187. * The content mode used for row tooltips.
  188. *
  189. * @since
  190. */
  191. public ContentMode rowTooltipContentMode = ContentMode.PREFORMATTED;
  192. }