Search in sources :

Example 6 with ContextMenu

use of com.vaadin.flow.component.contextmenu.ContextMenu in project psip-automation by bssw-psip.

the class AppBar method initAvatar.

private void initAvatar() {
    avatar = new Image();
    avatar.setClassName(CLASS_NAME + "__avatar");
    avatar.setSrc(IMG_PATH + "avatar.png");
    avatar.setAlt("User menu");
    ContextMenu contextMenu = new ContextMenu(avatar);
    contextMenu.setOpenOnClick(true);
    contextMenu.addItem("Settings", e -> Notification.show("Not implemented yet.", 3000, Notification.Position.BOTTOM_CENTER));
    contextMenu.addItem("Log Out", e -> Notification.show("Not implemented yet.", 3000, Notification.Position.BOTTOM_CENTER));
}
Also used : ContextMenu(com.vaadin.flow.component.contextmenu.ContextMenu) Image(com.vaadin.flow.component.html.Image)

Example 7 with ContextMenu

use of com.vaadin.flow.component.contextmenu.ContextMenu in project TJ-Bot by Together-Java.

the class MainLayout method createFooter.

private Footer createFooter() {
    Footer layout = new Footer();
    layout.addClassNames("flex", "items-center", "my-s", "px-m", "py-xs");
    Users user = this.authenticatedUser.get();
    Avatar avatar = new Avatar(user.getUsername());
    avatar.addClassNames("me-xs");
    ContextMenu userMenu = new ContextMenu(avatar);
    userMenu.setOpenOnClick(true);
    userMenu.addItem("Logout", e -> authenticatedUser.logout());
    Span name = new Span(user.getUsername());
    name.addClassNames("font-medium", "text-s", "text-secondary");
    layout.add(avatar, name);
    return layout;
}
Also used : ContextMenu(com.vaadin.flow.component.contextmenu.ContextMenu) Users(org.togetherjava.tjbot.db.generated.tables.pojos.Users) Avatar(com.vaadin.flow.component.avatar.Avatar)

Example 8 with ContextMenu

use of com.vaadin.flow.component.contextmenu.ContextMenu in project DoodleVerse by davidemarcoli.

the class MainLayout method createFooter.

private Footer createFooter() {
    Footer layout = new Footer();
    layout.addClassNames("footer");
    Optional<User> maybeUser = authenticatedUser.get();
    if (maybeUser.isPresent()) {
        User user = maybeUser.get();
        Avatar avatar = new Avatar(user.getName(), user.getProfilePictureUrl());
        avatar.addClassNames("me-xs");
        ContextMenu userMenu = new ContextMenu(avatar);
        userMenu.setOpenOnClick(true);
        userMenu.addItem("Logout", e -> {
            authenticatedUser.logout();
        });
        Span name = new Span(user.getName());
        name.addClassNames("font-medium", "text-s", "text-secondary");
        layout.add(avatar, name);
    } else {
        Anchor loginLink = new Anchor("login", "Sign in");
        layout.add(loginLink);
    }
    return layout;
}
Also used : AuthenticatedUser(com.dala.security.AuthenticatedUser) User(com.dala.data.user.User) ContextMenu(com.vaadin.flow.component.contextmenu.ContextMenu) Avatar(com.vaadin.flow.component.avatar.Avatar)

Example 9 with ContextMenu

use of com.vaadin.flow.component.contextmenu.ContextMenu in project flow-components by vaadin.

the class ContextMenuPage method addContextMenuWithCheckableItem.

private void addContextMenuWithCheckableItem() {
    Paragraph target = new Paragraph("Target for context menu with checkable item");
    target.setId("context-menu-checkable-item-target");
    Paragraph message = new Paragraph();
    message.setId("checked-message");
    ContextMenu contextMenu = new ContextMenu();
    contextMenu.setTarget(target);
    MenuItem item = contextMenu.addItem("checkable", event -> message.setText("" + event.getSource().isChecked()));
    NativeButton toggleCheckable = new NativeButton("Toggle checkable", event -> item.setCheckable(!item.isCheckable()));
    toggleCheckable.setId("toggle-checkable");
    MenuItem initiallyChecked = contextMenu.addItem("initially checked");
    initiallyChecked.setCheckable(true);
    initiallyChecked.setChecked(true);
    add(target, message, toggleCheckable);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) ContextMenu(com.vaadin.flow.component.contextmenu.ContextMenu) MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) Paragraph(com.vaadin.flow.component.html.Paragraph)

Example 10 with ContextMenu

use of com.vaadin.flow.component.contextmenu.ContextMenu in project flow-components by vaadin.

the class ContextMenuPage method createContextMenuAndAddComponentAtIndex.

private void createContextMenuAndAddComponentAtIndex() {
    Label target = new Label("Target for context menu with opened change listener");
    target.setId("context-menu-add-component-target");
    ContextMenu contextMenu = new ContextMenu();
    contextMenu.setTarget(target);
    contextMenu.setId("menu-add-component-at-index");
    contextMenu.add(new NativeButton(), new NativeButton(), new NativeButton());
    NativeButton addedButton = new NativeButton("Added Button");
    addedButton.setId("added-button");
    NativeButton addFirst = new NativeButton("Add to the first", event -> {
        contextMenu.addComponentAsFirst(addedButton);
    });
    addFirst.setId("button-to-first");
    NativeButton addAtSecond = createTestButton(contextMenu, addedButton, "button-to-second", 1);
    add(target, addFirst, addAtSecond);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Label(com.vaadin.flow.component.html.Label) ContextMenu(com.vaadin.flow.component.contextmenu.ContextMenu)

Aggregations

ContextMenu (com.vaadin.flow.component.contextmenu.ContextMenu)15 Label (com.vaadin.flow.component.html.Label)10 Component (com.vaadin.flow.component.Component)5 MenuItem (com.vaadin.flow.component.contextmenu.MenuItem)5 Div (com.vaadin.flow.component.html.Div)3 NativeButton (com.vaadin.flow.component.html.NativeButton)3 Paragraph (com.vaadin.flow.component.html.Paragraph)3 Avatar (com.vaadin.flow.component.avatar.Avatar)2 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)2 SubMenu (com.vaadin.flow.component.contextmenu.SubMenu)2 H5 (com.vaadin.flow.component.html.H5)2 Hr (com.vaadin.flow.component.html.Hr)2 JsonObject (elemental.json.JsonObject)2 User (com.dala.data.user.User)1 AuthenticatedUser (com.dala.security.AuthenticatedUser)1 Text (com.vaadin.flow.component.Text)1 Image (com.vaadin.flow.component.html.Image)1 Users (org.togetherjava.tjbot.db.generated.tables.pojos.Users)1