com.vaadin.flow.component.html.Div

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

62 Examples 7

19 Source : ScrollView.java
with MIT License
from mcollovati

static Div createSpacerDiv(int heightPx) {
    Div spacer = new Div();
    spacer.setHeight(heightPx + "px");
    return spacer;
}

19 Source : CustomScrollCallbacksView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.scroll.CustomScrollCallbacksView", layout = ViewTestLayout.clreplaced)
public clreplaced CustomScrollCallbacksView extends AbstractDivView implements HasUrlParameter<String> {

    private final Div viewName = new Div();

    private final Div log = new Div();

    public CustomScrollCallbacksView() {
        viewName.setId("view");
        log.setId("log");
        log.getStyle().set("white-space", "pre");
        UI.getCurrent().getPage().executeJs("window.Vaadin.Flow.setScrollPosition = function(xAndY) { $0.textContent += JSON.stringify(xAndY) + '\\n' }", log);
        UI.getCurrent().getPage().executeJs("window.Vaadin.Flow.getScrollPosition = function() { return [42, -window.pageYOffset] }");
        RouterLink navigate = new RouterLink("Navigate", CustomScrollCallbacksView.clreplaced, "navigated");
        navigate.setId("navigate");
        Anchor back = new Anchor("javascript:history.go(-1)", "Back");
        back.setId("back");
        add(viewName, log, new Span("Scroll down to see navigation actions"), ScrollView.createSpacerDiv(2000), navigate, back);
    }

    @Override
    public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
        viewName.setText("Current view: " + parameter);
    }
}

19 Source : PreserveOnRefreshView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.PreserveOnRefreshView")
@PreserveOnRefresh
public clreplaced PreserveOnRefreshView extends Div {

    final static String COMPONENT_ID = "contents";

    final static String NOTIFICATION_ID = "notification";

    final static String ATTACHCOUNTER_ID = "attachcounter";

    private int attached = 0;

    private final Div attachCounter;

    public PreserveOnRefreshView() {
        // create unique content for this instance
        final String uniqueId = Long.toString(new Random().nextInt());
        final Div componentId = new Div();
        componentId.setId(COMPONENT_ID);
        componentId.setText(uniqueId);
        add(componentId);
        // add an element to keep track of number of attach events
        attachCounter = new Div();
        attachCounter.setId(ATTACHCOUNTER_ID);
        attachCounter.setText("0");
        add(attachCounter);
        // also add an element as a separate UI child. This is expected to be
        // transferred on refresh (mimicking dialogs and notifications)
        final Element looseElement = new Element("div");
        looseElement.setProperty("id", NOTIFICATION_ID);
        looseElement.setText(uniqueId);
        UI.getCurrent().getElement().insertChild(0, looseElement);
    }

    @Override
    protected void onAttach(AttachEvent event) {
        attached += 1;
        attachCounter.setText(Integer.toString(attached));
    }
}

19 Source : DnDCustomComponentView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.DnDCustomComponentView", layout = ViewTestLayout.clreplaced)
public clreplaced DnDCustomComponentView extends Div {

    private final Div dropTarget;

    public clreplaced DraggableItem extends Div implements DragSource<DraggableItem> {

        private final Div dragHandle;

        public DraggableItem(EffectAllowed effectAllowed) {
            dragHandle = new Div();
            dragHandle.setHeight("50px");
            dragHandle.setWidth("80px");
            dragHandle.getStyle().set("background", "#000 ");
            dragHandle.getStyle().set("margin", "5 10px");
            dragHandle.getStyle().set("display", "inline-block");
            setDraggable(true);
            setDragData(effectAllowed);
            addDragStartListener(DnDCustomComponentView.this::onDragStart);
            addDragEndListener(DnDCustomComponentView.this::onDragEnd);
            setHeight("50px");
            setWidth("200px");
            getStyle().set("border", "1px solid black");
            getStyle().set("display", "inline-block");
            add(dragHandle, new Span(effectAllowed.toString()));
        }

        @Override
        public Element getDraggableElement() {
            return dragHandle.getElement();
        }
    }

    public DnDCustomComponentView() {
        Stream.of(EffectAllowed.values()).map(DraggableItem::new).forEach(this::add);
        dropTarget = new Div();
        dropTarget.add(new Text("Drop Here"));
        dropTarget.setWidth("200px");
        dropTarget.setHeight("200px");
        dropTarget.getStyle().set("border", "solid 1px pink");
        add(dropTarget);
        DropTarget.create(dropTarget).addDropListener(event -> event.getSource().add(new Span(event.getDragData().get().toString())));
    }

    private void onDragStart(DragStartEvent<DraggableItem> event) {
        dropTarget.getStyle().set("background-color", "lightgreen");
    }

    private void onDragEnd(DragEndEvent<DraggableItem> event) {
        dropTarget.getStyle().remove("background-color");
    }
}

19 Source : DynamicDependencyView.java
with MIT License
from mcollovati

@Route("com.vaadin.flow.uitest.ui.dependencies.DynamicDependencyView")
public clreplaced DynamicDependencyView extends Div {

    private final Div newComponent = new Div();

    @Override
    protected void onAttach(AttachEvent attachEvent) {
        if (attachEvent.isInitialAttach()) {
            newComponent.setId("new-component");
            add(newComponent);
            attachEvent.getUI().getPage().addDynamicImport("return new Promise( " + " function( resolve, reject){ " + "   var div = doreplacedent.createElement(\"div\");\n" + "     div.setAttribute('id','dep');\n" + "     div.textContent = doreplacedent.querySelector('#new-component')==null;\n" + "     doreplacedent.body.appendChild(div);resolve('');}" + ");");
            add(createLoadButton("nopromise", "Load non-promise dependency", "doreplacedent.querySelector('#new-component').textContent = 'import has been run'"));
            add(createLoadButton("throw", "Load throwing dependency", "throw Error('Throw on purpose')"));
            add(createLoadButton("reject", "Load rejecting dependency", "return new Promise(function(resolve, reject) { reject(Error('Reject on purpose')); });"));
        }
    }

    private NativeButton createLoadButton(String id, String name, String expression) {
        NativeButton button = new NativeButton(name, event -> {
            UI.getCurrent().getPage().addDynamicImport(expression);
            newComponent.setText("Div updated for " + id);
        });
        button.setId(id);
        return button;
    }
}

