private void registerLifecycleOwner(Component owner) { assert owner != null; lifecycleOwner = owner; // since we are attached, UI should be available Registration attachRegistration = owner.addAttachListener(e -> queueBeforeExecutionCallback()); // remove shortcut listener when detached Registration detachRegistration = owner.addDetachListener(e -> removeListenerRegistration()); lifecycleRegistration = new CompoundRegistration(attachRegistration, detachRegistration); }
/** * Gets the root element of this composite. * <p> * For a composite, the root element is the same as the root element of the * content of the composite. * * @return the root element of this component */ @Override public Element getElement() { return getContent().getElement(); }
/** * Gets the property value for the given component. * * @param hasElement * the component for which to get the value, not * <code>null</code> * @return the property value */ default G get(HasElement hasElement) { assert hasElement != null; return get(hasElement.getElement()); }
@SuppressWarnings("unchecked") private <T extends ComponentEvent<?>> void fireEventForListener(T event, ListenerWrapper<T> wrapper) { Class<T> eventType = (Class<T>) event.getClass(); event.setUnregisterListenerCommand(() -> { removeListener(eventType, wrapper); }); wrapper.listener.onComponentEvent(event); event.setUnregisterListenerCommand(null); }
@DomEvent("change") public static class ChangeEvent<R extends GeneratedVaadinTextArea<R, ?>> extends ComponentEvent<R> { public ChangeEvent(R source, boolean fromClient) { super(source, fromClient); } }
/** * Sets the property value for the given component. * * @param hasElement * the component for which to set the value, not * <code>null</code> * @param value * the property value to set */ default void set(HasElement hasElement, S value) { assert hasElement != null; set(hasElement.getElement(), value); }
/** * Removes the width and the height of the component. * <p> * This is just a convenience method which delegates its call to the * {@link #setWidth(String)} and {@link #setHeight(String)} methods with * {@literal null} as the argument value */ default void setSizeUndefined() { setWidth(null); setHeight(null); } }
private void removeAllListenerRegistrations() { if (listenOnAttachListenerRegistration != null) { listenOnAttachListenerRegistration.remove(); listenOnAttachListenerRegistration = null; } removeListenerRegistration(); listenOnComponent = null; }
private void setLifecycleOwner(Component owner) { assert owner != null; if (lifecycleRegistration != null) { lifecycleRegistration.remove(); } registerLifecycleOwner(owner); }
/** * Sets the height of the component to "100%". * <p> * This is just a convenience method which delegates its call to the * {@link #setHeight(String)} with * {@literal "100%"} as the argument value */ default void setHeightFull() { setHeight("100%"); }
@Override public DefaultKeyNotifierConfigurator withKeyUpListener(Key key, ComponentEventListener<KeyUpEvent> listener, KeyModifier... modifiers) { component.addKeyUpListener(key, listener, modifiers); return this; }
/** * Sets the id of the root element of this component. The id is used with * various APIs to identify the element, and it should be unique on the * page. * * @param id * the id to set, or <code>""</code> to remove any previously set * id */ public void setId(String id) { set(idDescriptor, id); }
/** * Gets the {@link ThemeDefinition} associated with the * pageConfigurationHolder of this context, if any. * * @return the theme definition, or empty if none is found, or * pageConfigurationHolder is <code>null</code> * @see UI#getThemeFor(Class, String) */ protected Optional<ThemeDefinition> getTheme() { return ui.getThemeFor(pageConfigurationHolder, null); } }
private TypeHandler(ElementSetter<P> setter, ElementGetter<P> getter, P typeDefault) { this.setter = setter; this.getter = (element, propertyName) -> getter.getValue(element, propertyName, typeDefault); }
@Override public DefaultCompositionNotifierConfigurator withCompositionEndListener( ComponentEventListener<CompositionEndEvent> listener) { component.addCompositionEndListener(listener); return this; }
@DomEvent("iron-resize") public static class IronResizeEvent<R extends GeneratedVaadinSplitLayout<R>> extends ComponentEvent<R> { public IronResizeEvent(R source, boolean fromClient) { super(source, fromClient); } }
public SeriesAfterAnimateEvent(Chart source, boolean fromClient, @EventData("event.detail.originalEvent.target.index") int seriesIndex) { super(source, fromClient); this.seriesIndex = seriesIndex; }
public SeriesHideEvent(Chart source, boolean fromClient, @EventData("event.detail.originalEvent.target.index") int seriesIndex) { super(source, fromClient); this.seriesIndex = seriesIndex; }