com.vaadin.flow.component.Component

Here are the examples of the java api com.vaadin.flow.component.Component taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

85 Examples 7

19 Source : TabContainer.java
with Apache License 2.0
from peholmst

public void addTab(Tab tab, Component content) {
    contentMap.put(tab, content);
}

19 Source : LoadingResultNotification.java
with MIT License
from netcore-jsa

private static HorizontalLayout row(Component... components) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.START);
    layout.add(components);
    return layout;
}

19 Source : SerializationTest.java
with MIT License
from mcollovati

@Test
public void testViewsSerializable() throws Exception {
    UI ui = new UI();
    UI.setCurrent(ui);
    try {
        Collection<Clreplaced<? extends Component>> viewClreplacedes = new ViewClreplacedLocator(getClreplaced().getClreplacedLoader()).getAllViewClreplacedes();
        for (Clreplaced<? extends Component> viewClreplaced : viewClreplacedes) {
            Component view = viewClreplaced.newInstance();
            // view.onLocationChange(new LocationChangeEvent(new Router(),
            // ui,
            // NavigationTrigger.PROGRAMMATIC, new Location(""),
            // Collections.emptyList(), Collections.emptyMap()));
            try {
                replacedert.replacedertNotNull(serializeDeserialize(view));
            } catch (Exception e) {
                throw new replacedertionError("Can't serialize view " + viewClreplaced.getName(), e);
            }
        }
    } finally {
        UI.setCurrent(null);
    }
}

19 Source : PaperIconItem.java
with Apache License 2.0
from FlowingCode

private static Optional<AppDrawer> findAppDrawer(Component component) {
    while (component != null) {
        if (component instanceof AppDrawer) {
            return Optional.of((AppDrawer) component);
        } else {
            component = component.getParent().orElse(null);
        }
    }
    return Optional.empty();
}

19 Source : PaperCard.java
with Apache License 2.0
from FlowingCode

public void setCardContent(final Component content) {
    cardContentDiv.removeAll();
    cardContentDiv.add(content);
}

19 Source : MenuItem.java
with Apache License 2.0
from FlowingCode

@Override
public void add(Component... components) {
    HasOrderedComponents.super.add(components);
}

19 Source : AppToolbar.java
with Apache License 2.0
from FlowingCode

public void addToolbarIconButtonAsFirst(Component component) {
    this.addComponentAtIndex(index, component);
}

19 Source : AppToolbar.java
with Apache License 2.0
from FlowingCode

private void addComponentAtIndex(int index, Component component) {
    hasOrderedComponents.addComponentAtIndex(index, component);
}

19 Source : AppToolbar.java
with Apache License 2.0
from FlowingCode

public void addToolbarIconButtons(Component... components) {
    this.add(components);
}

19 Source : AppToolbar.java
with Apache License 2.0
from FlowingCode

private void add(Component... components) {
    hasOrderedComponents.add(components);
}

19 Source : AppLayout.java
with Apache License 2.0
from FlowingCode

public void addToolbarIconButtons(Component... components) {
    header.getAppToolbar().addToolbarIconButtons(components);
}

19 Source : AppLayout.java
with Apache License 2.0
from FlowingCode

public void addToolbarIconButtonAsFirst(Component component) {
    header.getAppToolbar().addToolbarIconButtonAsFirst(component);
}

19 Source : AppLayout.java
with Apache License 2.0
from FlowingCode

public void setMenuItems(Component... menuitems) {
    drawer.setMenuItems(Arrays.asList(menuitems));
}

19 Source : AppLayout.java
with Apache License 2.0
from FlowingCode

public void setToolbarIconButtons(Component... components) {
    header.getAppToolbar().clearToolbarIconButtons();
    header.getAppToolbar().addToolbarIconButtons(components);
}

19 Source : AppDrawer.java
with Apache License 2.0
from FlowingCode

static Optional<AppDrawer> findAppDrawer(Component component) {
    while (component != null) {
        if (component instanceof AppDrawer) {
            return Optional.of((AppDrawer) component);
        } else {
            component = component.getParent().orElse(null);
        }
    }
    return Optional.empty();
}

