Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

RendererCellReference.java 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright 2000-2021 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.grid;
  17. import com.google.gwt.dom.client.TableCellElement;
  18. import com.vaadin.client.widget.escalator.FlyweightCell;
  19. import com.vaadin.client.widgets.Grid;
  20. /**
  21. * A data class which contains information which identifies a cell being
  22. * rendered in a {@link Grid}.
  23. * <p>
  24. * Since this class follows the <code>Flyweight</code>-pattern any instance of
  25. * this object is subject to change without the user knowing it and so should
  26. * not be stored anywhere outside of the method providing these instances.
  27. *
  28. * @since 7.4
  29. * @author Vaadin Ltd
  30. */
  31. public class RendererCellReference extends CellReference<Object> {
  32. /**
  33. * Creates a new renderer cell reference bound to a row reference.
  34. *
  35. * @param rowReference
  36. * the row reference to bind to
  37. */
  38. public RendererCellReference(RowReference<Object> rowReference) {
  39. super(rowReference);
  40. }
  41. private FlyweightCell cell;
  42. /**
  43. * Sets the identifying information for this cell.
  44. *
  45. * @param cell
  46. * the flyweight cell to reference
  47. * @param columnIndex
  48. * the index of the column in the grid, including hidden cells
  49. * @param column
  50. * the column to reference
  51. */
  52. @SuppressWarnings("unchecked")
  53. public void set(FlyweightCell cell, int columnIndex,
  54. Grid.Column<?, ?> column) {
  55. this.cell = cell;
  56. super.set(cell.getColumn(), columnIndex,
  57. (Grid.Column<?, Object>) column);
  58. }
  59. /**
  60. * Returns the element of the cell. Can be either a <code>TD</code> element
  61. * or a <code>TH</code> element.
  62. *
  63. * @return the element of the cell
  64. */
  65. @Override
  66. public TableCellElement getElement() {
  67. return cell.getElement();
  68. }
  69. /**
  70. * Sets the colspan attribute of the element of this cell.
  71. *
  72. * @param numberOfCells
  73. * the number of columns that the cell should span
  74. */
  75. public void setColSpan(int numberOfCells) {
  76. cell.setColSpan(numberOfCells);
  77. }
  78. /**
  79. * Gets the colspan attribute of the element of this cell.
  80. *
  81. * @return the number of columns that the cell should span
  82. */
  83. public int getColSpan() {
  84. return cell.getColSpan();
  85. }
  86. }