Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

RpcDataSourceConnector.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2000-2013 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.data;
  17. import java.util.List;
  18. import com.vaadin.client.ServerConnector;
  19. import com.vaadin.client.extensions.AbstractExtensionConnector;
  20. import com.vaadin.client.ui.grid.GridConnector;
  21. import com.vaadin.shared.data.DataProviderRpc;
  22. import com.vaadin.shared.data.DataProviderState;
  23. import com.vaadin.shared.data.DataRequestRpc;
  24. import com.vaadin.shared.ui.Connect;
  25. /**
  26. * Connects a Vaadin server-side container data source to a Grid. This is
  27. * currently implemented as an Extension hardcoded to support a specific
  28. * connector type. This will be changed once framework support for something
  29. * more flexible has been implemented.
  30. *
  31. * @since 7.2
  32. * @author Vaadin Ltd
  33. */
  34. @Connect(com.vaadin.data.RpcDataProviderExtension.class)
  35. public class RpcDataSourceConnector extends AbstractExtensionConnector {
  36. private final AbstractRemoteDataSource<String[]> dataSource = new AbstractRemoteDataSource<String[]>() {
  37. @Override
  38. protected void requestRows(int firstRowIndex, int numberOfRows) {
  39. getRpcProxy(DataRequestRpc.class).requestRows(firstRowIndex,
  40. numberOfRows);
  41. }
  42. };
  43. @Override
  44. protected void extend(ServerConnector target) {
  45. dataSource.setEstimatedSize(getState().containerSize);
  46. ((GridConnector) target).getWidget().setDataSource(dataSource);
  47. registerRpc(DataProviderRpc.class, new DataProviderRpc() {
  48. @Override
  49. public void setRowData(int firstRow, List<String[]> rows) {
  50. dataSource.setRowData(firstRow, rows);
  51. }
  52. });
  53. }
  54. /*
  55. * (non-Javadoc)
  56. *
  57. * @see com.vaadin.client.ui.AbstractConnector#getState()
  58. */
  59. @Override
  60. public DataProviderState getState() {
  61. return (DataProviderState) super.getState();
  62. }
  63. }