Class Dialog

    • Constructor Detail

      • Dialog

        public Dialog()
        Creates an empty dialog.
      • Dialog

        public Dialog​(Component... components)
        Creates a dialog with given components inside.
        Parameters:
        components - the components inside the dialog
        See Also:
        add(Component...)
    • Method Detail

      • setWidth

        public void setWidth​(String value)
        Description copied from interface: HasSize
        Sets the width of the component.

        The width should be in a format understood by the browser, e.g. "100px" or "2.5em".

        If the provided width value is null then width is removed.

        Specified by:
        setWidth in interface HasSize
        Parameters:
        value - the width to set, may be null
      • setMinWidth

        public void setMinWidth​(String value)
        Description copied from interface: HasSize
        Sets the min-width of the component.

        The width should be in a format understood by the browser, e.g. "100px" or "2.5em".

        If the provided minWidth value is null then min-width is removed.

        Specified by:
        setMinWidth in interface HasSize
        Parameters:
        value - the min-width value (if null, the property will be removed)
      • setMaxWidth

        public void setMaxWidth​(String value)
        Description copied from interface: HasSize
        Sets the max-width of the component.

        The width should be in a format understood by the browser, e.g. "100px" or "2.5em".

        If the provided maxWidth value is null then max-width is removed.

        Specified by:
        setMaxWidth in interface HasSize
        Parameters:
        value - the max-width value (if null, the property will be removed)
      • setHeight

        public void setHeight​(String value)
        Description copied from interface: HasSize
        Sets the height of the component.

        The height should be in a format understood by the browser, e.g. "100px" or "2.5em".

        If the provided height value is null then height is removed.

        Specified by:
        setHeight in interface HasSize
        Parameters:
        value - the height to set, may be null
      • setMinHeight

        public void setMinHeight​(String value)
        Description copied from interface: HasSize
        Sets the min-height of the component.

        The height should be in a format understood by the browser, e.g. "100px" or "2.5em".

        If the provided minHeight value is null then min-height is removed.

        Specified by:
        setMinHeight in interface HasSize
        Parameters:
        value - the min-height value (if null, the property will be removed)
      • setMaxHeight

        public void setMaxHeight​(String value)
        Description copied from interface: HasSize
        Sets the max-height of the component.

        The height should be in a format understood by the browser, e.g. "100px" or "2.5em".

        If the provided maxHeight value is null then max-height is removed.

        Specified by:
        setMaxHeight in interface HasSize
        Parameters:
        value - the max-height value (if null, the property will be removed)
      • getWidth

        public String getWidth()
        Description copied from interface: HasSize
        Gets the width defined for the component.

        Note that this does not return the actual size of the component but the width which has been set using HasSize.setWidth(String).

        Specified by:
        getWidth in interface HasSize
        Returns:
        the width which has been set for the component
      • getMinWidth

        public String getMinWidth()
        Description copied from interface: HasSize
        Gets the min-width defined for the component.

        Note that this does not return the actual size of the component but the min-width which has been set using HasSize.setMinWidth(String).

        Specified by:
        getMinWidth in interface HasSize
        Returns:
        the min-width which has been set for the component
      • getMaxWidth

        public String getMaxWidth()
        Description copied from interface: HasSize
        Gets the max-width defined for the component.

        Note that this does not return the actual size of the component but the max-width which has been set using HasSize.setMaxWidth(String).

        Specified by:
        getMaxWidth in interface HasSize
        Returns:
        the max-width which has been set for the component
      • getHeight

        public String getHeight()
        Description copied from interface: HasSize
        Gets the height defined for the component.

        Note that this does not return the actual size of the component but the height which has been set using HasSize.setHeight(String).

        Specified by:
        getHeight in interface HasSize
        Returns:
        the height which has been set for the component
      • getMinHeight

        public String getMinHeight()
        Description copied from interface: HasSize
        Gets the min-height defined for the component.

        Note that this does not return the actual size of the component but the min-height which has been set using HasSize.setMinHeight(String).

        Specified by:
        getMinHeight in interface HasSize
        Returns:
        the min-height which has been set for the component
      • getMaxHeight

        public String getMaxHeight()
        Description copied from interface: HasSize
        Gets the max-height defined for the component.

        Note that this does not return the actual size of the component but the max-height which has been set using HasSize.setMaxHeight(String).

        Specified by:
        getMaxHeight in interface HasSize
        Returns:
        the max-height which has been set for the component
      • addDialogCloseActionListener

        public Registration addDialogCloseActionListener​(ComponentEventListener<Dialog.DialogCloseActionEvent> listener)
        Add a listener that controls whether the dialog should be closed or not.

        The listener is informed when the user wants to close the dialog by clicking outside the dialog, or by pressing escape. Then you can decide whether to close or to keep opened the dialog. It means that dialog won't be closed automatically unless you call close() method explicitly in the listener implementation.

        NOTE: adding this listener changes behavior of the dialog. Dialog is closed automatically in case there are no any close listeners. And the close() method should be called explicitly to close the dialog in case there are close listeners.

        Parameters:
        listener -
        Returns:
        registration for removal of listener
        See Also:
        close()
      • addResizeListener

        public Registration addResizeListener​(ComponentEventListener<Dialog.DialogResizeEvent> listener)
        Adds a listener that is called after user finishes resizing the overlay. It is called only if resizing is enabled (see setResizable(boolean)).

        Note: By default, the component will sync the width/height values after every resizing.

        Parameters:
        listener -
        Returns:
        registration for removal of listener
      • add

        public void add​(Component... components)
        Adds the given components into this dialog.

        The elements in the DOM will not be children of the <vaadin-dialog> element, but will be inserted into an overlay that is attached into the <body>.

        Specified by:
        add in interface HasComponents
        Parameters:
        components - the components to add
      • remove

        public void remove​(Component... components)
        Description copied from interface: HasComponents
        Removes the given child components from this component.
        Specified by:
        remove in interface HasComponents
        Parameters:
        components - the components to remove
      • removeAll

        public void removeAll()
        Description copied from interface: HasComponents
        Removes all contents from this component, this includes child components, text content as well as child elements that have been added directly to this component using the Element API. it also removes the children that were added only at the client-side.
        Specified by:
        removeAll in interface HasComponents
      • addComponentAtIndex

        public void addComponentAtIndex​(int index,
                                        Component component)
        Adds the given component into this dialog at the given index.

        The element in the DOM will not be child of the <vaadin-dialog> element, but will be inserted into an overlay that is attached into the <body>.

        Specified by:
        addComponentAtIndex in interface HasComponents
        Parameters:
        index - the index, where the component will be added.
        component - the component to add
      • isCloseOnEsc

        public boolean isCloseOnEsc()
        Gets whether this dialog can be closed by hitting the esc-key or not.

        By default, the dialog is closable with esc.

        Returns:
        true if this dialog can be closed with the esc-key, false otherwise
      • setCloseOnEsc

        public void setCloseOnEsc​(boolean closeOnEsc)
        Sets whether this dialog can be closed by hitting the esc-key or not.

        By default, the dialog is closable with esc.

        Parameters:
        closeOnEsc - true to enable closing this dialog with the esc-key, false to disable it
      • isCloseOnOutsideClick

        public boolean isCloseOnOutsideClick()
        Gets whether this dialog can be closed by clicking outside of it or not.

        By default, the dialog is closable with an outside click.

        Returns:
        true if this dialog can be closed by an outside click, false otherwise
      • setCloseOnOutsideClick

        public void setCloseOnOutsideClick​(boolean closeOnOutsideClick)
        Sets whether this dialog can be closed by clicking outside of it or not.

        By default, the dialog is closable with an outside click.

        Parameters:
        closeOnOutsideClick - true to enable closing this dialog with an outside click, false to disable it
      • open

        public void open()
        Opens the dialog.

        Note: You don't need to add the dialog component anywhere before opening it. Since <vaadin-dialog>'s location in the DOM doesn't really matter, opening a dialog will automatically add it to the <body> if necessary.

      • close

        public void close()
        Closes the dialog.

        Note: This method also removes the dialog component from the DOM after closing it, unless you have added the component manually.

      • setModal

        public void setModal​(boolean modal)
        Sets whether component will open modal or modeless dialog.

        Note: When dialog is set to be modeless, then it's up to you to provide means for it to be closed (eg. a button that calls close()). The reason being that a modeless dialog allows user to interact with the interface under it and won't be closed by clicking outside or the ESC key.

        Parameters:
        modal - false to enable dialog to open as modeless modal, true otherwise.
      • isModal

        public boolean isModal()
        Gets whether component is set as modal or modeless dialog.
        Returns:
        true if modal dialog (default), false otherwise.
      • setDraggable

        public void setDraggable​(boolean draggable)
        Sets whether dialog is enabled to be dragged by the user or not.

        To allow an element inside the dialog to be dragged by the user (for instance, a header inside the dialog), a class "draggable" can be added to it (see HasStyle.addClassName(String)).

        Note: If draggable is enabled and dialog is opened without first being explicitly attached to a parent, then it won't restore its last position in the case the user closes and opens it again. Reason being that a self attached dialog is removed from the DOM when it's closed and position is not synched.

        Parameters:
        draggable - true to enable dragging of the dialog, false otherwise
      • isDraggable

        public boolean isDraggable()
        Gets whether dialog is enabled to be dragged or not.
        Returns:
        true if dragging is enabled, false otherwise (default).
      • setResizable

        public void setResizable​(boolean resizable)
        Sets whether dialog can be resized by user or not.
        Parameters:
        resizable - true to enabled resizing of the dialog, false otherwise.
      • isResizable

        public boolean isResizable()
        Gets whether dialog is enabled to be resized or not.
        Returns:
        true if resizing is enabled, falsoe otherwiser (default).
      • setVisible

        public void setVisible​(boolean visible)
        Set the visibility of the dialog.

        For a modal dialog the server-side modality will be removed when dialog is not visible so that interactions can be made in the application.

        Overrides:
        setVisible in class Component
        Parameters:
        visible - dialog visibility
        See Also:
        Component.setVisible(boolean)
      • setOpened

        public void setOpened​(boolean opened)
        Opens or closes the dialog.

        Note: You don't need to add the dialog component anywhere before opening it. Since <vaadin-dialog>'s location in the DOM doesn't really matter, opening a dialog will automatically add it to the <body> if necessary.

        Overrides:
        setOpened in class GeneratedVaadinDialog<Dialog>
        Parameters:
        opened - true to open the dialog, false to close it
      • isOpened

        public boolean isOpened()
        Gets the open state from the dialog.
        Returns:
        the opened property from the dialog
      • getChildren

        public Stream<Component> getChildren()
        Description copied from class: Component
        Gets the child components of this component.

        The default implementation finds child components by traversing each child Element tree.

        If the component is injected to a PolymerTemplate using the @Id annotation the getChildren method will only return children added from the server side and will not return any children declared in the template file.

        Overrides:
        getChildren in class Component
        Returns:
        the child components of this component
        See Also:
        Id
      • addThemeVariants

        public void addThemeVariants​(DialogVariant... variants)
        Adds theme variants to the component.
        Parameters:
        variants - theme variants to add
      • removeThemeVariants

        public void removeThemeVariants​(DialogVariant... variants)
        Removes theme variants from the component.
        Parameters:
        variants - theme variants to remove
      • onAttach

        protected void onAttach​(AttachEvent attachEvent)
        Description copied from class: Component
        Called when the component is attached to a UI.

        The default implementation does nothing.

        This method is invoked before the AttachEvent is fired for the component.

        Overrides:
        onAttach in class Component
        Parameters:
        attachEvent - the attach event