19 Source : AbstractDebounceSynchronizeView.java
with MIT License
from mcollovati

public abstract clreplaced AbstractDebounceSynchronizeView extends AbstractDivView {

    protected final static int CHANGE_TIMEOUT = 1000;

    private final Div messages = new Div();

    protected void addChangeMessagesDiv() {
        messages.getElement().setAttribute("id", "messages");
        add(messages);
    }

    protected void addChangeMessage(Serializable value) {
        messages.add(new Paragraph("Value: " + value));
    }
}

18 Source : MenuTemplate.java
with MIT License
from netcore-jsa

private void addSeparator() {
    Element li = ElementFactory.createLisreplacedem();
    Div div = new Div();
    div.getClreplacedNames().add("separator");
    li.appendChild(div.getElement());
    linksContainer.appendChild(li);
}

18 Source : WaitForVaadinView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.WaitForVaadinView", layout = ViewTestLayout.clreplaced)
public clreplaced WaitForVaadinView extends AbstractDivView {

    private final Div message;

    private final NativeButton button;

    public WaitForVaadinView() {
        message = new Div();
        message.setText("Not updated");
        message.setId("message");
        button = new NativeButton("Click to update", e -> waitAndUpdate());
        add(message, button);
    }

    private void waitAndUpdate() {
        try {
            message.setText("Updated");
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        // Ignore
        }
    }
}

18 Source : TemplateScalabilityView.java
with MIT License
from mcollovati

private void generateChildren() {
    div.removeAll();
    for (int i = 0; i < NUM_ITEMS; ++i) {
        TemplateScalabilityPanel p = new TemplateScalabilityPanel("Panel " + i);
        div.add(p);
    }
    Div complete = new Div();
    complete.setId(COMPLETED);
    div.addComponentAsFirst(complete);
}

18 Source : SynchronizedPropertyView.java
with MIT License
from mcollovati

private void addSyncOnKeyup() {
    Div label;
    add(new Text("Synchronized on 'keyup' event"));
    label = new Div();
    label.setId("syncOnKeyUpLabel");
    InputSync syncOnKeyUp = new InputSync(label, "keyup");
    syncOnKeyUp.setId("syncOnKeyUp");
    add(syncOnKeyUp);
    add(label);
}

18 Source : SynchronizedPropertyView.java
with MIT License
from mcollovati

private void addSimpleSync() {
    add(new Text("Synchronized on 'change' event"));
    Div label = new Div();
    label.setId("syncOnChangeLabel");
    InputSync syncOnChange = new InputSync(label, "change");
    syncOnChange.setId("syncOnChange");
    add(syncOnChange);
    add(label);
}

18 Source : SetParameterForwardToView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.SetParameterForwardToView", layout = ViewTestLayout.clreplaced)
public clreplaced SetParameterForwardToView extends Div implements HasUrlParameter<String>, AfterNavigationObserver {

    static final String LOCATION_ID = "location";

    private final Div location;

    public SetParameterForwardToView() {
        location = new Div();
        location.setId(LOCATION_ID);
    }

    @Override
    public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
        if (parameter != null && parameter.equals("one")) {
            event.forwardTo("com.vaadin.flow.uitest.ui.SetParameterForwardToView", "two");
        }
    }

    @Override
    public void afterNavigation(AfterNavigationEvent event) {
        location.setText(event.getLocation().getPath());
        add(location);
    }
}

18 Source : LoadingIndicatorView.java
with MIT License
from mcollovati

private static Div divWithText(String text) {
    Div div = new Div();
    div.setText(text);
    return div;
}

18 Source : ExtendedClientDetailsView.java
with MIT License
from mcollovati

@Override
protected void onShow() {
    Div screenWidth = createDiv("sw");
    Div screenHeight = createDiv("sh");
    Div windowInnerWidth = createDiv("ww");
    Div windowInnerHeight = createDiv("wh");
    Div bodyElementWidth = createDiv("bw");
    Div bodyElementHeight = createDiv("bh");
    Div devicePixelRatio = createDiv("pr");
    Div touchDevice = createDiv("td");
    // the sizing values cannot be set with JS but pixel ratio and touch
    // support can be faked
    NativeButton setValuesButton = new NativeButton("Set test values", event -> {
        getUI().ifPresent(ui -> ui.getPage().executeJs("{" + "window.devicePixelRatio = 2.0;" + "navigator.msMaxTouchPoints = 1;" + "}"));
    });
    setValuesButton.setId("set-values");
    NativeButton fetchDetailsButton = new NativeButton("Fetch client details", event -> {
        getUI().ifPresent(ui -> ui.getPage().retrieveExtendedClientDetails(details -> {
            screenWidth.setText("" + details.getScreenWidth());
            screenHeight.setText("" + details.getScreenHeight());
            windowInnerWidth.setText("" + details.getWindowInnerWidth());
            windowInnerHeight.setText("" + details.getWindowInnerHeight());
            bodyElementWidth.setText("" + details.getBodyClientWidth());
            bodyElementHeight.setText("" + details.getBodyClientHeight());
            devicePixelRatio.setText("" + details.getDevicePixelRatio());
            touchDevice.setText("" + details.isTouchDevice());
        }));
    });
    fetchDetailsButton.setId("fetch-values");
    add(setValuesButton, fetchDetailsButton);
}

18 Source : ExtendedClientDetailsView.java
with MIT License
from mcollovati

private Div createDiv(String id) {
    Div div = new Div();
    div.setId(id);
    add(div);
    return div;
}

18 Source : ElementInnerHtmlView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.ElementInnerHtmlView", layout = ViewTestLayout.clreplaced)
public clreplaced ElementInnerHtmlView extends AbstractDivView {

    Div innerHtml;

    @Override
    protected void onShow() {
        innerHtml = new Div();
        innerHtml.setId("inner-html-field");
        add(createButton("Foo"), createButton("Boo"), getNullButton(), innerHtml);
    }

    private NativeButton createButton(String value) {
        NativeButton button = new NativeButton("Set value " + value, click -> innerHtml.getElement().setProperty("innerHTML", String.format("<p>%s</p>", value)));
        button.setId("set-" + value.toLowerCase());
        return button;
    }

    private NativeButton getNullButton() {
        NativeButton button = new NativeButton("Set value null", click -> innerHtml.getElement().setProperty("innerHTML", null));
        button.setId("set-null");
        return button;
    }
}

