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

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