19 Source : AppDrawer.java
with Apache License 2.0
from FlowingCode

@Override
public void remove(Component... components) {
    for (Component c : components) {
        if (c instanceof MenuItem) {
            pm.removeAll();
        } else {
            HasComponents.super.remove(components);
        }
    }
}

19 Source : AppDrawer.java
with Apache License 2.0
from FlowingCode

@Override
public void add(Component... components) {
    for (Component c : components) {
        if (c instanceof MenuItem) {
            pm.add(c);
        } else {
            HasComponents.super.add(components);
        }
    }
}

19 Source : LayoutHelper.java
with Apache License 2.0
from appreciated

public static void add(HasComponents element, Component... components) {
    if (components == null) {
        throw new replacedertionError();
    } else {
        for (final Component component : components) {
            if (component == null) {
                throw new replacedertionError();
            }
            element.getElement().appendChild(component.getElement());
        }
    }
}

19 Source : NavigationElementInfo.java
with Apache License 2.0
from appreciated

/**
 * Data structure that contains all the needed information of a {@link LeftNavigationItem} This clreplaced is being used by
 * by the {@link DefaultNavigationElementInfoProducer}.
 */
public clreplaced NavigationElementInfo {

    String caption;

    Component icon;

    String route;

    public NavigationElementInfo(String caption, Component icon, String route) {
        this.caption = caption;
        this.icon = icon;
        this.route = route;
    }

    public NavigationElementInfo(String caption, String route) {
        this.caption = caption;
        this.route = route;
    }

    public String getCaption() {
        return caption;
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }

    public Component getIcon() {
        return icon;
    }

    public void setIcon(Component icon) {
        this.icon = icon;
    }

    public String getRoute() {
        return route;
    }

    public void setRoute(String route) {
        this.route = route;
    }
}

19 Source : NavigationElementInfo.java
with Apache License 2.0
from appreciated

public void setIcon(Component icon) {
    this.icon = icon;
}

19 Source : TopMenuComponent.java
with Apache License 2.0
from appreciated

@Override
public void add(Component... components) {
    super.add(components);
    applyParentToItems(Arrays.stream(components));
}

19 Source : TopAppMenuBuilder.java
with Apache License 2.0
from appreciated

public TopAppMenuBuilder addToSection(Section section, Component... element) {
    Arrays.stream(element).forEach(component -> addToSection(section, component));
    return this;
}

19 Source : TopAppMenuBuilder.java
with Apache License 2.0
from appreciated

private void addToSection(Section section, Component element) {
    components.add(element);
}

19 Source : LeftNavigationItem.java
with Apache License 2.0
from appreciated

/**
 * A wrapper clreplaced for a MenuElement that is clickable and backed by the Navigator. Which means that
 * clicks on instances on {@link LeftNavigationItem} respectively their
 * {@link com.vaadin.flow.component.Component} which will usually causes a change of the View at the
 * AppLayout content view.
 */
public clreplaced LeftNavigationItem extends LeftBadgeIconItem implements NavigationElement, BeforeEnterObserver {

    private static final long serialVersionUID = 1L;

    /**
     * The caption of this menu element
     */
    private String caption;

    /**
     * The view behind this menu element
     */
    private Component icon;

    private Clreplaced<? extends Component> clreplacedName;

    private NavigationElementContainer parent;

    public LeftNavigationItem(String caption, Component icon, Component view) {
        this(caption, icon, view.getClreplaced());
        this.caption = caption;
        this.icon = icon;
    }

    public LeftNavigationItem(String caption, Component icon, Clreplaced<? extends Component> clreplacedName) {
        super(caption, icon);
        this.caption = caption;
        this.icon = icon;
        this.clreplacedName = clreplacedName;
        UpNavigationHelper.registerNavigationRoute(clreplacedName);
        setRoute(UI.getCurrent().getRouter(), clreplacedName);
        setHighlightCondition((routerLink, event) -> UpNavigationHelper.shouldHighlight(clreplacedName, event.getLocation()));
    }

    public LeftNavigationItem(String caption, VaadinIcon icon, Clreplaced<? extends Component> clreplacedName) {
        this(caption, icon.create(), clreplacedName);
    }

    public LeftNavigationItem(Component view) {
        this(view.getClreplaced());
    }

    public LeftNavigationItem(Clreplaced<? extends Component> clreplacedName) {
        this(clreplacedName.getAnnotation(Caption.clreplaced).value(), clreplacedName.getAnnotation(com.github.appreciated.app.layout.annotations.Icon.clreplaced).value().create(), clreplacedName);
    }

    public Component getIcon() {
        return icon;
    }

    @Override
    public void setNavigationElementContainer(NavigationElementContainer parent) {
        this.parent = parent;
    }

    @Override
    public void beforeEnter(BeforeEnterEvent event) {
        if (parent != null) {
            parent.setActiveNavigationElement(UpNavigationHelper.shouldHighlight(clreplacedName, event.getLocation()) ? this : null);
        }
    }
}

