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.

NoLayout.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.tests.serialization;
  17. import com.vaadin.annotations.Widgetset;
  18. import com.vaadin.server.VaadinRequest;
  19. import com.vaadin.tests.components.AbstractReindeerTestUI;
  20. import com.vaadin.tests.widgetset.TestingWidgetSet;
  21. import com.vaadin.tests.widgetset.server.LayoutDetector;
  22. import com.vaadin.ui.Button;
  23. import com.vaadin.ui.Button.ClickEvent;
  24. import com.vaadin.ui.CheckBox;
  25. import com.vaadin.ui.JavaScript;
  26. @Widgetset(TestingWidgetSet.NAME)
  27. public class NoLayout extends AbstractReindeerTestUI {
  28. private final LayoutDetector layoutDetector = new LayoutDetector();
  29. @Override
  30. protected void setup(VaadinRequest request) {
  31. addComponent(layoutDetector);
  32. CheckBox uiPolling = new CheckBox("UI polling enabled");
  33. uiPolling.addValueChangeListener(event -> {
  34. if (event.getValue()) {
  35. setPollInterval(100);
  36. } else {
  37. setPollInterval(-1);
  38. }
  39. });
  40. addComponent(uiPolling);
  41. addComponent(
  42. new Button("Change regular state", new Button.ClickListener() {
  43. @Override
  44. public void buttonClick(ClickEvent event) {
  45. event.getButton().setCaption(
  46. String.valueOf(System.currentTimeMillis()));
  47. }
  48. }));
  49. addComponent(new Button("Change @NoLayout state",
  50. new Button.ClickListener() {
  51. @Override
  52. public void buttonClick(ClickEvent event) {
  53. event.getButton().setDescription(
  54. String.valueOf(System.currentTimeMillis()));
  55. }
  56. }));
  57. addComponent(new Button("Do regular RPC", new Button.ClickListener() {
  58. @Override
  59. public void buttonClick(ClickEvent event) {
  60. JavaScript.eval("");
  61. }
  62. }));
  63. addComponent(new Button("Do @NoLayout RPC", new Button.ClickListener() {
  64. @Override
  65. public void buttonClick(ClickEvent event) {
  66. layoutDetector.doNoLayoutRpc();
  67. }
  68. }));
  69. addComponent(new Button("Update LegacyComponent",
  70. new Button.ClickListener() {
  71. @Override
  72. public void buttonClick(ClickEvent event) {
  73. // Assumes UI is a LegacyComponent
  74. markAsDirty();
  75. }
  76. }));
  77. }
  78. @Override
  79. protected String getTestDescription() {
  80. return "Checks which actions trigger a layout phase";
  81. }
  82. @Override
  83. protected Integer getTicketNumber() {
  84. return Integer.valueOf(12936);
  85. }
  86. }