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 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Copyright 2000-2018 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.AbstractSingleSelectState;
  22. import com.vaadin.shared.ui.ContentMode;
  23. /**
  24. * The shared state for the {@link com.vaadin.ui.Grid} component.
  25. *
  26. * @since 8.0
  27. * @author Vaadin Ltd
  28. */
  29. public class GridState extends AbstractSingleSelectState {
  30. /**
  31. * The default value for height-by-rows for both GWT widgets
  32. * {@link com.vaadin.client.widgets.Grid} and
  33. * {@link com.vaadin.client.widgets.Escalator Escalator}.
  34. */
  35. public static final double DEFAULT_HEIGHT_BY_ROWS = 10.0d;
  36. /**
  37. * The key in which a row's data can be found.
  38. *
  39. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  40. * elemental.json.JsonArray)
  41. */
  42. public static final String JSONKEY_DATA = "d";
  43. /**
  44. * The key in which a row's own key can be found.
  45. *
  46. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  47. * elemental.json.JsonArray)
  48. */
  49. public static final String JSONKEY_ROWKEY = "k";
  50. /**
  51. * The key in which a row's generated style can be found.
  52. *
  53. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  54. * elemental.json.JsonArray)
  55. */
  56. public static final String JSONKEY_ROWSTYLE = "rs";
  57. /**
  58. * The key in which a generated styles for a row's cells can be found.
  59. *
  60. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  61. * elemental.json.JsonArray)
  62. */
  63. public static final String JSONKEY_CELLSTYLES = "cs";
  64. /**
  65. * The key in which a row's description can be found.
  66. *
  67. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  68. * elemental.json.JsonArray)
  69. */
  70. public static final String JSONKEY_ROWDESCRIPTION = "rd";
  71. /**
  72. * The key in which a cell's description can be found.
  73. *
  74. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  75. * elemental.json.JsonArray)
  76. */
  77. public static final String JSONKEY_CELLDESCRIPTION = "cd";
  78. /**
  79. * The key that tells whether details are visible for the row.
  80. *
  81. * @see com.vaadin.ui.Grid#setDetailsGenerator(com.vaadin.ui.components.grid.DetailsGenerator)
  82. * @see com.vaadin.ui.Grid#setDetailsVisible(Object, boolean)
  83. * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
  84. * elemental.json.JsonArray)
  85. */
  86. public static final String JSONKEY_DETAILS_VISIBLE = "dv";
  87. /**
  88. * The key that tells whether row is selected or not.
  89. */
  90. public static final String JSONKEY_SELECTED = "s";
  91. {
  92. primaryStyleName = "v-grid";
  93. }
  94. /**
  95. * Column resize mode in grid.
  96. *
  97. * @since 7.7.5
  98. */
  99. public ColumnResizeMode columnResizeMode = ColumnResizeMode.ANIMATED;
  100. /** The state of the header section. */
  101. public SectionState header = new SectionState();
  102. /** The state of the footer section. */
  103. public SectionState footer = new SectionState();
  104. /**
  105. * Column order in grid.
  106. */
  107. public List<String> columnOrder = new ArrayList<>();
  108. /** The number of frozen columns. */
  109. @DelegateToWidget
  110. public int frozenColumnCount = 0;
  111. /** The height of the Grid in terms of body rows. */
  112. @DelegateToWidget
  113. public double heightByRows = DEFAULT_HEIGHT_BY_ROWS;
  114. /** The mode by which Grid defines its height. */
  115. @DelegateToWidget
  116. public HeightMode heightMode = HeightMode.CSS;
  117. /** Keys of the currently sorted columns. */
  118. public String[] sortColumns = new String[0];
  119. /** Directions for each sorted column. */
  120. public SortDirection[] sortDirs = new SortDirection[0];
  121. /**
  122. * Whether rows and/or cells have generated descriptions (tooltips).
  123. */
  124. public boolean hasDescriptions;
  125. /** Whether the columns can be reordered. */
  126. @DelegateToWidget
  127. public boolean columnReorderingAllowed;
  128. /**
  129. * Explicit body row height in pixels for grid rows, or -1 to calculate
  130. * automatically based on the theme.
  131. *
  132. * @since 8.2
  133. */
  134. public double bodyRowHeight = -1;
  135. /**
  136. * Explicit body row height in pixels for grid rows, or -1 to calculate
  137. * automatically based on the theme.
  138. *
  139. * @since 8.2
  140. */
  141. public double headerRowHeight = -1;
  142. /**
  143. * Explicit body row height in pixels for grid rows, or -1 to calculate
  144. * automatically based on the theme.
  145. *
  146. * @since 8.2
  147. */
  148. public double footerRowHeight = -1;
  149. /**
  150. * The content mode for row descriptions.
  151. *
  152. * @since 8.2
  153. */
  154. public ContentMode rowDescriptionContentMode;
  155. }