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.

TestTooSmallSubwindowSize.java 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package com.vaadin.tests.components.window;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractTestUI;
  4. import com.vaadin.ui.Label;
  5. import com.vaadin.ui.VerticalLayout;
  6. import com.vaadin.ui.Window;
  7. /**
  8. * Tests that the styles work correctly in tiny subwindows that have more
  9. * content than can fit.
  10. *
  11. * @author Vaadin Ltd
  12. */
  13. public class TestTooSmallSubwindowSize extends AbstractTestUI {
  14. @Override
  15. protected String getTestDescription() {
  16. return "The size of the subwindows (outer size) is set to 60x60 pixels. Make sure the shadows fits the windows instead of the contents. The decorations at the lower right corners of the resizable windows must not be missing either.";
  17. }
  18. @Override
  19. protected Integer getTicketNumber() {
  20. return 2579;
  21. }
  22. @Override
  23. protected void setup(VaadinRequest request) {
  24. getUI().addWindow(createNonResizableWindow());
  25. getUI().addWindow(createNonResizableWindowWithHorizontalScrollbar());
  26. getUI().addWindow(createResizableWindow());
  27. getUI().addWindow(createResizableWindowWithHorizontalScrollbar());
  28. }
  29. private Window createNonResizableWindow() {
  30. VerticalLayout layout = new VerticalLayout();
  31. layout.setMargin(true);
  32. Window w = new Window("Scroll", layout);
  33. Label desc = new Label(
  34. "This is a new child window with a preset"
  35. + " width, height and position. Resizing has been"
  36. + " disabled for this window. Additionally, this text label"
  37. + " is intentionally too large to fit the window. You can"
  38. + " use the scrollbars to view different parts of the window content.");
  39. layout.addComponent(desc);
  40. // Set window position
  41. w.setPositionX(100);
  42. w.setPositionY(100);
  43. // Set window size
  44. w.setWidth(60, Unit.PIXELS);
  45. w.setHeight(60, Unit.PIXELS);
  46. // Disable resizing
  47. w.setResizable(false);
  48. return w;
  49. }
  50. private Window createNonResizableWindowWithHorizontalScrollbar() {
  51. VerticalLayout layout = new VerticalLayout();
  52. layout.setMargin(true);
  53. Window w = new Window("Scroll", layout);
  54. Label desc = new Label(
  55. "This is a new child window with a preset"
  56. + " width, height and position. Resizing has been"
  57. + " disabled for this window. Additionally, this text label"
  58. + " is intentionally too large to fit the window. You could"
  59. + " use the scrollbars to view different parts of the window content,"
  60. + " except it's too small for that either.");
  61. // disable wrapping
  62. desc.setSizeUndefined();
  63. layout.addComponent(desc);
  64. // Set window position
  65. w.setPositionX(200);
  66. w.setPositionY(100);
  67. // Set window size
  68. w.setWidth(60, Unit.PIXELS);
  69. w.setHeight(60, Unit.PIXELS);
  70. // Disable resizing
  71. w.setResizable(false);
  72. return w;
  73. }
  74. private Window createResizableWindow() {
  75. VerticalLayout layout = new VerticalLayout();
  76. layout.setMargin(true);
  77. Window w = new Window("Resize", layout);
  78. Label desc = new Label(
  79. "This is a new child window with a preset"
  80. + " width, height and position. Resizing has not been"
  81. + " disabled for this window. Additionally, this text label"
  82. + " is intentionally too large to fit the window. You can resize or"
  83. + " use the scrollbars to view different parts of the window content.");
  84. layout.addComponent(desc);
  85. // Set window position
  86. w.setPositionX(300);
  87. w.setPositionY(100);
  88. // Set window size
  89. w.setWidth(60, Unit.PIXELS);
  90. w.setHeight(60, Unit.PIXELS);
  91. // Don't disable resizing
  92. return w;
  93. }
  94. private Window createResizableWindowWithHorizontalScrollbar() {
  95. VerticalLayout layout = new VerticalLayout();
  96. layout.setMargin(true);
  97. Window w = new Window("Resize", layout);
  98. Label desc = new Label(
  99. "This is a new child window with a preset"
  100. + " width, height and position. Resizing has not been"
  101. + " disabled for this window. Additionally, this text label"
  102. + " is intentionally too large to fit the window. You can resize"
  103. + " to view different parts of the window content.");
  104. // disable wrapping
  105. desc.setSizeUndefined();
  106. layout.addComponent(desc);
  107. // Set window position
  108. w.setPositionX(400);
  109. w.setPositionY(100);
  110. // Set window size
  111. w.setWidth(60, Unit.PIXELS);
  112. w.setHeight(60, Unit.PIXELS);
  113. // Don't disable resizing
  114. return w;
  115. }
  116. }