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.

MenuBarUI.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.vaadin.tests.elements.menubar;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.shared.ui.ContentMode;
  4. import com.vaadin.tests.components.AbstractTestUI;
  5. import com.vaadin.ui.MenuBar;
  6. import com.vaadin.ui.MenuBar.Command;
  7. import com.vaadin.ui.MenuBar.MenuItem;
  8. @SuppressWarnings("serial")
  9. public class MenuBarUI extends AbstractTestUI {
  10. @Override
  11. protected void setup(VaadinRequest request) {
  12. addComponent(createDefaultMenuBar("", ""));
  13. addComponent(createDefaultMenuBar("2", ""));
  14. addComponent(createDefaultMenuBar("", "2"));
  15. }
  16. private MenuBar createDefaultMenuBar(String topLevelItemSuffix,
  17. String secondaryLevelItemSuffix) {
  18. MenuBar menuBar = new MenuBar();
  19. MenuItem file = menuBar.addItem("File" + topLevelItemSuffix, null);
  20. file.addItem("Open" + secondaryLevelItemSuffix, new MenuBarCommand())
  21. .setDescription("<b>Preformatted</b>\ndescription");
  22. file.addItem("Save" + secondaryLevelItemSuffix, new MenuBarCommand())
  23. .setDescription("plain description,\n <b>HTML</b> is visible",
  24. ContentMode.TEXT);
  25. file.addItem("Save As.." + secondaryLevelItemSuffix,
  26. new MenuBarCommand());
  27. file.addSeparator();
  28. MenuItem export = file.addItem("Export.." + secondaryLevelItemSuffix,
  29. null);
  30. export.addItem("As PDF..." + secondaryLevelItemSuffix,
  31. new MenuBarCommand());
  32. export.addItem("As Doc..." + secondaryLevelItemSuffix,
  33. new MenuBarCommand());
  34. file.addSeparator();
  35. file.addItem("Exit" + secondaryLevelItemSuffix, new MenuBarCommand())
  36. .setDescription("<b>HTML</b><br/>description",
  37. ContentMode.HTML);
  38. MenuItem edit = menuBar.addItem("Edit" + topLevelItemSuffix, null);
  39. edit.addItem("Copy" + secondaryLevelItemSuffix, new MenuBarCommand());
  40. edit.addItem("Cut" + secondaryLevelItemSuffix, new MenuBarCommand());
  41. edit.addItem("Paste" + secondaryLevelItemSuffix, new MenuBarCommand());
  42. menuBar.addItem("Help" + topLevelItemSuffix, new MenuBarCommand());
  43. return menuBar;
  44. }
  45. @Override
  46. protected String getTestDescription() {
  47. return "UI used to validate MenuBarElement API";
  48. }
  49. @Override
  50. protected Integer getTicketNumber() {
  51. return 13364;
  52. }
  53. private class MenuBarCommand implements Command {
  54. @Override
  55. public void menuSelected(MenuItem selectedItem) {
  56. }
  57. }
  58. }