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.

TooltipTests.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.vaadin.tests.components.abstractcomponent;
  2. import com.vaadin.data.Property;
  3. import com.vaadin.data.Property.ValueChangeEvent;
  4. import com.vaadin.tests.components.TestBase;
  5. import com.vaadin.ui.CheckBox;
  6. import com.vaadin.ui.HorizontalLayout;
  7. import com.vaadin.ui.Label;
  8. import com.vaadin.ui.Panel;
  9. import com.vaadin.ui.VerticalLayout;
  10. public class TooltipTests extends TestBase {
  11. private Panel panel;
  12. private VerticalLayout layout;
  13. private Label label;
  14. @Override
  15. protected String getDescription() {
  16. return "Generic tooltip handling tests";
  17. }
  18. @Override
  19. protected Integer getTicketNumber() {
  20. return 8425;
  21. }
  22. @Override
  23. protected void setup() {
  24. HorizontalLayout topLayout = new HorizontalLayout();
  25. addComponent(topLayout);
  26. CheckBox panelCbox = new CheckBox("Panel");
  27. panelCbox.addListener(panelListener);
  28. topLayout.addComponent(panelCbox);
  29. CheckBox layoutCbox = new CheckBox("Layout");
  30. layoutCbox.addListener(layoutListener);
  31. topLayout.addComponent(layoutCbox);
  32. CheckBox labelCbox = new CheckBox("Label");
  33. topLayout.addComponent(labelCbox);
  34. labelCbox.addListener(labelListener);
  35. panel = new Panel();
  36. panel.setCaption("Panel caption");
  37. panel.setId("panel");
  38. addComponent(panel);
  39. layout = new VerticalLayout();
  40. layout.setId("layout");
  41. layout.setMargin(true);
  42. layout.setSpacing(true);
  43. panel.setContent(layout);
  44. label = new Label("Hover me!");
  45. label.setId("label");
  46. layout.addComponent(label);
  47. }
  48. private final Property.ValueChangeListener panelListener = new Property.ValueChangeListener() {
  49. @Override
  50. public void valueChange(ValueChangeEvent event) {
  51. boolean value = (Boolean) (event.getProperty().getValue());
  52. if (value) {
  53. panel.setDescription("I'm panel!");
  54. } else {
  55. panel.setDescription("");
  56. }
  57. }
  58. };
  59. private final Property.ValueChangeListener layoutListener = new Property.ValueChangeListener() {
  60. @Override
  61. public void valueChange(ValueChangeEvent event) {
  62. boolean value = (Boolean) (event.getProperty().getValue());
  63. if (value) {
  64. layout.setDescription("I'm layout!");
  65. } else {
  66. layout.setDescription("");
  67. }
  68. }
  69. };
  70. private final Property.ValueChangeListener labelListener = new Property.ValueChangeListener() {
  71. @Override
  72. public void valueChange(ValueChangeEvent event) {
  73. boolean value = (Boolean) (event.getProperty().getValue());
  74. if (value) {
  75. label.setDescription("I'm label!");
  76. } else {
  77. label.setDescription("");
  78. }
  79. }
  80. };
  81. }