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.

GridAddReplaceMove.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright 2000-2014 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.layouts.layouttester.GridLayout;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.shared.ui.label.ContentMode;
  19. import com.vaadin.ui.AbstractComponent;
  20. import com.vaadin.ui.Button;
  21. import com.vaadin.ui.Button.ClickEvent;
  22. import com.vaadin.ui.Button.ClickListener;
  23. import com.vaadin.ui.HorizontalLayout;
  24. import com.vaadin.ui.Label;
  25. import com.vaadin.ui.Table;
  26. import com.vaadin.ui.TextField;
  27. /**
  28. *
  29. * @since
  30. * @author Vaadin Ltd
  31. */
  32. public class GridAddReplaceMove extends GridBaseLayoutTestUI {
  33. /*
  34. * (non-Javadoc)
  35. *
  36. * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
  37. * VaadinRequest)
  38. */
  39. @Override
  40. protected void setup(VaadinRequest request) {
  41. buildLayout();
  42. super.setup(request);
  43. }
  44. private void buildLayout() {
  45. final HorizontalLayout source = new HorizontalLayout();
  46. source.addComponent(new Label("OTHER LABEL 1"));
  47. source.addComponent(new Label("OTHER LABEL 2"));
  48. final AbstractComponent c1 = new Label("<b>LABEL</b>", ContentMode.HTML);
  49. final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML);
  50. final AbstractComponent c3 = new Table("TABLE");
  51. c3.setHeight("100px");
  52. c3.setWidth("100%");
  53. final Button btnAdd = new Button("Test add");
  54. final Button btnReplace = new Button("Test replace");
  55. final Button btnMove = new Button("Test move");
  56. final Button btnRemove = new Button("Test remove");
  57. layout.addComponent(btnAdd);
  58. layout.addComponent(btnReplace);
  59. layout.addComponent(btnMove);
  60. layout.addComponent(btnRemove);
  61. btnAdd.addClickListener(new ClickListener() {
  62. @Override
  63. public void buttonClick(ClickEvent event) {
  64. layout.addComponent(new TextField());
  65. }
  66. });
  67. btnReplace.addClickListener(new ClickListener() {
  68. @Override
  69. public void buttonClick(ClickEvent event) {
  70. layout.replaceComponent(c1, c3);
  71. }
  72. });
  73. btnMove.addClickListener(new ClickListener() {
  74. @Override
  75. public void buttonClick(ClickEvent event) {
  76. layout.moveComponentsFrom(source);
  77. }
  78. });
  79. btnRemove.addClickListener(new ClickListener() {
  80. @Override
  81. public void buttonClick(ClickEvent event) {
  82. layout.removeComponent(c1);
  83. layout.removeComponent(c2);
  84. }
  85. });
  86. layout.addComponent(c1);
  87. layout.addComponent(c2);
  88. layout.addComponent(c3);
  89. }
  90. }