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.

Notifications.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package com.vaadin.tests.components.notification;
  2. import com.vaadin.server.Page;
  3. import com.vaadin.tests.components.TestBase;
  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. import com.vaadin.v7.ui.NativeSelect;
  10. import com.vaadin.v7.ui.TextArea;
  11. public class Notifications extends TestBase implements ClickListener {
  12. private static final String CAPTION = "CAPTION";
  13. private TextArea tf;
  14. private NativeSelect type;
  15. @SuppressWarnings("deprecation")
  16. @Override
  17. protected void setup() {
  18. tf = new TextArea("Text", "Hello world");
  19. tf.setRows(10);
  20. addComponent(tf);
  21. type = new NativeSelect();
  22. type.setNullSelectionAllowed(false);
  23. type.addContainerProperty(CAPTION, String.class, "");
  24. type.setItemCaptionPropertyId(CAPTION);
  25. type.addItem(Notification.TYPE_HUMANIZED_MESSAGE)
  26. .getItemProperty(CAPTION).setValue("Humanized");
  27. type.addItem(Notification.TYPE_ERROR_MESSAGE).getItemProperty(CAPTION)
  28. .setValue("Error");
  29. type.addItem(Notification.TYPE_WARNING_MESSAGE).getItemProperty(CAPTION)
  30. .setValue("Warning");
  31. type.addItem(Notification.TYPE_TRAY_NOTIFICATION)
  32. .getItemProperty(CAPTION).setValue("Tray");
  33. type.setValue(type.getItemIds().iterator().next());
  34. addComponent(type);
  35. Button showNotification = new Button("Show notification", this);
  36. addComponent(showNotification);
  37. }
  38. @Override
  39. protected String getDescription() {
  40. return "Generic test case for notifications";
  41. }
  42. @Override
  43. protected Integer getTicketNumber() {
  44. // TODO Auto-generated method stub
  45. return null;
  46. }
  47. @Override
  48. public void buttonClick(ClickEvent event) {
  49. Notification n = new Notification(tf.getValue(),
  50. (Type) type.getValue());
  51. n.setHtmlContentAllowed(true);
  52. n.show(Page.getCurrent());
  53. }
  54. }