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.8KB

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