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.

LayoutDuringStateUpdateConnector.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.vaadin.tests.widgetset.client;
  2. import com.google.gwt.user.client.ui.Label;
  3. import com.vaadin.client.communication.StateChangeEvent;
  4. import com.vaadin.client.ui.AbstractComponentConnector;
  5. import com.vaadin.client.ui.PostLayoutListener;
  6. import com.vaadin.shared.ui.Connect;
  7. import com.vaadin.tests.widgetset.server.LayoutDuringStateUpdateComponent;
  8. @Connect(LayoutDuringStateUpdateComponent.class)
  9. public class LayoutDuringStateUpdateConnector extends AbstractComponentConnector
  10. implements PostLayoutListener {
  11. private int layoutCount = 0;
  12. @Override
  13. protected void init() {
  14. super.init();
  15. updateLabelText();
  16. }
  17. @Override
  18. public Label getWidget() {
  19. return (Label) super.getWidget();
  20. }
  21. @Override
  22. public void onStateChanged(StateChangeEvent stateChangeEvent) {
  23. super.onStateChanged(stateChangeEvent);
  24. try {
  25. getLayoutManager().layoutNow();
  26. } catch (AssertionError e) {
  27. // Ignore
  28. }
  29. }
  30. private void updateLabelText() {
  31. getWidget().setText("Layout phase count: " + layoutCount);
  32. }
  33. @Override
  34. public void postLayout() {
  35. layoutCount++;
  36. updateLabelText();
  37. }
  38. }