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.

RendererCellReference.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright 2000-2016 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.v7.client.widget.grid;
  17. import com.google.gwt.dom.client.TableCellElement;
  18. import com.vaadin.v7.client.widget.escalator.FlyweightCell;
  19. import com.vaadin.v7.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. public void set(FlyweightCell cell, int columnIndex,
  53. Grid.Column<?, ?> column) {
  54. this.cell = cell;
  55. super.set(cell.getColumn(), columnIndex,
  56. (Grid.Column<?, Object>) column);
  57. }
  58. /**
  59. * Returns the element of the cell. Can be either a <code>TD</code> element
  60. * or a <code>TH</code> element.
  61. *
  62. * @return the element of the cell
  63. */
  64. @Override
  65. public TableCellElement getElement() {
  66. return cell.getElement();
  67. }
  68. /**
  69. * Sets the colspan attribute of the element of this cell.
  70. *
  71. * @param numberOfCells
  72. * the number of columns that the cell should span
  73. */
  74. public void setColSpan(int numberOfCells) {
  75. cell.setColSpan(numberOfCells);
  76. }
  77. /**
  78. * Gets the colspan attribute of the element of this cell.
  79. *
  80. * @return the number of columns that the cell should span
  81. */
  82. public int getColSpan() {
  83. return cell.getColSpan();
  84. }
  85. }