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.

LayoutDetectorConnector.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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;
  17. import com.google.gwt.user.client.ui.HTML;
  18. import com.vaadin.client.ui.AbstractComponentConnector;
  19. import com.vaadin.client.ui.PostLayoutListener;
  20. import com.vaadin.shared.ui.Connect;
  21. import com.vaadin.tests.widgetset.server.LayoutDetector;
  22. @Connect(LayoutDetector.class)
  23. public class LayoutDetectorConnector extends AbstractComponentConnector
  24. implements PostLayoutListener {
  25. private int layoutCount = 0;
  26. private int rpcCount = 0;
  27. @Override
  28. protected void init() {
  29. super.init();
  30. updateText();
  31. registerRpc(NoLayoutRpc.class, new NoLayoutRpc() {
  32. @Override
  33. public void doRpc() {
  34. rpcCount++;
  35. updateText();
  36. }
  37. });
  38. }
  39. @Override
  40. public HTML getWidget() {
  41. return (HTML) super.getWidget();
  42. }
  43. @Override
  44. public void postLayout() {
  45. layoutCount++;
  46. updateText();
  47. }
  48. private void updateText() {
  49. getWidget().setHTML(
  50. "Layout count: <span id='layoutCount'>" + layoutCount
  51. + "</span><br />RPC count: <span id='rpcCount'>"
  52. + rpcCount + "</span>");
  53. }
  54. }