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.

AbsoluteLayoutHideComponent.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package com.vaadin.tests.components.absolutelayout;
  2. import com.vaadin.server.ThemeResource;
  3. import com.vaadin.server.VaadinRequest;
  4. import com.vaadin.tests.components.AbstractReindeerTestUI;
  5. import com.vaadin.ui.AbsoluteLayout;
  6. import com.vaadin.ui.Alignment;
  7. import com.vaadin.ui.Button;
  8. import com.vaadin.ui.Embedded;
  9. import com.vaadin.ui.GridLayout;
  10. import com.vaadin.ui.HorizontalLayout;
  11. import com.vaadin.ui.Label;
  12. import com.vaadin.ui.VerticalLayout;
  13. import com.vaadin.v7.ui.PasswordField;
  14. import com.vaadin.v7.ui.TextField;
  15. public class AbsoluteLayoutHideComponent extends AbstractReindeerTestUI {
  16. private AbsoluteLayout mainLayout;
  17. private VerticalLayout topBar = new VerticalLayout();
  18. private GridLayout menu;
  19. private TextField editEmail = new TextField();
  20. private PasswordField editPassword = new PasswordField();
  21. @Override
  22. protected void setup(VaadinRequest request) {
  23. mainLayout = new AbsoluteLayout();
  24. mainLayout.setWidth("100%");
  25. mainLayout.setHeight("100%");
  26. topBar.setHeight("50px");
  27. topBar.setWidth("100%");
  28. HorizontalLayout layoutLogin = new HorizontalLayout();
  29. layoutLogin.setSpacing(true);
  30. layoutLogin.setHeight("100%");
  31. Label label_eMail = new Label("e-Mail:");
  32. layoutLogin.addComponent(label_eMail);
  33. editEmail.setWidth("200px");
  34. editEmail.setTabIndex(1);
  35. layoutLogin.addComponent(editEmail);
  36. layoutLogin.addComponent(new Label(" "));
  37. layoutLogin.addComponent(new Label(" "));
  38. Label label_password = new Label("password:");
  39. layoutLogin.addComponent(label_password);
  40. editPassword.setWidth("100px");
  41. editPassword.setTabIndex(2);
  42. layoutLogin.addComponent(editPassword);
  43. layoutLogin.addComponent(new Label(" "));
  44. // btnLogin
  45. Button btnLogin = new Button();
  46. btnLogin.setCaption("Login");
  47. btnLogin.setWidth("-1px");
  48. btnLogin.setHeight("-1px");
  49. btnLogin.addClickListener(event -> login());
  50. layoutLogin.addComponent(btnLogin);
  51. for (int index = 0; index < layoutLogin.getComponentCount(); index++) {
  52. layoutLogin.setComponentAlignment(layoutLogin.getComponent(index),
  53. Alignment.MIDDLE_CENTER);
  54. }
  55. // =====> THIS CODE generates error
  56. // WITHOUT THIS CODE works fine
  57. Embedded e = new Embedded("",
  58. new ThemeResource("../runo/icons/64/ok.png"));
  59. // e.setMimeType("image/jpg");
  60. e.setWidth("100%");
  61. e.setHeight("100%");
  62. mainLayout.addComponent(e);
  63. // =======
  64. topBar.addComponent(layoutLogin);
  65. mainLayout.addComponent(topBar, "left:0px;top:0px;");
  66. menu = buildMenu();
  67. menu.setVisible(false);
  68. mainLayout.addComponent(menu, "left:20px;top:70px;");
  69. setContent(mainLayout);
  70. }
  71. private GridLayout buildMenu() {
  72. GridLayout gridButtons = new GridLayout(2, 3);
  73. Button btn1 = new Button("Button one");
  74. btn1.addClickListener(event -> {
  75. });
  76. gridButtons.addComponent(btn1, 0, 0);
  77. Button btn2 = new Button("Button two");
  78. btn2.addClickListener(event -> {
  79. });
  80. gridButtons.addComponent(btn2, 0, 1);
  81. Button btn3 = new Button("Button three");
  82. btn3.addClickListener(event -> {
  83. });
  84. gridButtons.addComponent(btn3, 1, 0);
  85. return gridButtons;
  86. }
  87. private void login() {
  88. menu.setVisible(true);
  89. topBar.setVisible(false);
  90. }
  91. @Override
  92. protected String getTestDescription() {
  93. return "Clicking on the button should hide the fields and the button but leave the image";
  94. }
  95. @Override
  96. protected Integer getTicketNumber() {
  97. return 10155;
  98. }
  99. }