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));
}
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;
}
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;
}
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);
}
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);
}
Aggregations