private void queueBeforeExecutionCallback() { if (lifecycleOwner == null || !lifecycleOwner.getUI().isPresent()) { return; } if (executionRegistration != null) { executionRegistration.remove(); } executionRegistration = lifecycleOwner.getUI().get() .beforeClientResponse(lifecycleOwner, beforeClientResponseConsumer); }
private void runBeforeClientResponse(Consumer<UI> command) { getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> command.accept(ui))); }
private void runBeforeClientResponse(SerializableConsumer<UI> command) { getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> command.accept(ui))); } }
@Override protected void onAttach(AttachEvent attachEvent) { super.onAttach(attachEvent); attachEvent.getUI().beforeClientResponse(this, context -> { drawChart(); if (configuration != null) { // Start listening to data series events once the chart has been // drawn. configuration.addChangeListener(changeListener); } }); }
void runBeforeClientResponse(SerializableConsumer<UI> command) { getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> command.accept(ui))); }
private void runBeforeClientResponse(SerializableConsumer<UI> command) { getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> command.accept(ui))); }
void runBeforeClientResponse(SerializableConsumer<UI> command) { getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> command.accept(ui))); }
void runBeforeClientResponse(SerializableConsumer<UI> command) { getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> command.accept(ui))); }
private void attachComponentTemplate() { deferredJob = new AttachComponentTemplate(); getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> deferredJob.accept(ui))); } }
private void beforeOpen() { if (getElement().getNode().getParent() == null) { UI ui = getCurrentUI(); ui.beforeClientResponse(ui, context -> { ui.add(this); autoAddedToTheUi = true; }); } }
private void ensureAttached() { if (getElement().getNode().getParent() == null) { UI ui = getCurrentUI(); ui.beforeClientResponse(ui, context -> { ui.add(this); autoAddedToTheUi = true; }); } } }
@Override protected void onAttach(AttachEvent attachEvent) { getElement().getNode().runWhenAttached(ui -> ui.beforeClientResponse( this, context -> ui.getPage().executeJavaScript( "$0.addEventListener('items-changed', " + "function(){ this.$server.updateSelectedTab(true); });", getElement()))); }
/** * Opens or closes the notification. * <p> * Note: You don't need to add the component anywhere before opening it. * Since {@code <vaadin-notification>}'s location in the DOM doesn't really * matter, opening a notification will automatically add it to the * {@code <body>} if it's not yet attached anywhere. * * @param opened * {@code true} to open the notification, {@code false} to close * it */ @Override public void setOpened(boolean opened) { UI ui = UI.getCurrent(); if (ui == null) { throw new IllegalStateException("UI instance is not available. " + "It means that you are calling this method " + "out of a normal workflow where it's always implicitely set. " + "That may happen if you call the method from the custom thread without " + "'UI::access' or from tests without proper initialization."); } if (opened && getElement().getNode().getParent() == null) { ui.beforeClientResponse(ui, context -> { ui.add(this); autoAddedToTheUi = true; }); } super.setOpened(opened); }
/** * Default constructor. Create an empty notification with component support * and non-auto-closing * <p> * Note: To mix text and child components in notification that also supports * child components, use the {@link Text} component for the textual parts. */ public Notification() { initBaseElementsAndListeners(); getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> deferredJob.accept(ui))); setPosition(DEFAULT_POSITION); setDuration(0); }
/** * Sets the checked state of this item. A checked item displays a checkmark * icon next to it. The checked state is also toggled by clicking the item. * <p> * Note that the item needs to be explicitly set as checkable via * {@link #setCheckable(boolean)} in order to check it. * * @param checked * {@code true} to check this item, {@code false} to un-check it * @throws IllegalStateException * if trying to check the item when it's checkable */ public void setChecked(boolean checked) { if (isChecked() == checked) { return; } if (!checkable && checked) { throw new IllegalStateException( "Trying to set a non-checkable menu item checked. " + "Use setCheckable() to make the item checkable first."); } getElement().setProperty("_checked", checked); getElement().getNode().runWhenAttached( ui -> ui.beforeClientResponse(this, context -> { ui.getPage().executeJavaScript( "window.Vaadin.Flow.contextMenuConnector.setChecked($0, $1)", getElement(), checked); })); }
ui -> ui.beforeClientResponse(this, context -> ui.getPage() .executeJavaScript("$0.listenOn=$1", this, target))); ui -> ui.beforeClientResponse(target, context -> { ui.getInternals() .addComponentDependencies(ContextMenuBase.class);