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.

ColumnConfiguration.java 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.client.widget.escalator;
  17. import java.util.Map;
  18. import com.vaadin.client.widgets.Escalator;
  19. /**
  20. * A representation of the columns in an instance of {@link Escalator}.
  21. *
  22. * @since 7.4
  23. * @author Vaadin Ltd
  24. * @see Escalator#getColumnConfiguration()
  25. */
  26. public interface ColumnConfiguration {
  27. /**
  28. * Removes columns at certain indices.
  29. * <p>
  30. * If any of the removed columns were frozen, the number of frozen columns
  31. * will be reduced by the number of the removed columns that were frozen.
  32. * <p>
  33. * <em>Note:</em> This method simply removes the given columns, and does not
  34. * do much of anything else. Especially if you have column spans, you
  35. * probably need to run {@link #refreshColumns(int, int)} or
  36. * {@link RowContainer#refreshRows(int, int)}
  37. *
  38. * @param index
  39. * the index of the first column to be removed
  40. * @param numberOfColumns
  41. * the number of rows to remove, starting from {@code index}
  42. * @throws IndexOutOfBoundsException
  43. * if the entire range of removed columns is not currently
  44. * present in the escalator
  45. * @throws IllegalArgumentException
  46. * if <code>numberOfColumns</code> is less than 1.
  47. */
  48. public void removeColumns(int index, int numberOfColumns)
  49. throws IndexOutOfBoundsException, IllegalArgumentException;
  50. /**
  51. * Adds columns at a certain index.
  52. * <p>
  53. * The new columns will be inserted between the column at the index, and the
  54. * column before (an index of 0 means that the columns are inserted at the
  55. * beginning). Therefore, the columns at the index and afterwards will be
  56. * moved to the right.
  57. * <p>
  58. * The contents of the inserted columns will be queried from the respective
  59. * cell renderers in the header, body and footer.
  60. * <p>
  61. * If there are frozen columns and the first added column is to the left of
  62. * the last frozen column, the number of frozen columns will be increased by
  63. * the number of inserted columns.
  64. * <p>
  65. * <em>Note:</em> Only the contents of the inserted columns will be
  66. * rendered. If inserting new columns affects the contents of existing
  67. * columns (e.g. you have column spans),
  68. * {@link RowContainer#refreshRows(int, int)} or
  69. * {@link #refreshColumns(int, int)} needs to be called as appropriate.
  70. *
  71. * @param index
  72. * the index of the column before which new columns are inserted,
  73. * or {@link #getColumnCount()} to add new columns at the end
  74. * @param numberOfColumns
  75. * the number of columns to insert after the <code>index</code>
  76. * @throws IndexOutOfBoundsException
  77. * if <code>index</code> is not an integer in the range
  78. * <code>[0..{@link #getColumnCount()}]</code>
  79. * @throws IllegalArgumentException
  80. * if {@code numberOfColumns} is less than 1.
  81. */
  82. public void insertColumns(int index, int numberOfColumns)
  83. throws IndexOutOfBoundsException, IllegalArgumentException;
  84. /**
  85. * Returns the number of columns in the escalator.
  86. *
  87. * @return the number of columns in the escalator
  88. */
  89. public int getColumnCount();
  90. /**
  91. * Sets the number of leftmost columns that are not affected by horizontal
  92. * scrolling.
  93. *
  94. * @param count
  95. * the number of columns to freeze
  96. *
  97. * @throws IllegalArgumentException
  98. * if the column count is &lt; 0 or &gt; the number of columns
  99. *
  100. */
  101. public void setFrozenColumnCount(int count) throws IllegalArgumentException;
  102. /**
  103. * Get the number of leftmost columns that are not affected by horizontal
  104. * scrolling.
  105. *
  106. * @return the number of frozen columns
  107. */
  108. public int getFrozenColumnCount();
  109. /**
  110. * Sets (or unsets) an explicit width for a column.
  111. *
  112. * @param index
  113. * the index of the column for which to set a width
  114. * @param px
  115. * the number of pixels the indicated column should be, or a
  116. * negative number to let the escalator decide
  117. * @throws IllegalArgumentException
  118. * if <code>index</code> is not a valid column index
  119. */
  120. public void setColumnWidth(int index, double px)
  121. throws IllegalArgumentException;
  122. /**
  123. * Returns the user-defined width of a column.
  124. *
  125. * @param index
  126. * the index of the column for which to retrieve the width
  127. * @return the column's width in pixels, or a negative number if the width
  128. * is implicitly decided by the escalator
  129. * @throws IllegalArgumentException
  130. * if <code>index</code> is not a valid column index
  131. */
  132. public double getColumnWidth(int index) throws IllegalArgumentException;
  133. /**
  134. * Sets widths for a set of columns. Triggers element size recalculation for
  135. * elements that require manual calculations.
  136. *
  137. * @param indexWidthMap
  138. * a map from column index to its respective width to be set. If
  139. * the given width for a column index is negative, the column is
  140. * resized-to-fit.
  141. * @throws IllegalArgumentException
  142. * if {@code indexWidthMap} is {@code null}
  143. * @throws IllegalArgumentException
  144. * if any column index in {@code indexWidthMap} is invalid
  145. * @throws NullPointerException
  146. * If any value in the map is <code>null</code>
  147. */
  148. public void setColumnWidths(Map<Integer, Double> indexWidthMap)
  149. throws IllegalArgumentException;
  150. /**
  151. * Sets widths for a set of columns.
  152. *
  153. * @param indexWidthMap
  154. * a map from column index to its respective width to be set. If
  155. * the given width for a column index is negative, the column is
  156. * resized-to-fit.
  157. * @param recalculateElementSizes
  158. * should the element size recalculation be triggered for
  159. * elements that require manual calculation
  160. * @throws IllegalArgumentException
  161. * if {@code indexWidthMap} is {@code null}
  162. * @throws IllegalArgumentException
  163. * if any column index in {@code indexWidthMap} is invalid
  164. * @throws NullPointerException
  165. * If any value in the map is <code>null</code>
  166. */
  167. public void setColumnWidths(Map<Integer, Double> indexWidthMap,
  168. boolean recalculateElementSizes) throws IllegalArgumentException;
  169. /**
  170. * Returns the actual width of a column.
  171. *
  172. * @param index
  173. * the index of the column for which to retrieve the width
  174. * @return the column's actual width in pixels
  175. * @throws IllegalArgumentException
  176. * if <code>index</code> is not a valid column index
  177. */
  178. public double getColumnWidthActual(int index)
  179. throws IllegalArgumentException;
  180. /**
  181. * Refreshes a range of columns in the current row containers in each
  182. * Escalator section.
  183. * <p>
  184. * The data for the refreshed columns is queried from the current cell
  185. * renderer.
  186. *
  187. * @param index
  188. * the index of the first column that will be updated
  189. * @param numberOfColumns
  190. * the number of columns to update, starting from the index
  191. * @throws IndexOutOfBoundsException
  192. * if any integer number in the range
  193. * <code>[index..(index+numberOfColumns)]</code> is not an
  194. * existing column index.
  195. * @throws IllegalArgumentException
  196. * if {@code numberOfColumns} is less than 1.
  197. * @see RowContainer#setEscalatorUpdater(EscalatorUpdater)
  198. * @see Escalator#getHeader()
  199. * @see Escalator#getBody()
  200. * @see Escalator#getFooter()
  201. */
  202. public void refreshColumns(int index, int numberOfColumns)
  203. throws IndexOutOfBoundsException, IllegalArgumentException;
  204. }