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.

PanelChangeContents.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2000-2018 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.panel;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.tests.components.AbstractTestUI;
  19. import com.vaadin.ui.Button;
  20. import com.vaadin.ui.Button.ClickEvent;
  21. import com.vaadin.ui.Button.ClickListener;
  22. import com.vaadin.ui.HorizontalLayout;
  23. import com.vaadin.ui.Label;
  24. import com.vaadin.ui.Panel;
  25. import com.vaadin.ui.VerticalLayout;
  26. public class PanelChangeContents extends AbstractTestUI
  27. implements ClickListener {
  28. VerticalLayout stats = new VerticalLayout();
  29. VerticalLayout companies = new VerticalLayout();
  30. VerticalLayout settings = new VerticalLayout();
  31. Button statsButton = new Button("Stats", this);
  32. Button companiesButton = new Button("Companies", this);
  33. Button settingsButton = new Button("Settings", this);
  34. private Panel panel;
  35. @Override
  36. protected void setup(VaadinRequest request) {
  37. VerticalLayout content = new VerticalLayout();
  38. setSizeFull();
  39. HorizontalLayout buttons = new HorizontalLayout();
  40. stats.addComponent(new Label("stats"));
  41. companies.addComponent(new Label("companies"));
  42. settings.addComponent(new Label("settings"));
  43. buttons.addComponent(statsButton);
  44. buttons.addComponent(companiesButton);
  45. buttons.addComponent(settingsButton);
  46. panel = new Panel();
  47. panel.setCaption("<div class=\"caption-with-html\">Caption</div>");
  48. panel.setSizeFull();
  49. panel.setContent(stats);
  50. content.addComponent(buttons);
  51. content.addComponent(panel);
  52. content.setMargin(true);
  53. content.setSpacing(true);
  54. content.setExpandRatio(panel, 1);
  55. setContent(content);
  56. }
  57. @Override
  58. public void buttonClick(ClickEvent event) {
  59. if (event.getButton() == statsButton) {
  60. panel.setContent(stats);
  61. } else if (event.getButton() == companiesButton) {
  62. panel.setContent(companies);
  63. } else if (event.getButton() == settingsButton) {
  64. panel.setContent(settings);
  65. }
  66. }
  67. @Override
  68. protected String getTestDescription() {
  69. // TODO Auto-generated method stub
  70. return null;
  71. }
  72. @Override
  73. protected Integer getTicketNumber() {
  74. return 8735;
  75. }
  76. }