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.

PopupViewOffScreen.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package com.vaadin.tests.components.popupview;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import com.vaadin.shared.ui.ContentMode;
  5. import com.vaadin.tests.components.TestBase;
  6. import com.vaadin.tests.util.LoremIpsum;
  7. import com.vaadin.ui.Button;
  8. import com.vaadin.ui.Button.ClickEvent;
  9. import com.vaadin.ui.Button.ClickListener;
  10. import com.vaadin.ui.Component;
  11. import com.vaadin.ui.GridLayout;
  12. import com.vaadin.ui.Label;
  13. import com.vaadin.ui.Panel;
  14. import com.vaadin.ui.PopupView;
  15. import com.vaadin.ui.VerticalLayout;
  16. import com.vaadin.v7.ui.themes.BaseTheme;
  17. public class PopupViewOffScreen extends TestBase {
  18. private List<PopupView> popupViews = new ArrayList<>();
  19. @Override
  20. protected String getDescription() {
  21. return "A popupview should be displayed on screen. If the popup position is close to a border it should be moved so it is still on screen.";
  22. }
  23. @Override
  24. protected Integer getTicketNumber() {
  25. return 3099;
  26. }
  27. @Override
  28. protected void setup() {
  29. GridLayout gl = new GridLayout(3, 3);
  30. gl.setSizeFull();
  31. Label expander = new Label();
  32. gl.addComponent(expander, 1, 1);
  33. gl.setColumnExpandRatio(1, 1);
  34. gl.setRowExpandRatio(1, 1);
  35. Button showall = new Button("Popup all", new ClickListener() {
  36. @Override
  37. public void buttonClick(ClickEvent event) {
  38. for (PopupView pv : popupViews) {
  39. pv.setPopupVisible(true);
  40. }
  41. }
  42. });
  43. gl.addComponent(showall, 1, 0);
  44. gl.addComponent(createPopupView("red"), 0, 0);
  45. gl.addComponent(createPopupView("green"), 2, 0);
  46. gl.addComponent(createPopupView("blue"), 0, 2);
  47. gl.addComponent(createPopupView("yellow"), 2, 2);
  48. addComponent(gl);
  49. gl.getParent().setSizeFull();
  50. }
  51. private Component createPopupView(String bg) {
  52. VerticalLayout vl = new VerticalLayout();
  53. vl.setSpacing(false);
  54. vl.setMargin(false);
  55. vl.setSizeFull();
  56. vl.addStyleName(BaseTheme.CLIP);
  57. Panel p = new Panel(vl);
  58. p.setWidth("400px");
  59. p.setHeight("400px");
  60. Label l = new Label(
  61. "<div style='width: 100%; height: 100%; background: " + bg
  62. + "'>" + LoremIpsum.get(2000) + "</div>",
  63. ContentMode.HTML);
  64. l.setSizeFull();
  65. vl.addComponent(l);
  66. PopupView pv = new PopupView("Click here to popup", p);
  67. popupViews.add(pv);
  68. return pv;
  69. }
  70. }