Class ComponentUtilsKt

    • Constructor Detail

    • Method Detail

      • fireEvent

         final static Unit fireEvent(Component $self, ComponentEvent<?> event)

        Fires given event on the component.

      • serverClick

         final static <T extends ClickNotifier<?>> Unit serverClick(T $self, Boolean fromClient, Integer button, Integer clickCount, Boolean shiftKey, Boolean ctrlKey, Boolean altKey, Boolean metaKey)

        Adds com.vaadin.flow.component.button.Button.click functionality to all ClickNotifiers. This function directly calls all click listeners, thus it avoids the roundtrip to client and back. It even works with browserless testing.

        Parameters:
        fromClient - see ComponentEvent.isFromClient, defaults to true.
        button - see ClickEvent.getButton, defaults to 0.
        clickCount - see ClickEvent.getClickCount, defaults to 1.
      • addContextMenuListener

         final static DomListenerRegistration addContextMenuListener(Component $self, DomEventListener listener)

        Adds the right-click (context-menu) listener to the component. Also causes the right-click browser menu not to be shown on this component (see preventDefault).

      • preventDefault

         final static DomListenerRegistration preventDefault(DomListenerRegistration $self)

        Makes the client-side listener call Event.preventDefault() on the event.

        Returns:

        this

      • removeFromParent

         final static Unit removeFromParent(Component $self)

        Removes the component from its parent. Does nothing if the component is not attached to a parent.

      • findAncestor

         final static Component findAncestor(Component $self, Function1<Component, Boolean> predicate)

        Finds component's parent, parent's parent (etc) which satisfies given predicate. Returns null if there is no such parent.

      • findAncestorOrSelf

         final static Component findAncestorOrSelf(Component $self, Function1<Component, Boolean> predicate)

        Finds component, component's parent, parent's parent (etc) which satisfies given predicate. Returns null if no component on the ancestor-or-self axis satisfies.

      • isNestedIn

         final static Boolean isNestedIn(Component $self, Component potentialAncestor)

        Checks if this component is nested in potentialAncestor.

      • isAttached

         final static Boolean isAttached(Component $self)

        Checks whether this component is currently attached to a UI.

        Returns true for attached components even if the UI itself is closed.

      • insertBefore

         final static Unit insertBefore(HasOrderedComponents $self, Component newComponent, Component existing)

        Inserts this component as a child, right before an existing one.

        In case the specified component has already been added to another parent, it will be removed from there and added to this one.

      • addClassNames2

         final static Unit addClassNames2(HasStyle $self, String classNames)

        Splits classNames by whitespaces to obtain individual class names, then calls HasStyle.addClassName on each class name. Does nothing if the string is blank.

      • addClassNames2

         final static Unit addClassNames2(HasStyle $self, String classNames)

        Splits classNames by whitespaces to obtain individual class names, then calls addClassNames2 on each class name. Does nothing if the string is blank.

      • removeClassNames2

         final static Unit removeClassNames2(HasStyle $self, String classNames)

        Splits classNames by whitespaces to obtain individual class names, then calls removeClassNames2 on each class name. Does nothing if the string is blank.

      • setClassNames2

         final static Unit setClassNames2(HasStyle $self, String classNames)

        Splits classNames by whitespaces to obtain individual class names, then clears the class names and calls addClassNames2 on each class name. Does nothing if the string is blank.

      • setClassNames2

         final static Unit setClassNames2(HasStyle $self, String classNames)

        Splits classNames by whitespaces to obtain individual class names, then clears the class names and calls addClassNames2 on each class name. Does nothing if the string is blank.