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

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