Search in sources :

Example 61 with Icon

use of com.vaadin.flow.component.icon.Icon in project komunumo-server by komunumo.

the class KeywordsView method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(KeywordListEntity::keyword).setHeader("Keyword").setAutoWidth(true).setFlexGrow(0).setKey("keyword");
    grid.addColumn(KeywordListEntity::eventCount).setHeader("Events").setAutoWidth(true).setTextAlign(ColumnTextAlign.CENTER).setFlexGrow(0);
    grid.addColumn(new ComponentRenderer<>(keyword -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showKeywordDialog(keyword));
        editButton.setTitle("Edit this keyword");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteKeyword(keyword));
        deleteButton.setTitle("Delete this keyword");
        deleteButton.setEnabled(keyword.eventCount() == 0);
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : KeywordListEntity(org.komunumo.data.entity.KeywordListEntity) EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 62 with Icon

use of com.vaadin.flow.component.icon.Icon in project komunumo-server by komunumo.

the class ConfigurationSetting method configureGrid.

private void configureGrid() {
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER, GridVariant.LUMO_ROW_STRIPES);
    grid.addColumn(ConfigurationRecord::getKey).setHeader("Key").setAutoWidth(true).setFlexGrow(0);
    grid.addColumn(ConfigurationRecord::getValue).setHeader("Value").setAutoWidth(false).setFlexGrow(1);
    grid.addColumn(new ComponentRenderer<>(configurationRecord -> {
        final var editButton = new EnhancedButton(new Icon(VaadinIcon.EDIT), clickEvent -> showEditDialog(configurationRecord));
        editButton.setTitle("Edit this configuration setting");
        final var deleteButton = new EnhancedButton(new Icon(VaadinIcon.TRASH), clickEvent -> deleteConfiguration(configurationRecord));
        deleteButton.setTitle("Delete this configuration setting");
        return new HorizontalLayout(editButton, deleteButton);
    })).setHeader("Actions").setAutoWidth(true).setFlexGrow(0);
    grid.setHeightFull();
}
Also used : EnhancedButton(org.komunumo.ui.component.EnhancedButton) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 63 with Icon

use of com.vaadin.flow.component.icon.Icon in project docs by vaadin.

the class NotificationError method show.

public Notification show() {
    // tag::snippet[]
    // When creating a notification using the constructor,
    // the duration is 0-sec by default which means that
    // the notification does not close automatically.
    Notification notification = new Notification();
    notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
    Div text = new Div(new Text("Failed to generate report"));
    Button closeButton = new Button(new Icon("lumo", "cross"));
    closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
    closeButton.getElement().setAttribute("aria-label", "Close");
    closeButton.addClickListener(event -> {
        notification.close();
    });
    HorizontalLayout layout = new HorizontalLayout(text, closeButton);
    layout.setAlignItems(Alignment.CENTER);
    notification.add(layout);
    notification.open();
    // end::snippet[]
    notification.setPosition(Notification.Position.MIDDLE);
    return notification;
}
Also used : Div(com.vaadin.flow.component.html.Div) Button(com.vaadin.flow.component.button.Button) Text(com.vaadin.flow.component.Text) Icon(com.vaadin.flow.component.icon.Icon) Notification(com.vaadin.flow.component.notification.Notification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 64 with Icon

use of com.vaadin.flow.component.icon.Icon in project docs by vaadin.

the class NotificationLink method show.

public Notification show() {
    // tag::snippet[]
    // When creating a notification using the constructor,
    // the duration is 0-sec by default which means that
    // the notification does not close automatically.
    Notification notification = new Notification();
    Div text = new Div(new Text("Jason Bailey mentioned you in "), new Anchor("#", "Project Q4"));
    Button closeButton = new Button(new Icon("lumo", "cross"));
    closeButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE);
    closeButton.getElement().setAttribute("aria-label", "Close");
    closeButton.addClickListener(event -> {
        notification.close();
    });
    HorizontalLayout layout = new HorizontalLayout(text, closeButton);
    layout.setAlignItems(Alignment.CENTER);
    notification.add(layout);
    notification.open();
    // end::snippet[]
    notification.setPosition(Notification.Position.MIDDLE);
    return notification;
}
Also used : Div(com.vaadin.flow.component.html.Div) Anchor(com.vaadin.flow.component.html.Anchor) Button(com.vaadin.flow.component.button.Button) Text(com.vaadin.flow.component.Text) Icon(com.vaadin.flow.component.icon.Icon) Notification(com.vaadin.flow.component.notification.Notification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 65 with Icon

use of com.vaadin.flow.component.icon.Icon in project docs by vaadin.

the class MenuBarIconOnly method createIconItem.

// tag::createIcon[]
private MenuItem createIconItem(MenuBar menu, VaadinIcon iconName, String ariaLabel) {
    Icon icon = new Icon(iconName);
    MenuItem item = menu.addItem(icon);
    item.getElement().setAttribute("aria-label", ariaLabel);
    return item;
}
Also used : MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) Icon(com.vaadin.flow.component.icon.Icon)

Aggregations

Icon (com.vaadin.flow.component.icon.Icon)110 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)94 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)46 Button (com.vaadin.flow.component.button.Button)39 Span (com.vaadin.flow.component.html.Span)21 Div (com.vaadin.flow.component.html.Div)19 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)18 Tab (com.vaadin.flow.component.tabs.Tab)16 Text (com.vaadin.flow.component.Text)15 Test (org.junit.Test)12 EnhancedButton (org.komunumo.ui.component.EnhancedButton)12 Grid (com.vaadin.flow.component.grid.Grid)10 RouterLink (com.vaadin.flow.router.RouterLink)9 Notification (com.vaadin.flow.component.notification.Notification)8 Component (com.vaadin.flow.component.Component)7 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)7 Anchor (com.vaadin.flow.component.html.Anchor)7 TextField (com.vaadin.flow.component.textfield.TextField)7 UI (com.vaadin.flow.component.UI)6 StreamResource (com.vaadin.flow.server.StreamResource)6