18 Source : DnDView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.DnDView", layout = ViewTestLayout.clreplaced)
public clreplaced DnDView extends Div {

    public static final String NO_EFFECT_SETUP = "no-effect";

    private Div eventLog;

    private int eventCounter = 0;

    private boolean data;

    public DnDView() {
        setWidth("1000px");
        setHeight("800px");
        getStyle().set("display", "flex");
        eventLog = new Div();
        eventLog.add(new Text("Events:"));
        eventLog.add(new NativeButton("Clear", event -> {
            eventLog.getChildren().filter(component -> component instanceof Div).forEach(eventLog::remove);
            eventCounter = 0;
        }));
        eventLog.add(new NativeButton("Data: " + data, event -> {
            data = !data;
            event.getSource().setText("Data: " + data);
        }));
        eventLog.setHeightFull();
        eventLog.setWidth("400px");
        eventLog.getStyle().set("display", "inline-block").set("border", "2px " + "solid");
        add(eventLog);
        Div startLane = createLane("start");
        startLane.add(createDraggableBox(null));
        Stream.of(EffectAllowed.values()).map(this::createDraggableBox).forEach(startLane::add);
        Div noEffectLane = createDropLane(null);
        Div copyDropLane = createDropLane(DropEffect.COPY);
        Div moveDropLane = createDropLane(DropEffect.MOVE);
        Div linkDropLane = createDropLane(DropEffect.LINK);
        Div noneDropLane = createDropLane(DropEffect.NONE);
        Div deactivatedLane = createDropLane(DropEffect.COPY);
        deactivatedLane.setId("lane-deactivated");
        deactivatedLane.getChildren().findFirst().ifPresent(component -> component.getElement().setText("deactivated"));
        DropTarget.configure(deactivatedLane, false);
        add(startLane, noEffectLane, copyDropLane, moveDropLane, linkDropLane, noneDropLane, deactivatedLane);
    }

    private void addLogEntry(String eventDetails) {
        Div div = new Div();
        eventCounter++;
        div.add(eventCounter + ": " + eventDetails);
        div.setId("event-" + eventCounter);
        eventLog.add(div);
    }

    private Component createDraggableBox(EffectAllowed effectAllowed) {
        String identifier = effectAllowed == null ? NO_EFFECT_SETUP : effectAllowed.toString();
        Div box = createBox(identifier);
        DragSource<Div> dragSource = DragSource.create(box);
        dragSource.setDraggable(true);
        if (effectAllowed != null) {
            dragSource.setEffectAllowed(effectAllowed);
        }
        dragSource.addDragStartListener(event -> {
            addLogEntry("Start: " + event.getComponent().getText());
            if (data) {
                dragSource.setDragData(identifier);
            }
        });
        dragSource.addDragEndListener(event -> {
            addLogEntry("End: " + event.getComponent().getText() + " " + event.getDropEffect());
        });
        return box;
    }

    private Div createDropLane(DropEffect dropEffect) {
        String identifier = dropEffect == null ? "no-effect" : dropEffect.toString();
        Div lane = createLane(identifier);
        DropTarget<Div> dropTarget = DropTarget.create(lane);
        dropTarget.setActive(true);
        if (dropEffect != null) {
            dropTarget.setDropEffect(dropEffect);
        }
        dropTarget.addDropListener(event -> addLogEntry("Drop: " + event.getEffectAllowed() + " " + event.getDropEffect() + (data ? (" " + event.getDragData()) : "")));
        return lane;
    }

    private Div createBox(String identifier) {
        Div box = new Div();
        box.setText(identifier);
        box.setWidth("100px");
        box.setHeight("60px");
        box.getStyle().set("border", "1px solid").set("margin", "10px");
        box.setId("box-" + identifier);
        return box;
    }

    private Div createLane(String identifier) {
        Div lane = new Div();
        lane.add(identifier);
        lane.setId("lane-" + identifier);
        lane.getStyle().set("margin", "20px").set("border", "1px solid black").set("display", "inline-block");
        lane.setHeightFull();
        lane.setWidth("150px");
        return lane;
    }
}

18 Source : DnDView.java
with MIT License
from mcollovati

private void addLogEntry(String eventDetails) {
    Div div = new Div();
    eventCounter++;
    div.add(eventCounter + ": " + eventDetails);
    div.setId("event-" + eventCounter);
    eventLog.add(div);
}

18 Source : DnDAttachDetachView.java
with MIT License
from mcollovati

/* https://github.com/vaadin/flow/issues/6054 */
@Route(value = "com.vaadin.flow.uitest.ui.DnDAttachDetachView")
public clreplaced DnDAttachDetachView extends Div {

    public static final String DRAGGABLE_ID = "draggable";

    public static final String VIEW_1_ID = "view1";

    public static final String VIEW_2_ID = "view2";

    public static final String SWAP_BUTTON_ID = "swap-button";

    public static final String MOVE_BUTTON_ID = "move-button";

    private Div buttonSwitchViews = new Div();

    private Div buttonRemoveAdd = new Div();

    private Div view1 = new Div();

    private Div view2 = new Div();

    private int counter = 0;

    public DnDAttachDetachView() {
        setSizeFull();
        buttonSwitchViews.setText("Click to detach OR attach");
        buttonSwitchViews.setId(SWAP_BUTTON_ID);
        buttonSwitchViews.getStyle().set("border", "1px solid black");
        buttonSwitchViews.setHeight("20px");
        buttonSwitchViews.setWidth("200px");
        buttonRemoveAdd.setText("Click to detach AND attach");
        buttonRemoveAdd.setId(MOVE_BUTTON_ID);
        buttonRemoveAdd.getStyle().set("border", "1px solid black");
        buttonRemoveAdd.setHeight("20px");
        buttonRemoveAdd.setWidth("200px");
        add(buttonSwitchViews, buttonRemoveAdd);
        Div div = new Div();
        div.setText("Text To Drag");
        div.setId(DRAGGABLE_ID);
        div.getStyle().set("background-color", "grey");
        add(div);
        add(view1);
        view1.setWidth("500px");
        view1.setHeight("500px");
        view1.getStyle().set("background-color", "pink");
        view1.setId(VIEW_1_ID);
        view2.setWidth("500px");
        view2.setHeight("500px");
        view2.setId(VIEW_2_ID);
        // need to set the effect allowed and drop effect for the simulation
        DragSource<Div> dragSource = DragSource.create(div);
        dragSource.addDragStartListener(event -> add(new Span("Start: " + counter)));
        dragSource.setEffectAllowed(EffectAllowed.COPY);
        DropTarget<Div> dt = DropTarget.create(view1);
        dt.setDropEffect(DropEffect.COPY);
        buttonSwitchViews.addClickListener(event -> {
            if (getChildren().anyMatch(component -> component == view1)) {
                remove(div, view1);
                add(view2);
            } else {
                remove(view2);
                add(div, view1);
            }
        });
        buttonRemoveAdd.addClickListener(event -> {
            remove(div, view1);
            add(div, view1);
        });
        DropTarget.configure(view1).addDropListener(this::onDrop);
    }

    private void onDrop(DropEvent<Div> divDropEvent) {
        Span span = new Span("Drop: " + counter);
        span.setId("drop-" + counter);
        add(span);
        counter++;
    }
}

