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 4.8KB

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