19 Source : LeftIconItem.java
with Apache License 2.0
from appreciated

public void setIcon(Component icon) {
    if (this.icon != null) {
        remove(caption);
    }
    this.icon = icon;
    if (icon != null) {
        getElement().insertChild(0, this.icon.getElement());
    }
}

19 Source : LeftSubMenuBuilder.java
with Apache License 2.0
from appreciated

/**
 * Adds a MenuElement
 *
 * @param elements
 * @return
 */
public LeftSubMenuBuilder add(Component... elements) {
    components.addAll(Arrays.asList(elements));
    return this;
}

19 Source : LeftSubMenuBuilder.java
with Apache License 2.0
from appreciated

/**
 * returns a SubmenuBuilder with a predefined expanding element that only has an icon
 *
 * @param icon
 * @return
 */
public static LeftSubMenuBuilder get(Component icon) {
    return new LeftSubMenuBuilder(null, icon);
}

19 Source : LeftSubMenuBuilder.java
with Apache License 2.0
from appreciated

public static LeftSubMenuBuilder get(String replacedle, Component icon) {
    return new LeftSubMenuBuilder(replacedle, icon);
}

19 Source : LeftAppMenuBuilder.java
with Apache License 2.0
from appreciated

public LeftAppMenuBuilder addToSection(Section section, Component... element) {
    Arrays.stream(element).forEach(component -> addToSection(component, section));
    return this;
}

19 Source : LeftAppMenuBuilder.java
with Apache License 2.0
from appreciated

public LeftAppMenuBuilder add(String caption, Component icon, Clreplaced<? extends Component> clreplacedName) {
    return add(new LeftNavigationItem(caption, icon, clreplacedName));
}

19 Source : LeftAppMenuBuilder.java
with Apache License 2.0
from appreciated

private LeftAppMenuBuilder addToSection(Component element, Section section) {
    switch(section) {
        case HEADER:
            header.add(element);
            break;
        case FOOTER:
            footer.add(element);
            break;
        default:
            body.add(element);
    }
    return this;
}

19 Source : AppLayoutBuilder.java
with Apache License 2.0
from appreciated

/**
 * This is the supposed entry clreplaced to build an instance of the app-layout. The {@link AppLayoutBuilder} is a builder pattern.
 */
