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.

NotificationGetTypeAndDescription.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.vaadin.tests.elements.notification;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractTestUI;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.Button.ClickEvent;
  6. import com.vaadin.ui.Button.ClickListener;
  7. import com.vaadin.ui.Notification;
  8. import com.vaadin.ui.Notification.Type;
  9. public class NotificationGetTypeAndDescription extends AbstractTestUI {
  10. private final static Type[] types = { Type.WARNING_MESSAGE,
  11. Type.ERROR_MESSAGE, Type.HUMANIZED_MESSAGE,
  12. Type.TRAY_NOTIFICATION };
  13. public final static String[] type_names = { "warning", "error", "humanized",
  14. "tray_notification" };
  15. public final static String[] captions = { "warningC", "errorC",
  16. "humanizedC", "tray_notificationC" };
  17. public final static String[] descriptions = { "warning", "error",
  18. "humanized", "tray_notification" };
  19. @Override
  20. protected void setup(VaadinRequest request) {
  21. for (int i = 0; i < types.length; i++) {
  22. Button btn = new Button();
  23. btn.setId("button" + i);
  24. btn.setCaption(type_names[i]);
  25. btn.addClickListener(new CounterClickListener(i));
  26. addComponent(btn);
  27. }
  28. // add extra button which shows Notification only with caption #14356
  29. Button btn = new Button("Show notification");
  30. btn.setId("showid");
  31. btn.addClickListener(new ClickListener() {
  32. @Override
  33. public void buttonClick(ClickEvent event) {
  34. Notification.show("test");
  35. }
  36. });
  37. addComponent(btn);
  38. }
  39. @Override
  40. protected String getTestDescription() {
  41. return "Test getType and getDescription methods of NotificationElement";
  42. }
  43. @Override
  44. protected Integer getTicketNumber() {
  45. return 13768;
  46. }
  47. private class CounterClickListener implements ClickListener {
  48. int index;
  49. public CounterClickListener(int i) {
  50. index = i;
  51. }
  52. @Override
  53. public void buttonClick(ClickEvent event) {
  54. Notification.show(captions[index], descriptions[index],
  55. types[index]);
  56. }
  57. }
  58. }