Class StackPanel

    • Constructor Detail

      • StackPanel

        public StackPanel()
        Creates an empty stack panel.
    • Method Detail

      • add

        public void add​(Widget w)
        Description copied from class: Panel
        Adds a child widget.

        How to Override this Method

        There are several important things that must take place in the correct order to properly add or insert a Widget to a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.

        1. Validate: Perform any sanity checks to ensure the Panel can accept a new Widget. Examples: checking for a valid index on insertion; checking that the Panel is not full if there is a max capacity.
        2. Adjust for Reinsertion: Some Panels need to handle the case where the Widget is already a child of this Panel. Example: when performing a reinsert, the index might need to be adjusted to account for the Widget's removal. See ComplexPanel.adjustIndex(Widget, int).
        3. Detach Child: Remove the Widget from its existing parent, if any. Most Panels will simply call Widget.removeFromParent() on the Widget.
        4. Logical Attach: Any state variables of the Panel should be updated to reflect the addition of the new Widget. Example: the Widget is added to the Panel's WidgetCollection at the appropriate index.
        5. Physical Attach: The Widget's Element must be physically attached to the Panel's Element, either directly or indirectly.
        6. Adopt: Call Panel.adopt(Widget) to finalize the add as the very last step.

        Specified by:
        add in interface HasWidgets
        Specified by:
        add in interface InsertPanel
        Overrides:
        add in class Panel
        Parameters:
        w - the widget to be added
        See Also:
        HasWidgets.add(Widget)
      • add

        public void add​(Widget w,
                        java.lang.String stackText)
        Adds a new child with the given widget and header.
        Parameters:
        w - the widget to be added
        stackText - the header text associated with this widget
      • add

        public void add​(Widget w,
                        SafeHtml stackHtml)
        Adds a new child with the given widget and header, optionally interpreting the header as HTML.
        Parameters:
        w - the widget to be added
        stackHtml - the header html associated with this widget
      • add

        public void add​(Widget w,
                        java.lang.String stackText,
                        boolean asHTML)
        Adds a new child with the given widget and header, optionally interpreting the header as HTML.
        Parameters:
        w - the widget to be added
        stackText - the header text associated with this widget
        asHTML - true to treat the specified text as HTML
      • getSelectedIndex

        public int getSelectedIndex()
        Gets the currently selected child index.
        Returns:
        selected child
      • insert

        public void insert​(Widget w,
                           int beforeIndex)
        Description copied from interface: InsertPanel
        Inserts a child widget before the specified index. If the widget is already a child of this panel, it will be moved to the specified index.
        Specified by:
        insert in interface InsertPanel
        Parameters:
        w - the child widget to be inserted
        beforeIndex - the index before which it will be inserted
      • remove

        public boolean remove​(int index)
        Description copied from interface: IndexedPanel
        Removes the widget at the specified index.
        Specified by:
        remove in interface IndexedPanel
        Overrides:
        remove in class ComplexPanel
        Parameters:
        index - the index of the widget to be removed
        Returns:
        false if the widget is not present
      • remove

        public boolean remove​(Widget child)
        Description copied from class: Panel
        Removes a child widget.

        How to Override this Method

        There are several important things that must take place in the correct order to properly remove a Widget from a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.

        1. Validate: Make sure this Panel is actually the parent of the child Widget; return false if it is not.
        2. Orphan: Call Panel.orphan(Widget) first while the child Widget is still attached.
        3. Physical Detach: Adjust the DOM to account for the removal of the child Widget. The Widget's Element must be physically removed from the DOM.
        4. Logical Detach: Update the Panel's state variables to reflect the removal of the child Widget. Example: the Widget is removed from the Panel's WidgetCollection.

        Specified by:
        remove in interface HasWidgets
        Overrides:
        remove in class ComplexPanel
        Parameters:
        child - the widget to be removed
        Returns:
        true if the child was present
      • setStackText

        public void setStackText​(int index,
                                 java.lang.String text)
        Sets the text associated with a child by its index.
        Parameters:
        index - the index of the child whose text is to be set
        text - the text to be associated with it
      • setStackText

        public void setStackText​(int index,
                                 SafeHtml html)
        Sets the html associated with a child by its index.
        Parameters:
        index - the index of the child whose text is to be set
        html - the html to be associated with it
      • setStackText

        public void setStackText​(int index,
                                 java.lang.String text,
                                 boolean asHTML)
        Sets the text associated with a child by its index.
        Parameters:
        index - the index of the child whose text is to be set
        text - the text to be associated with it
        asHTML - true to treat the specified text as HTML
      • showStack

        public void showStack​(int index)
        Shows the widget at the specified child index.
        Parameters:
        index - the index of the child to be shown
      • onEnsureDebugId

        protected void onEnsureDebugId​(java.lang.String baseID)
        Affected Elements:
        • -text# = The element around the header at the specified index.
        • -text-wrapper# = The element around the header at the specified index.
        • -content# = The element around the body at the specified index.
        Overrides:
        onEnsureDebugId in class UIObject
        Parameters:
        baseID - the base ID used by the main element
        See Also:
        UIObject.onEnsureDebugId(String)
      • createHeaderElem

        Element createHeaderElem()
        Returns a header element.
      • getHeaderTextElem

        Element getHeaderTextElem​(Element headerElem)
        Get the element that holds the header text given the header element created by #createHeaderElement.
        Parameters:
        headerElem - the header element
        Returns:
        the element around the header text
      • addHeaderStyleName

        public void addHeaderStyleName​(int index,
                                       java.lang.String styleName)
        Adds the styleName on the <tr> for the header specified by index.
        Parameters:
        index - the index of the header row to apply to the style to
        styleName - the name of the class to add
      • removeHeaderStyleName

        public void removeHeaderStyleName​(int index,
                                          java.lang.String styleName)
        Removes the styleName off the <tr> for the header specified by index.
        Parameters:
        index - the index of the header row to remove the style from
        styleName - the name of the class to remove