public clreplaced AppLayoutBuilder<T extends AppLayout> implements ComponentBuilder<T> {

    private T instance;

    private Component replacedleComponent;

    private Component imageComponent;

    private boolean upNavigation;

    private boolean swipeOpen = true;

    private AppLayoutBuilder(@NotNull T instance) {
        this.instance = instance;
    }

    public static <T extends AppLayout> AppLayoutBuilder<T> get(Clreplaced<T> variant) {
        try {
            return get(variant.newInstance());
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        throw new IllegalStateException(variant.getName() + " could not be instantiated, please check the logs!");
    }

    public static <T extends AppLayout> AppLayoutBuilder<T> get(T variant) {
        return new AppLayoutBuilder<>(variant);
    }

    /**
     * Creates a replacedle {@link Component} and set it in the app-bar of the {@link AppLayout}
     *
     * @param replacedle replacedle as string
     * @return the builder
     */
    public AppLayoutBuilder<T> withreplacedle(String replacedle) {
        setreplacedle(replacedle);
        return this;
    }

    /**
     * Sets a replacedle {@link Component} in the app-bar of the {@link AppLayout}
     *
     * @param replacedle replacedle as string
     */
    public void setreplacedle(String replacedle) {
        Span span = new Span(replacedle);
        span.setWidth("100%");
        span.getStyle().set("margin-left", "var(--app-layout-menu-toggle-button-padding)").set("white-space", "nowrap").set("overflow", "hidden").set("text-overflow", "ellipsis");
        setreplacedleComponent(span);
    }

    /**
     * Sets the {@link Component} that is supposed to represent the replacedle in the app-bar
     *
     * @param replacedleComponent component that will the the replacedle
     */
    public void setreplacedleComponent(Component replacedleComponent) {
        this.replacedleComponent = replacedleComponent;
    }

    /**
     * Sets the replacedle component by using {@link AppLayoutBuilder#setreplacedleComponent(Component)}
     *
     * @param component the replacedle component
     * @return Itself to allow method chaining
     */
    public AppLayoutBuilder<T> withreplacedle(Component component) {
        setreplacedleComponent(component);
        return this;
    }

    /**
     * Builds the layout and returns an instance of an AppLayout which also is a Component
     *
     * @return the build AppLayout instance
     */
    public T build() {
        if (replacedleComponent != null) {
            instance.setreplacedleComponent(replacedleComponent);
        }
        if (imageComponent != null) {
            instance.setIconComponent(imageComponent);
        }
        if (swipeOpen && instance.getDrawer() != null) {
            instance.getDrawer().getElement().setAttribute("swipe-open", true);
        }
        instance.setUpNavigationEnabled(upNavigation);
        instance.init();
        return instance;
    }

    /**
     * set the app-bar {@link Component} of the {@link AppLayout} that is built
     *
     * @param component the build app-bar component
     * @return Itself to allow method chaining
     */
    public AppLayoutBuilder<T> withAppBar(Component component) {
        setAppBarComponent(component);
        return this;
    }

    public void setAppBarComponent(Component component) {
        instance.setAppBar(component);
    }

    /**
     * @param component the app menu component
     * @return Itself to allow method chaining
     */
    public AppLayoutBuilder<T> withAppMenu(Component component) {
        setAppMenu(component);
        return this;
    }

    /**
     * Sets the Component that represents the menu on the left hand / the top side (depending which {@link AppLayout} you are using).
     *
     * @param component
     */
    public void setAppMenu(Component component) {
        instance.setAppMenu(component);
    }

    /**
     * @param url a url to the image that is supposed to be shown in the app bar
     * @return Itself to allow method chaining
     */
    public AppLayoutBuilder<T> withIcon(String url) {
        Image image = new Image(url, "icon");
        image.setHeight("var(--app-layout-menu-button-height)");
        image.getStyle().set("margin", "var(--app-layout-space-s)");
        return withIconComponent(image);
    }

    /**
     * @param image
     * @return Itself to allow method chaining
     */
    public AppLayoutBuilder<T> withIconComponent(Component image) {
        this.imageComponent = image;
        return this;
    }

    public AppLayoutBuilder<T> withSwipeOpen(boolean swipeOpen) {
        this.swipeOpen = swipeOpen;
        return this;
    }

    public AppLayoutBuilder<T> withUpNavigation() {
        this.upNavigation = true;
        return this;
    }
}

19 Source : AppLayoutBuilder.java
with Apache License 2.0
from appreciated

public void setAppBarComponent(Component component) {
    instance.setAppBar(component);
}

19 Source : AppLayoutBuilder.java
with Apache License 2.0
from appreciated

/**
 * set the app-bar {@link Component} of the {@link AppLayout} that is built
 *
 * @param component the build app-bar component
 * @return Itself to allow method chaining
 */
public AppLayoutBuilder<T> withAppBar(Component component) {
    setAppBarComponent(component);
    return this;
}

19 Source : AppLayoutBuilder.java
with Apache License 2.0
from appreciated

/**
 * Sets the {@link Component} that is supposed to represent the replacedle in the app-bar
 *
 * @param replacedleComponent component that will the the replacedle
 */
public void setreplacedleComponent(Component replacedleComponent) {
    this.replacedleComponent = replacedleComponent;
}

19 Source : AppLayoutBuilder.java
with Apache License 2.0
from appreciated

/**
 * Sets the replacedle component by using {@link AppLayoutBuilder#setreplacedleComponent(Component)}
 *
 * @param component the replacedle component
 * @return Itself to allow method chaining
 */
public AppLayoutBuilder<T> withreplacedle(Component component) {
    setreplacedleComponent(component);
    return this;
}

19 Source : AppLayoutBuilder.java
with Apache License 2.0
from appreciated

/**
 * @param image
 * @return Itself to allow method chaining
 */
public AppLayoutBuilder<T> withIconComponent(Component image) {
    this.imageComponent = image;
    return this;
}

19 Source : AppLayoutBuilder.java
with Apache License 2.0
from appreciated

/**
 * @param component the app menu component
 * @return Itself to allow method chaining
 */
public AppLayoutBuilder<T> withAppMenu(Component component) {
    setAppMenu(component);
    return this;
}

19 Source : AppLayoutBuilder.java
with Apache License 2.0
from appreciated

/**
 * Sets the Component that represents the menu on the left hand / the top side (depending which {@link AppLayout} you are using).
 *
 * @param component
 */
public void setAppMenu(Component component) {
    instance.setAppMenu(component);
}

19 Source : AbstractLeftAppLayoutBase.java
with Apache License 2.0
from appreciated

@Override
public void setAppMenu(Component container) {
    this.container = container;
    menuElements.removeAll();
    menuElements.add(container);
}

19 Source : AbstractLeftAppLayoutBase.java
with Apache License 2.0
from appreciated

public void setreplacedleComponent(Component component) {
    replacedleWrapper.replace(this.replacedle, component);
    this.replacedle = component;
    this.replacedle.getElement().getStyle().set("display", "var(--app-layout-app-bar-large-object-display)");
    replacedleWrapper.setAlignItems(FlexComponent.Alignment.CENTER);
}

19 Source : AbstractLeftAppLayoutBase.java
with Apache License 2.0
from appreciated

public void setIconComponent(Component appBarIconComponent) {
    replacedleWrapper.getElement().insertChild(0, appBarIconComponent.getElement());
    replacedleWrapper.setAlignItems(FlexComponent.Alignment.CENTER);
}

19 Source : AbstractLeftAppLayoutBase.java
with Apache License 2.0
from appreciated

@Override
public void setAppBar(Component component) {
    appBarElementContainer.removeAll();
    appBarElementContainer.add(component);
}

19 Source : ContextMenuAppBarButton.java
with Apache License 2.0
from appreciated

public void addItem(Component component, ComponentEventListener<ClickEvent<MenuItem>> clickListener) {
    contextMenu.addItem(component, clickListener);
}

19 Source : ContextMenuAppBarButton.java
with Apache License 2.0
from appreciated

public void addItem(Component component) {
    contextMenu.addItem(component);
}

19 Source : AppBarBuilder.java
with Apache License 2.0
from appreciated

public AppBarBuilder add(Component... component) {
    components.addAll(Arrays.asList(component));
    return this;
}

19 Source : AppBarProfileButtonBuilder.java
with Apache License 2.0
from appreciated

public AppBarProfileButtonBuilder withItem(Component component) {
    appBarProfileButton.addItem(component);
    return this;
}

19 Source : AppBarProfileButtonBuilder.java
with Apache License 2.0
from appreciated

public AppBarProfileButtonBuilder withItem(Component component, ComponentEventListener<ClickEvent<MenuItem>> clickListener) {
    appBarProfileButton.addItem(component, clickListener);
    return this;
}

19 Source : AppBarImageProfileButtonBuilder.java
with Apache License 2.0
from appreciated

public AppBarImageProfileButtonBuilder withItem(Component component) {
    appBarProfileButton.addItem(component);
    return this;
}

19 Source : AppBarImageProfileButtonBuilder.java
with Apache License 2.0
from appreciated

public AppBarImageProfileButtonBuilder withItem(Component component, ComponentEventListener<ClickEvent<MenuItem>> clickListener) {
    appBarProfileButton.addItem(component, clickListener);
    return this;
}

See More Examples