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.

EscalatorProxy.java 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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.tests.widgetset.client.grid;
  17. import java.util.Map;
  18. import com.google.gwt.dom.client.Element;
  19. import com.google.gwt.dom.client.TableRowElement;
  20. import com.google.gwt.dom.client.TableSectionElement;
  21. import com.vaadin.client.widget.escalator.Cell;
  22. import com.vaadin.client.widget.escalator.ColumnConfiguration;
  23. import com.vaadin.client.widget.escalator.EscalatorUpdater;
  24. import com.vaadin.client.widget.escalator.RowContainer;
  25. import com.vaadin.client.widgets.Escalator;
  26. import com.vaadin.tests.widgetset.client.grid.EscalatorBasicClientFeaturesWidget.LogWidget;
  27. public class EscalatorProxy extends Escalator {
  28. private class ColumnConfigurationProxy implements ColumnConfiguration {
  29. private ColumnConfiguration columnConfiguration;
  30. public ColumnConfigurationProxy(ColumnConfiguration columnConfiguration) {
  31. this.columnConfiguration = columnConfiguration;
  32. }
  33. @Override
  34. public void removeColumns(int index, int numberOfColumns)
  35. throws IndexOutOfBoundsException, IllegalArgumentException {
  36. columnConfiguration.removeColumns(index, numberOfColumns);
  37. logWidget.log("removeColumns " + index + ", " + numberOfColumns);
  38. logWidget.updateDebugLabel();
  39. }
  40. @Override
  41. public void insertColumns(int index, int numberOfColumns)
  42. throws IndexOutOfBoundsException, IllegalArgumentException {
  43. columnConfiguration.insertColumns(index, numberOfColumns);
  44. logWidget.log("insertColumns " + index + ", " + numberOfColumns);
  45. logWidget.updateDebugLabel();
  46. }
  47. @Override
  48. public int getColumnCount() {
  49. return columnConfiguration.getColumnCount();
  50. }
  51. @Override
  52. public void setFrozenColumnCount(int count)
  53. throws IllegalArgumentException {
  54. columnConfiguration.setFrozenColumnCount(count);
  55. }
  56. @Override
  57. public int getFrozenColumnCount() {
  58. return columnConfiguration.getFrozenColumnCount();
  59. }
  60. @Override
  61. public void setColumnWidth(int index, double px)
  62. throws IllegalArgumentException {
  63. columnConfiguration.setColumnWidth(index, px);
  64. }
  65. @Override
  66. public double getColumnWidth(int index) throws IllegalArgumentException {
  67. return columnConfiguration.getColumnWidth(index);
  68. }
  69. @Override
  70. public double getColumnWidthActual(int index)
  71. throws IllegalArgumentException {
  72. return columnConfiguration.getColumnWidthActual(index);
  73. }
  74. @Override
  75. public void refreshColumns(int index, int numberOfColumns)
  76. throws IndexOutOfBoundsException, IllegalArgumentException {
  77. columnConfiguration.refreshColumns(index, numberOfColumns);
  78. }
  79. @Override
  80. public void setColumnWidths(Map<Integer, Double> indexWidthMap)
  81. throws IllegalArgumentException {
  82. columnConfiguration.setColumnWidths(indexWidthMap);
  83. }
  84. }
  85. private class RowContainerProxy implements RowContainer {
  86. private final RowContainer rowContainer;
  87. public RowContainerProxy(RowContainer rowContainer) {
  88. this.rowContainer = rowContainer;
  89. }
  90. @Override
  91. public EscalatorUpdater getEscalatorUpdater() {
  92. return rowContainer.getEscalatorUpdater();
  93. }
  94. @Override
  95. public void setEscalatorUpdater(EscalatorUpdater escalatorUpdater)
  96. throws IllegalArgumentException {
  97. rowContainer.setEscalatorUpdater(escalatorUpdater);
  98. }
  99. @Override
  100. public void removeRows(int index, int numberOfRows)
  101. throws IndexOutOfBoundsException, IllegalArgumentException {
  102. rowContainer.removeRows(index, numberOfRows);
  103. logWidget.log(rowContainer.getClass().getSimpleName()
  104. + " removeRows " + index + ", " + numberOfRows);
  105. logWidget.updateDebugLabel();
  106. }
  107. @Override
  108. public void insertRows(int index, int numberOfRows)
  109. throws IndexOutOfBoundsException, IllegalArgumentException {
  110. rowContainer.insertRows(index, numberOfRows);
  111. logWidget.log(rowContainer.getClass().getSimpleName()
  112. + " insertRows " + index + ", " + numberOfRows);
  113. logWidget.updateDebugLabel();
  114. }
  115. @Override
  116. public void refreshRows(int index, int numberOfRows)
  117. throws IndexOutOfBoundsException, IllegalArgumentException {
  118. rowContainer.refreshRows(index, numberOfRows);
  119. logWidget.log(rowContainer.getClass().getSimpleName()
  120. + " refreshRows " + index + ", " + numberOfRows);
  121. }
  122. @Override
  123. public int getRowCount() {
  124. return rowContainer.getRowCount();
  125. }
  126. @Override
  127. public void setDefaultRowHeight(double px)
  128. throws IllegalArgumentException {
  129. rowContainer.setDefaultRowHeight(px);
  130. }
  131. @Override
  132. public double getDefaultRowHeight() {
  133. return rowContainer.getDefaultRowHeight();
  134. }
  135. @Override
  136. public Cell getCell(Element element) {
  137. return rowContainer.getCell(element);
  138. }
  139. @Override
  140. public TableRowElement getRowElement(int index)
  141. throws IndexOutOfBoundsException, IllegalStateException {
  142. return rowContainer.getRowElement(index);
  143. }
  144. @Override
  145. public TableSectionElement getElement() {
  146. return rowContainer.getElement();
  147. }
  148. }
  149. private RowContainer headerProxy = null;
  150. private RowContainer bodyProxy = null;
  151. private RowContainer footerProxy = null;
  152. private ColumnConfiguration columnProxy = null;
  153. private LogWidget logWidget;
  154. @Override
  155. public RowContainer getHeader() {
  156. if (headerProxy == null) {
  157. headerProxy = new RowContainerProxy(super.getHeader());
  158. }
  159. return headerProxy;
  160. }
  161. @Override
  162. public RowContainer getFooter() {
  163. if (footerProxy == null) {
  164. footerProxy = new RowContainerProxy(super.getFooter());
  165. }
  166. return footerProxy;
  167. }
  168. @Override
  169. public RowContainer getBody() {
  170. if (bodyProxy == null) {
  171. bodyProxy = new RowContainerProxy(super.getBody());
  172. }
  173. return bodyProxy;
  174. }
  175. @Override
  176. public ColumnConfiguration getColumnConfiguration() {
  177. if (columnProxy == null) {
  178. columnProxy = new ColumnConfigurationProxy(
  179. super.getColumnConfiguration());
  180. }
  181. return columnProxy;
  182. }
  183. public void setLogWidget(LogWidget logWidget) {
  184. this.logWidget = logWidget;
  185. logWidget.updateDebugLabel();
  186. }
  187. @Override
  188. public void setScrollTop(double scrollTop) {
  189. logWidget.log("setScrollTop " + scrollTop);
  190. logWidget.updateDebugLabel();
  191. super.setScrollTop(scrollTop);
  192. }
  193. }