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.5KB

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