Ejemplo n.º 1
0
  protected void initSortMenu() {
    MenuBar menuBar = new MenuBar();
    menuBar.addStyleName(ExplorerLayout.STYLE_SEARCHBOX_SORTMENU);

    // TODO: Adding types of sorting manually and listener/events
    MenuItem rootItem = menuBar.addItem("Sort by", null);
    rootItem.addItem("Id", null);
    rootItem.addItem("Name", null);
    rootItem.addItem("Due date", null);
    rootItem.addItem("Creation date", null);

    layout.addComponent(menuBar);
    layout.setComponentAlignment(menuBar, Alignment.MIDDLE_RIGHT);
  }
Ejemplo n.º 2
0
  private void BuildSettings(String user) {
    Command cmd =
        new Command() {
          @Override
          public void menuSelected(MenuItem selectedItem) {
            Notification.show("Não implementado nesta versão.");
          }
        };

    MenuBar menubar = new MenuBar();
    MenuItem settingsMenu = menubar.addItem(user, new ThemeResource("img/profile-pic.png"), null);
    settingsMenu.addItem("Configurações", cmd);
    settingsMenu.addItem("Preferências", cmd);
    settingsMenu.addSeparator();
    settingsMenu.addItem("Minha conta", cmd);
    settingsMenu.addItem("Sair", cmd);

    settings.addComponent(menubar);
    settings.setMargin(true);
  }
Ejemplo n.º 3
0
  @Before
  public void setUp() {
    menuBar = new MenuBar();
    menuFile = menuBar.addItem("File", this);
    menuEdit = menuBar.addItem("Edit", this);
    menuEditCopy = menuEdit.addItem("Copy", this);
    menuEditCut = menuEdit.addItem("Cut", this);
    menuEditPaste = menuEdit.addItem("Paste", this);
    menuEdit.addSeparator();
    menuEditFind = menuEdit.addItem("Find...", this);
    menuFileOpen = menuFile.addItem("Open", this);
    menuFileSave = menuFile.addItem("Save", this);
    menuFile.addSeparator();
    menuFileExit = menuFile.addItem("Exit", this);

    menuItems.add(menuFile);
    menuItems.add(menuEdit);
    menuItems.add(menuEditCopy);
    menuItems.add(menuEditCut);
    menuItems.add(menuEditPaste);
    menuItems.add(menuEditFind);
    menuItems.add(menuFileOpen);
    menuItems.add(menuFileSave);
    menuItems.add(menuFileExit);
  }
Ejemplo n.º 4
0
  @Test
  public void testMenubarIdUniqueness() {
    // Ids within a menubar must be unique
    assertUniqueIds(menuBar);

    menuBar.removeItem(menuFile);
    MenuItem file2 = menuBar.addItem("File2", this);
    MenuItem file3 = menuBar.addItem("File3", this);
    MenuItem file2sub = file2.addItem("File2 sub menu", this);
    menuItems.add(file2);
    menuItems.add(file2sub);
    menuItems.add(file3);

    assertUniqueIds(menuBar);
  }
  @Override
  protected void setup() {
    Command c =
        new Command() {
          public void menuSelected(MenuItem selectedItem) {
            getMainWindow().showNotification(selectedItem.getText());
          }
        };

    MenuBar root = new MenuBar();

    MenuItem submenu = root.addItem("Hello", null);
    submenu.addItem("World", c);

    root.addItem("World", c);
    addComponent(root);
  }
Ejemplo n.º 6
0
  private Component createContentWrapper(final Component content) {
    final CssLayout slot = new CssLayout();
    slot.setWidth("100%");
    slot.addStyleName("dashboard-panel-slot");

    CssLayout card = new CssLayout();
    card.setWidth("100%");
    card.addStyleName(ValoTheme.LAYOUT_CARD);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("dashboard-panel-toolbar");
    toolbar.setWidth("100%");
    toolbar.setSpacing(false);

    Label caption = new Label(content.getCaption());
    caption.addStyleName(ValoTheme.LABEL_H4);
    caption.addStyleName(ValoTheme.LABEL_COLORED);
    caption.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    content.setCaption(null);

    MenuBar tools = new MenuBar();
    tools.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    MenuItem max =
        tools.addItem(
            "",
            FontAwesome.EXPAND,
            new Command() {

              @Override
              public void menuSelected(final MenuItem selectedItem) {
                if (!slot.getStyleName().contains("max")) {
                  selectedItem.setIcon(FontAwesome.COMPRESS);
                  toggleMaximized(slot, true);
                } else {
                  slot.removeStyleName("max");
                  selectedItem.setIcon(FontAwesome.EXPAND);
                  toggleMaximized(slot, false);
                }
              }
            });
    max.setStyleName("icon-only");
    MenuItem root = tools.addItem("", FontAwesome.COG, null);
    root.addItem(
        "Configure",
        new Command() {
          @Override
          public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
          }
        });
    root.addSeparator();
    root.addItem(
        "Close",
        new Command() {
          @Override
          public void menuSelected(final MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
          }
        });

    toolbar.addComponents(caption, tools);
    toolbar.setExpandRatio(caption, 1);
    toolbar.setComponentAlignment(caption, Alignment.MIDDLE_LEFT);

    card.addComponents(toolbar, content);
    slot.addComponent(card);
    return slot;
  }