18 Source : ApplayoutDemoView.java
with Apache License 2.0
from FlowingCode

private Component createAvatarComponent() {
    Div container = new Div();
    container.getElement().setAttribute("style", "text-align: center;");
    Image img = new Image("/frontend/images/avatar.png", "avatar");
    img.getStyle().set("width", "80px");
    img.getStyle().set("margin-top", "20px");
    H4 h4 = new H4("User");
    container.add(img, h4);
    return container;
}

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

/**
 * Component that renders the app toolbar
 *
 * @author mlopez
 */
@SuppressWarnings("serial")
@HtmlImport("bower_components/app-layout/app-toolbar/app-toolbar.html")
@HtmlImport("bower_components/iron-icons/iron-icons.html")
@NpmPackage(value = "@polymer/app-layout", version = AppLayout.NPM_VERSION)
@NpmPackage(value = "@polymer/iron-icons", version = "^3.0.0")
@JsModule("@polymer/app-layout/app-toolbar/app-toolbar.js")
@JsModule("@polymer/iron-icons/iron-icons.js")
@Tag("app-toolbar")
public clreplaced AppToolbar extends Component {

    private ToolbarIconButton menu;

    private Div divreplacedle;

    private int index;

    private HasOrderedComponents<AppToolbar> hasOrderedComponents = new HasOrderedComponents<AppToolbar>() {

        @Override
        public Element getElement() {
            return AppToolbar.this.getElement();
        }

        @Override
        public int getComponentCount() {
            return (int) getChildren().count();
        }

        @Override
        public Component getComponentAt(int index) {
            if (index < 0) {
                throw new IllegalArgumentException("The 'index' argument should be greater than or equal to 0. It was: " + index);
            }
            return getChildren().sequential().skip(index).findFirst().orElseThrow(() -> new IllegalArgumentException("The 'index' argument should not be greater than or equals to the number of children components. It was: " + index));
        }
    };

    public AppToolbar(String replacedle, AppDrawer drawer) {
        this(null, replacedle, drawer);
    }

    public AppToolbar(Image logo, String replacedle, AppDrawer drawer) {
        menu = new ToolbarIconButton().setIcon("menu");
        add(menu);
        drawer.getId().ifPresent(id -> menu.getElement().setAttribute("onclick", id + ".toggle()"));
        if (logo != null) {
            add(logo);
        }
        divreplacedle = new Div();
        divreplacedle.getElement().setAttribute("main-replacedle", true);
        setreplacedle(replacedle);
        add(divreplacedle);
        index = hasOrderedComponents.getComponentCount();
    }

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

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

    public void setreplacedle(String replacedle) {
        divreplacedle.setText(replacedle);
    }

    public void clearToolbarIconButtons() {
        while (hasOrderedComponents.getComponentCount() > index) {
            hasOrderedComponents.remove(hasOrderedComponents.getComponentAt(index));
        }
    }

    public void setMenuIconVisible(boolean visible) {
        menu.setVisible(visible);
    }

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

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

17 Source : PaperInputView.java
with MIT License
from mcollovati

private void showValue(String value) {
    Div div = new Div();
    div.setText(value);
    div.setClreplacedName("update-value");
    add(div);
}

17 Source : PolymerPropertyChangeEventView.java
with MIT License
from mcollovati

private void propertyChanged(PropertyChangeEvent event) {
    Div div = new Div();
    div.setText("New property value: '" + event.getValue() + "', old property value: '" + event.getOldValue() + "'");
    div.addClreplacedName("change-event");
    add(div);
}

17 Source : PolymerModelPropertiesView.java
with MIT License
from mcollovati

private Div addUpdateElement(String id) {
    Div div = new Div();
    div.setText("Property value:" + getElement().getProperty("text") + ", model value: " + getModel().getText());
    div.setId(id);
    return div;
}

17 Source : PolymerDefaultPropertyValueView.java
with MIT License
from mcollovati

private void createEmailValue(PolymerDefaultPropertyValue template) {
    Div div = new Div();
    div.setText(template.getEmail());
    div.setId("email-value");
    add(div);
}

17 Source : InjectScriptTagView.java
with MIT License
from mcollovati

@ClientCallable
private void changeValue() {
    getModel().setValue("<!-- <SCRIPT>");
    getElement().removeAllChildren();
    Div slot = new Div(new Text("<!-- <SCRIPT> --><!-- <SCRIPT></SCRIPT>"));
    slot.setId("slot-2");
    getElement().appendChild(slot.getElement());
}

17 Source : DnDView.java
with MIT License
from mcollovati

private Div createLane(String identifier) {
    Div lane = new Div();
    lane.add(identifier);
    lane.setId("lane-" + identifier);
    lane.getStyle().set("margin", "20px").set("border", "1px solid black").set("display", "inline-block");
    lane.setHeightFull();
    lane.setWidth("150px");
    return lane;
}

17 Source : DnDView.java
with MIT License
from mcollovati

private Div createDropLane(DropEffect dropEffect) {
    String identifier = dropEffect == null ? "no-effect" : dropEffect.toString();
    Div lane = createLane(identifier);
    DropTarget<Div> dropTarget = DropTarget.create(lane);
    dropTarget.setActive(true);
    if (dropEffect != null) {
        dropTarget.setDropEffect(dropEffect);
    }
    dropTarget.addDropListener(event -> addLogEntry("Drop: " + event.getEffectAllowed() + " " + event.getDropEffect() + (data ? (" " + event.getDragData()) : "")));
    return lane;
}

17 Source : AttachExistingElementView.java
with MIT License
from mcollovati

@Override
protected void onShow() {
    setId("root-div");
    add(createButton("Attach label", "attach-label", event -> getElement().getStateProvider().attachExistingElement(getElement().getNode(), "label", null, this::handleLabel)));
    add(createButton("Attach Header", "attach-header", event -> getElement().getStateProvider().attachExistingElement(getElement().getNode(), "h1", null, this::handleHeader)));
    Div div = new Div();
    div.setId("element-with-shadow");
    ShadowRoot shadowRoot = div.getElement().attachShadow();
    add(createButton("Attach label in shadow", "attach-label-inshadow", event -> shadowRoot.getStateProvider().attachExistingElement(shadowRoot.getNode(), "label", null, this::handleLabelInShadow)));
    add(createButton("Attach non-existing element", "non-existing-element", event -> getElement().getStateProvider().attachExistingElement(getElement().getNode(), "image", null, new NonExistingElementCallback())));
    add(div);
    getPage().executeJs("$0.appendChild(doreplacedent.createElement('label'));", shadowRoot);
    getPage().executeJs("$0.appendChild(doreplacedent.createElement('span')); $0.appendChild(doreplacedent.createElement('label'));" + "$0.appendChild(doreplacedent.createElement('h1'));", getElement());
}

17 Source : DependenciesLoadingBaseView.java
with MIT License
from mcollovati

private Div createDiv(String id, String text) {
    Div div = new Div();
    div.setId(id);
    div.setText(text);
    return div;
}

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

/**
 * Component that renders a paper-card
 *
 * @author mlopez
 */
@SuppressWarnings("serial")
@HtmlImport("bower_components/paper-card/paper-card.html")
@NpmPackage(value = "@polymer/paper-card", version = "3.0.1")
@JsModule("@polymer/paper-card/paper-card.js")
@Tag("paper-card")
public clreplaced PaperCard extends Component implements Hreplacedize, Hreplacedtyle, ThemableLayout {

    private final Div cardContentDiv = new Div();

    private final Div cardActionsDiv = new Div();

    @SuppressWarnings("squid:S1604")
    private final HasComponents hasComponentsVersion = new HasComponents() {

        @Override
        public Element getElement() {
            return PaperCard.this.getElement();
        }
    };

    public PaperCard() {
        this(null);
    }

    public PaperCard(final Component cardContent, final MenuItem... cardActions) {
        cardContentDiv.setClreplacedName("card-content");
        cardActionsDiv.setClreplacedName("card-actions");
        hasComponentsVersion.add(cardContentDiv);
        if (cardContent != null) {
            setCardContent(cardContent);
        }
        setCardActions(cardActions);
    }

    public void setCardActions(final MenuItem... cardActions) {
        if (cardActions.length > 0) {
            final List<Component> buttons = new ArrayList<>();
            for (final MenuItem menuItem : cardActions) {
                if (menuItem.getIcon() != null) {
                    buttons.add(menuItem);
                } else {
                    buttons.add(menuItem);
                }
            }
            final Div inner = new Div();
            cardActionsDiv.add(inner);
            inner.addClreplacedNames("horizontal", "justified");
            buttons.forEach(inner::add);
            hasComponentsVersion.add(cardActionsDiv);
        }
    }

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

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

public void setCardActions(final MenuItem... cardActions) {
    if (cardActions.length > 0) {
        final List<Component> buttons = new ArrayList<>();
        for (final MenuItem menuItem : cardActions) {
            if (menuItem.getIcon() != null) {
                buttons.add(menuItem);
            } else {
                buttons.add(menuItem);
            }
        }
        final Div inner = new Div();
        cardActionsDiv.add(inner);
        inner.addClreplacedNames("horizontal", "justified");
        buttons.forEach(inner::add);
        hasComponentsVersion.add(cardActionsDiv);
    }
}

16 Source : TitleView.java
with MIT License
from mcollovati

@Override
protected void onShow() {
    removeAll();
    Div replacedleView = new Div();
    replacedleView.setText("replacedle view");
    replacedleView.setId("annotated");
    add(replacedleView);
}

16 Source : SubPropertyModelTemplate.java
with MIT License
from mcollovati

@EventHandler
private void click(@ModelItem("status") Status statusItem) {
    Div div = new Div();
    div.setId("statusClick");
    div.setText(statusItem.getMessage());
    ((HasComponents) getParent().get()).add(div);
}

16 Source : SubPropertyModelTemplate.java
with MIT License
from mcollovati

@EventHandler
private void sync() {
    Div div = new Div();
    div.setId("synced-msg");
    div.setText(getStatus().getMessage());
    ((HasComponents) getParent().get()).add(div);
}

16 Source : SubPropertyModelTemplate.java
with MIT License
from mcollovati

@EventHandler
private void valueUpdated() {
    Div div = new Div();
    div.setId("value-update");
    div.setText(getStatus().getMessage());
    ((HasComponents) getParent().get()).add(div);
}

16 Source : ExceptionsDuringPropertyUpdatesView.java
with MIT License
from mcollovati

@Override
protected void onAttach(AttachEvent attachEvent) {
    if (attachEvent.isInitialAttach()) {
        attachEvent.getSession().setErrorHandler(e -> {
            Div div = new Div(new Text("An error occurred: " + e.getThrowable()));
            div.addClreplacedName("error");
            add(div);
        });
    }
}

16 Source : TwoWayListBindingView.java
with MIT License
from mcollovati

@EventHandler
private void valueUpdated() {
    Div div = new Div();
    div.setClreplacedName("messages");
    div.setText(getModel().getMessages().toString());
    add(div);
}

16 Source : ClearNodeChildrenView.java
with MIT License
from mcollovati

private void addDivTo(HasComponents container) {
    Div div = new Div();
    div.setText("Server div " + (container.getElement().getChildCount() + 1));
    div.addAttachListener(evt -> message.setText(message.getText() + "\nDiv '" + div.getText() + "' attached."));
    div.addDetachListener(evt -> message.setText(message.getText() + "\nDiv '" + div.getText() + "' detached."));
    container.add(div);
}

16 Source : ChildOrderView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.template.ChildOrderView", layout = ViewTestLayout.clreplaced)
@Tag("child-order-template")
@HtmlImport("frontend://com/vaadin/flow/uitest/ui/template/ChildOrderTemplate.html")
@JsModule("ChildOrderTemplate.js")
public clreplaced ChildOrderView extends PolymerTemplate<TemplateModel> {

    @Id
    private Div containerWithElement;

    @Id
    private Div containerWithText;

    @Id
    private Div containerWithElementAddedOnConstructor;

    @Id
    private NativeButton addChildToContainer1;

    @Id
    private NativeButton prependChildToContainer1;

    @Id
    private NativeButton removeChildFromContainer1;

    @Id
    private NativeButton addChildToContainer2;

    @Id
    private NativeButton prependChildToContainer2;

    @Id
    private NativeButton removeChildFromContainer2;

    public ChildOrderView() {
        setId("root");
        Div childOnConstructor1 = new Div();
        childOnConstructor1.setText("Server child " + (containerWithElementAddedOnConstructor.getElement().getChildCount() + 1));
        containerWithElementAddedOnConstructor.add(childOnConstructor1);
        Div childOnConstructor2 = new Div();
        childOnConstructor2.setText("Server child " + (containerWithElementAddedOnConstructor.getElement().getChildCount() + 1));
        containerWithElementAddedOnConstructor.add(childOnConstructor2);
        addChildToContainer1.addClickListener(event -> {
            Div div = new Div();
            div.setText("Server child " + (containerWithElement.getElement().getChildCount() + 1));
            containerWithElement.add(div);
        });
        prependChildToContainer1.addClickListener(event -> {
            Div div = new Div();
            div.setText("Server child " + (containerWithElement.getElement().getChildCount() + 1));
            containerWithElement.getElement().insertChild(0, div.getElement());
        });
        removeChildFromContainer1.addClickListener(event -> {
            if (containerWithElement.getElement().getChildCount() > 0) {
                containerWithElement.getElement().removeChild(containerWithElement.getElement().getChildCount() - 1);
            }
        });
        addChildToContainer2.addClickListener(event -> {
            Element text = Element.createText("\nServer text " + (containerWithText.getElement().getChildCount() + 1));
            containerWithText.getElement().appendChild(text);
        });
        prependChildToContainer2.addClickListener(event -> {
            Element text = Element.createText("\nServer text " + (containerWithText.getElement().getChildCount() + 1));
            containerWithText.getElement().insertChild(0, text);
        });
        removeChildFromContainer2.addClickListener(event -> {
            if (containerWithText.getElement().getChildCount() > 0) {
                containerWithText.getElement().removeChild(containerWithText.getElement().getChildCount() - 1);
            }
        });
    }
}

16 Source : DnDView.java
with MIT License
from mcollovati

private Div createBox(String identifier) {
    Div box = new Div();
    box.setText(identifier);
    box.setWidth("100px");
    box.setHeight("60px");
    box.getStyle().set("border", "1px solid").set("margin", "10px");
    box.setId("box-" + identifier);
    return box;
}

16 Source : BrowserWindowResizeView.java
with MIT License
from mcollovati

@Override
protected void onShow() {
    Div windowSize = new Div();
    windowSize.setId("size-info");
    getPage().addBrowserWindowResizeListener(event -> windowSize.setText(String.valueOf(event.getWidth())));
    add(windowSize);
}

16 Source : ResultUploadDialog.java
with Apache License 2.0
from kochetkov-ma

@Slf4j
public clreplaced ResultUploadDialog extends // NOPMD
Dialog {

    private static final long serialVersionUID = -4958469225519042248L;

    private final MemoryBuffer buffer;

    private final Upload upload;

    private final Div infoContainer;

    private final Button close = new Button("Ok", e -> onClickCloseAndDiscard());

    public ResultUploadDialog(AllureResultController allureResultController) {
        this.buffer = new MemoryBuffer();
        this.infoContainer = new Div();
        this.upload = new Upload(buffer);
        upload.setMaxFiles(1);
        upload.setDropLabel(new Label("Upload allure results as Zip archive (.zip)"));
        upload.setAcceptedFileTypes(".zip");
        upload.setMaxFileSize(5 * 1024 * 1024);
        upload.addSucceededListener(event -> {
            try {
                var uploadResponse = allureResultController.uploadResults(toMultiPartFile(buffer));
                show(info(format("File '{}- {} bytes' loaded: {}", event.getFileName(), event.getContentLength(), uploadResponse)), false);
            } catch (Exception ex) {
                // NOPMD
                show(error("Internal error: " + ex.getLocalizedMessage()), true);
                log.error("Uploading error", ex);
            }
        });
        upload.addFileRejectedListener(event -> {
            show(error("Reject: " + event.getErrorMessage()), true);
            if (log.isWarnEnabled()) {
                log.warn("Uploading rejected: " + event.getErrorMessage());
            }
        });
        configureDialog();
    }

    public void onClose(ComponentEventListener<DialogCloseActionEvent> listener) {
        addDialogCloseActionListener(listener);
    }

    public void addControlButton(final Button externalButton) {
        externalButton.addClickListener(event -> {
            if (isOpened()) {
                onClickCloseAndDiscard();
            } else {
                onClickOpenAndInit();
            }
        });
    }

    private void configureDialog() {
        setCloseOnEsc(true);
        setCloseOnOutsideClick(true);
        addDialogCloseActionListener(event -> {
            cleanInfo();
            close();
        });
        var replacedle = new H3("Upload result");
        add(replacedle, new VerticalLayout(upload, infoContainer, close));
    }

    private void onClickOpenAndInit() {
        cleanInfo();
        open();
    }

    private void onClickCloseAndDiscard() {
        super.fireEvent(new Dialog.DialogCloseActionEvent(this, true));
    }

    private MultipartFile toMultiPartFile(MemoryBuffer memoryBuffer) {
        return new MultipartFile() {

            @Override
            @Nonnull
            public String getName() {
                return memoryBuffer.getFileName();
            }

            @Override
            public String getOriginalFilename() {
                return memoryBuffer.getFileName();
            }

            @Override
            public String getContentType() {
                return memoryBuffer.getFileData().getMimeType();
            }

            @Override
            public boolean isEmpty() {
                return false;
            }

            @Override
            public long getSize() {
                try {
                    return getBytes().length;
                } catch (IOException e) {
                    return 0;
                }
            }

            @Override
            @Nonnull
            public byte[] getBytes() throws IOException {
                return IOUtils.toByteArray(getInputStream());
            }

            @Override
            @Nonnull
            public InputStream getInputStream() {
                return memoryBuffer.getInputStream();
            }

            @Override
            public void transferTo(@Nonnull File destination) {
                throw new UnsupportedOperationException("transferTo");
            }
        };
    }

    private Component info(String text) {
        var p = new Paragraph();
        p.getElement().setText(text);
        p.getElement().getStyle().set("color", "green");
        return p;
    }

    private Component error(String text) {
        var p = new Paragraph();
        p.getElement().setText(text);
        p.getElement().getStyle().set("color", "red");
        return p;
    }

    private void cleanInfo() {
        infoContainer.removeAll();
        upload.getElement().getStyle().remove("background");
    }

    private void show(Component component, boolean error) {
        cleanInfo();
        if (error) {
            upload.getElement().getStyle().set("background", "pink");
        }
        infoContainer.add(component);
    }
}

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

public Component build() {
    components.addAll(header);
    LeftMenuComponentWrapper menu = new LeftMenuComponentWrapper();
    components.addAll(body);
    if (sticky) {
        menu.getMenu().getStyle().set("display", "flex");
        Div div = new Div();
        div.setWidth("100%");
        div.setHeight("0px");
        div.getStyle().set("flex", "1 1");
        components.add(div);
    }
    components.addAll(footer);
    menu.add(components.toArray(new Component[0]));
    return menu;
}

16 Source : AbstractTwoComponentsCrudLayout.java
with Apache License 2.0
from alejandro-du

@Override
public void showDialog(String caption, Component form) {
    if (caption != null) {
        Div label = new Div(new Text(caption));
        label.getStyle().set("color", "var(--lumo-primary-text-color)");
        formCaptionLayout.removeAll();
        formCaptionLayout.add(label);
        secondComponent.addComponentAtIndex(secondComponent.getComponentCount() - 1, formCaptionLayout);
    } else if (formCaptionLayout.getElement().getParent() != null) {
        formCaptionLayout.getElement().getParent().removeChild(formCaptionLayout.getElement());
    }
    formComponentLayout.removeAll();
    formComponentLayout.add(form);
}

15 Source : HiddenTemplateView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.template.HiddenTemplateView", layout = ViewTestLayout.clreplaced)
@Tag("hidden-template")
@HtmlImport("frontend://com/vaadin/flow/uitest/ui/template/HiddenTemplate.html")
@JsModule("HiddenTemplate.js")
public clreplaced HiddenTemplateView extends PolymerTemplate<TemplateModel> {

    @Id("child")
    private Div div;

    public HiddenTemplateView() {
        setId("template");
    }

    @EventHandler
    private void updateVisibility() {
        div.setVisible(!div.isVisible());
    }
}

15 Source : ClearNodeChildrenView.java
with MIT License
from mcollovati

@Route(value = "com.vaadin.flow.uitest.ui.template.ClearNodeChildrenView", layout = ViewTestLayout.clreplaced)
@Tag("clear-node-children")
@HtmlImport("frontend://com/vaadin/flow/uitest/ui/template/ClearNodeChildren.html")
@JsModule("ClearNodeChildren.js")
public clreplaced ClearNodeChildrenView extends PolymerTemplate<TemplateModel> implements HasComponents, HasText {

    @Id
    private Div containerWithElementChildren;

    @Id
    private Div containerWithMixedChildren;

    @Id
    private Div containerWithClientSideChildren;

    @Id
    private Div containerWithSlottedChildren;

    @Id
    private Div containerWithContainer;

    @Id
    private Div nestedContainer;

    @Id
    private NativeButton addChildToContainer1;

    @Id
    private NativeButton addTextNodeToContainer1;

    @Id
    private NativeButton clearContainer1;

    @Id
    private NativeButton addChildToContainer2;

    @Id
    private NativeButton clearContainer2;

    @Id
    private NativeButton addChildToContainer3;

    @Id
    private NativeButton clearContainer3;

    @Id
    private NativeButton addChildToNestedContainer;

    @Id
    private NativeButton clearContainer4;

    @Id
    private NativeButton addChildToSlot;

    @Id
    private NativeButton clear;

    @Id
    private NativeButton setTextToContainer1;

    @Id
    private NativeButton setTextToContainer2;

    @Id
    private NativeButton setTextToContainer3;

    @Id
    private NativeButton setTextToContainer4;

    @Id
    private NativeButton setText;

    @Id
    private Div message;

    public ClearNodeChildrenView() {
        setId("root");
        addChildToContainer1.addClickListener(event -> addDivTo(containerWithElementChildren));
        addChildToContainer2.addClickListener(event -> addDivTo(containerWithMixedChildren));
        addChildToContainer3.addClickListener(event -> addDivTo(containerWithClientSideChildren));
        addChildToNestedContainer.addClickListener(event -> addDivTo(nestedContainer));
        addChildToSlot.addClickListener(event -> addDivTo(this));
        clearContainer1.addClickListener(event -> clear(containerWithElementChildren, "containerWithElementChildren"));
        clearContainer2.addClickListener(event -> clear(containerWithMixedChildren, "containerWithMixedChildren"));
        clearContainer3.addClickListener(event -> clear(containerWithClientSideChildren, "containerWithClientSideChildren"));
        clearContainer4.addClickListener(event -> clear(containerWithContainer, "containerWithContainer"));
        setTextToContainer1.addClickListener(event -> setTextTo(containerWithElementChildren, "containerWithElementChildren"));
        setTextToContainer2.addClickListener(event -> setTextTo(containerWithMixedChildren, "containerWithMixedChildren"));
        setTextToContainer3.addClickListener(event -> setTextTo(containerWithClientSideChildren, "containerWithClientSideChildren"));
        setTextToContainer4.addClickListener(event -> setTextTo(containerWithContainer, "containerWithContainer"));
        clear.addClickListener(event -> clear(this, "root"));
        setText.addClickListener(event -> setTextTo(this, "root"));
        addTextNodeToContainer1.addClickListener(event -> {
            Element text = Element.createText("Text node");
            containerWithElementChildren.getElement().appendChild(text);
            message.setText("Added 'Text node' to div with id 'containerWithElementChildren'.");
        });
    }

    private void addDivTo(HasComponents container) {
        Div div = new Div();
        div.setText("Server div " + (container.getElement().getChildCount() + 1));
        div.addAttachListener(evt -> message.setText(message.getText() + "\nDiv '" + div.getText() + "' attached."));
        div.addDetachListener(evt -> message.setText(message.getText() + "\nDiv '" + div.getText() + "' detached."));
        container.add(div);
    }

    private void clear(HasComponents container, String id) {
        container.removeAll();
        message.setText(message.getText() + "\nDiv '" + id + "' cleared.");
    }

    private void setTextTo(HasText container, String id) {
        container.setText("Hello World");
        message.setText(message.getText() + "\nDiv '" + id + "' text set to '" + container.getText() + "'.");
    }
}

15 Source : DnDView.java
with MIT License
from mcollovati

private Component createDraggableBox(EffectAllowed effectAllowed) {
    String identifier = effectAllowed == null ? NO_EFFECT_SETUP : effectAllowed.toString();
    Div box = createBox(identifier);
    DragSource<Div> dragSource = DragSource.create(box);
    dragSource.setDraggable(true);
    if (effectAllowed != null) {
        dragSource.setEffectAllowed(effectAllowed);
    }
    dragSource.addDragStartListener(event -> {
        addLogEntry("Start: " + event.getComponent().getText());
        if (data) {
            dragSource.setDragData(identifier);
        }
    });
    dragSource.addDragEndListener(event -> {
        addLogEntry("End: " + event.getComponent().getText() + " " + event.getDropEffect());
    });
    return box;
}

15 Source : CompositeNestedView.java
with MIT License
from mcollovati

@Override
protected Div initContent() {
    Div div = new Div();
    nameField = new NameField();
    nameField.setId(NAME_FIELD_ID);
    Div name = new Div();
    name.setText("Name on server: " + nameField.getName());
    name.setId(NAME_ID);
    nameField.addNameChangeListener(e -> {
        name.setText("Name on server: " + nameField.getName());
    });
    div.add(name, nameField);
    return div;
}

15 Source : LeftSubmenu.java
with Apache License 2.0
from appreciated

/**
 * The component which is used for submenu webcomponents. On click it toggles a css clreplaced which causes it to grow / shrink
 */
public clreplaced LeftSubmenu extends Composite<IronCollapseLayout> implements NavigationElementContainer, AfterNavigationObserver, BeforeLeaveObserver {

    private static final long serialVersionUID = 1L;

    private final LeftSubmenuContainer submenuContainer;

    private final Div toggleWrapper;

    private final LeftIconItem item;

    private final IronIcon ironIcon;

    private final String caption;

    private final Component icon;

    private NavigationElementContainer parent;

    private NavigationElement active;

    private boolean close = true;

    public LeftSubmenu(String caption, Component icon, List<Component> submenuElements) {
        submenuContainer = new LeftSubmenuContainer();
        submenuContainer.getStyle().set("border-radius", "var(--app-layout-menu-button-border-radius)").set("background", "var(--app-layout-drawer-submenu-background-color)");
        getSubmenuContainer().add(submenuElements.toArray(new Component[] {}));
        applyParentToItems(submenuElements.stream());
        toggleWrapper = new Div();
        toggleWrapper.getStyle().set("position", "relative");
        item = new LeftIconItem(caption, icon);
        item.setHighlightCondition((routerLink, event) -> false);
        item.setHighlightAction((routerLink, highlight) -> {
        });
        ironIcon = new IronIcon("vaadin", "chevron-down-small");
        ironIcon.addClreplacedName("collapse-icon");
        ironIcon.getElement().getStyle().set("fill", "var(--expand-icon-fill-color)").set("position", "absolute").set("right", "var(--app-layout-menu-toggle-button-padding)").set("top", "50%").set("transform", "translate(0%, -50%) rotate(0deg)").set("transition", "transform 0.3s ease").set("pointer-events", "none");
        item.add(ironIcon);
        toggleWrapper.add(item);
        getContent().getElement().appendChild(toggleWrapper.getElement());
        getContent().addCollapsibleContent(submenuContainer);
        getContent().getElement().getStyle().set("width", "100%");
        this.caption = caption;
        this.icon = icon;
    }

    public LeftSubmenuContainer getSubmenuContainer() {
        return submenuContainer;
    }

    public Component getIcon() {
        return icon;
    }

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

    @Override
    public void setActiveNavigationElement(NavigationElement active) {
        if (active != null) {
            this.active = active;
        }
        if (this.parent != null) {
            parent.setActiveNavigationElement(active);
        }
    }

    public String getCaption() {
        return caption;
    }

    public LeftIconItem gereplacedem() {
        return item;
    }

    public IronIcon getIronIcon() {
        return ironIcon;
    }

    public void setCloseMenuOnNavigation(boolean close) {
        this.close = close;
    }

    public LeftSubmenu withCloseMenuOnNavigation(boolean close) {
        this.close = close;
        return this;
    }

    @Override
    public void afterNavigation(AfterNavigationEvent event) {
        if (active != null) {
            item.getElement().setAttribute("highlight", true);
        } else {
            item.getElement().removeAttribute("highlight");
            if (this.close) {
                getContent().getIronCollapse().hide();
            }
        }
    }

    @Override
    public void beforeLeave(BeforeLeaveEvent event) {
        this.active = null;
    }
}

See More Examples