Class A_CmsSelectBox<OPTION extends A_CmsSelectCell>

  • Type Parameters:
    OPTION - the widget type of the select options
    All Implemented Interfaces:
    com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasValueChangeHandlers<java.lang.String>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget, I_CmsTruncable, I_CmsFormWidget
    Direct Known Subclasses:
    CmsComboBox, CmsFilterSelectBox, CmsMultiSelectBox, CmsSelectBox

    public abstract class A_CmsSelectBox<OPTION extends A_CmsSelectCell>
    extends com.google.gwt.user.client.ui.Composite
    implements I_CmsFormWidget, com.google.gwt.event.logical.shared.HasValueChangeHandlers<java.lang.String>, com.google.gwt.event.dom.client.HasFocusHandlers, I_CmsTruncable
    Abstract superclass for select box widgets.

    Since:
    8.0.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static interface  A_CmsSelectBox.I_CmsSelectBoxUiBinder
      The UI Binder interface for this widget.
      • Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject

        com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static I_CmsInputCss CSS
      The layout bundle.
      protected CmsErrorWidget m_error
      Error widget.
      protected com.google.gwt.event.shared.SimpleEventBus m_eventBus
      The event bus.
      protected com.google.gwt.event.shared.HandlerRegistration m_mousewheelRegistration
      Handler registration for mouse wheel handlers.
      protected CmsPushButton m_openClose
      The open-close button.
      protected com.google.gwt.user.client.ui.FocusPanel m_opener
      The opener widget.
      protected com.google.gwt.user.client.ui.Panel m_panel
      Container for the opener and error widget.
      protected com.google.gwt.user.client.ui.PopupPanel m_popup
      The popup panel inside which the selector will be shown.
      protected CmsStyleVariable m_selectBoxState
      Style of the select box widget.
      protected java.util.Map<java.lang.String,​OPTION> m_selectCells
      The map of select options.
      protected java.lang.String m_selectedValue
      The value of the currently selected option.
      protected com.google.gwt.user.client.ui.Panel m_selector
      The selector which contains the select options.
      protected CmsStyleVariable m_selectorState
      Style of the select box widget.
      • Fields inherited from class com.google.gwt.user.client.ui.UIObject

        DEBUG_ID_PREFIX
    • Constructor Summary

      Constructors 
      Constructor Description
      A_CmsSelectBox()
      Creates a new select box.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.gwt.event.shared.HandlerRegistration addFocusHandler​(com.google.gwt.event.dom.client.FocusHandler handler)  
      void addOption​(OPTION cell)
      Adds a new select option to the select box.
      com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler​(com.google.gwt.event.logical.shared.ValueChangeHandler<java.lang.String> handler)  
      void addWidget​(com.google.gwt.user.client.ui.Widget widget)
      Adds a widget.
      protected void clearItems()
      Internal helper method for clearing the select options.
      protected void close()
      Internal method which is called when the selector is closed.
      protected abstract OPTION createUnknownOption​(java.lang.String value)
      Internal method to create a select option for an unknown value.
      boolean displayingAbove()
      Returns whether the select options are being displayed below or above the widget.
      protected void doClickOpener​(com.google.gwt.event.dom.client.ClickEvent e)
      Handle clicks on the opener.
      I_CmsFormWidget.FieldType getFieldType()
      Returns the type of data this widget produces.
      java.lang.Object getFormValue()
      Gets the selected/entered value from the widget.
      java.lang.String getFormValueAsString()
      Gets the current value of the widget as a string.
      protected int getPopupHeight()
      Returns the offset height of the popup panel, should also work when the popup is currently not showing.
      com.google.gwt.user.client.ui.Panel getSelectorPopup()
      Returns the selector of this widget.
      protected abstract void initOpener()
      The implementation of this method should initialize the opener of the select box.
      protected int initPreferredPopupWidth()
      Initializes the selector width.
      boolean isEnabled()
      Returns true if this widget is enabled.
      void onBrowserEvent​(com.google.gwt.user.client.Event event)  
      protected void onDetach()  
      protected void onFocus​(com.google.gwt.event.dom.client.FocusEvent event)
      Handles the focus event on the opener.
      protected void onLoad()  
      protected void onUnload()  
      protected void onValueSelect​(java.lang.String value)
      This method is called when a value is selected.
      protected void onValueSelect​(java.lang.String value, boolean fireEvents)
      Internal handler method which is called when a new value is selected.
      protected void open()
      Internal method which is called when the selector is opened.
      protected void removeWindowResizeHandler()
      Deinstalls the window resize handler.
      void reset()
      Resets the widget to its default state.
      void selectValue​(java.lang.String value)
      Helper method to set the current selected option.
      void setEnabled​(boolean enabled)
      Enables or disables the widget.
      void setErrorMessage​(java.lang.String errorMessage)
      Sets the error message for this widget.
      void setFormValue​(java.lang.Object value)
      Sets the form value of this select box.
      void setFormValue​(java.lang.Object value, boolean fireEvents)
      Sets the form value of this select box.
      void setFormValueAsString​(java.lang.String formValue)
      Sets the current value of the widget as a string.
      void setPopupResize​(boolean resize)
      Sets the behavior of the popup if the input is bigger than the selectbox itself.
      void truncate​(java.lang.String textMetricsPrefix, int widgetWidth)
      Truncates long text and sets the original text to the title attribute.
      protected abstract void truncateOpener​(java.lang.String prefix, int width)
      Abstract method whose implementation should truncate the opener widget(s).
      protected abstract void updateOpener​(java.lang.String newValue)
      The implementation of this method should update the opener when a new value is selected by the user.
      • Methods inherited from class com.google.gwt.user.client.ui.Composite

        claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, render, render, resolvePotentialElement, setWidget
      • Methods inherited from class com.google.gwt.user.client.ui.Widget

        addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
      • Methods inherited from class com.google.gwt.user.client.ui.UIObject

        addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.google.gwt.event.shared.HasHandlers

        fireEvent
    • Field Detail

      • m_eventBus

        protected com.google.gwt.event.shared.SimpleEventBus m_eventBus
        The event bus.
      • m_mousewheelRegistration

        protected com.google.gwt.event.shared.HandlerRegistration m_mousewheelRegistration
        Handler registration for mouse wheel handlers.
      • m_opener

        @UiField
        protected com.google.gwt.user.client.ui.FocusPanel m_opener
        The opener widget.
      • m_panel

        @UiField
        protected com.google.gwt.user.client.ui.Panel m_panel
        Container for the opener and error widget.
      • m_popup

        protected com.google.gwt.user.client.ui.PopupPanel m_popup
        The popup panel inside which the selector will be shown.

      • m_selectedValue

        protected java.lang.String m_selectedValue
        The value of the currently selected option.
      • m_selector

        protected com.google.gwt.user.client.ui.Panel m_selector
        The selector which contains the select options.
    • Constructor Detail

    • Method Detail

      • addFocusHandler

        public com.google.gwt.event.shared.HandlerRegistration addFocusHandler​(com.google.gwt.event.dom.client.FocusHandler handler)
        Specified by:
        addFocusHandler in interface com.google.gwt.event.dom.client.HasFocusHandlers
        See Also:
        HasFocusHandlers.addFocusHandler(com.google.gwt.event.dom.client.FocusHandler)
      • addOption

        public void addOption​(OPTION cell)
        Adds a new select option to the select box.

        Parameters:
        cell - the widget representing the select option
      • addValueChangeHandler

        public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler​(com.google.gwt.event.logical.shared.ValueChangeHandler<java.lang.String> handler)
        Specified by:
        addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<OPTION extends A_CmsSelectCell>
        See Also:
        HasValueChangeHandlers.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
      • addWidget

        public void addWidget​(com.google.gwt.user.client.ui.Widget widget)
        Adds a widget.

        Parameters:
        widget - the widget to add
      • displayingAbove

        public boolean displayingAbove()
        Returns whether the select options are being displayed below or above the widget.

        Returns:
        true in case the select options are displayed above the widget
      • getSelectorPopup

        public com.google.gwt.user.client.ui.Panel getSelectorPopup()
        Returns the selector of this widget.

        Returns:
        the selector of this widget
      • onBrowserEvent

        public void onBrowserEvent​(com.google.gwt.user.client.Event event)
        Specified by:
        onBrowserEvent in interface com.google.gwt.user.client.EventListener
        Overrides:
        onBrowserEvent in class com.google.gwt.user.client.ui.Composite
        See Also:
        Composite.onBrowserEvent(com.google.gwt.user.client.Event)
      • selectValue

        public void selectValue​(java.lang.String value)
        Helper method to set the current selected option.

        This method does not trigger the "value changed" event.

        Parameters:
        value - the new value
      • setFormValue

        public void setFormValue​(java.lang.Object value)
        Sets the form value of this select box.

        Parameters:
        value - the new value
      • setFormValue

        public void setFormValue​(java.lang.Object value,
                                 boolean fireEvents)
        Sets the form value of this select box.

        Parameters:
        value - the new value
        fireEvents - true if change events should be fired
      • setPopupResize

        public void setPopupResize​(boolean resize)
        Sets the behavior of the popup if the input is bigger than the selectbox itself.
        Parameters:
        resize - true to resize
      • clearItems

        protected void clearItems()
        Internal helper method for clearing the select options.

      • close

        protected void close()
        Internal method which is called when the selector is closed.

      • createUnknownOption

        protected abstract OPTION createUnknownOption​(java.lang.String value)
        Internal method to create a select option for an unknown value.

        Parameters:
        value - the value for which to create the option
        Returns:
        the new option
      • doClickOpener

        @UiHandler("m_opener")
        protected void doClickOpener​(com.google.gwt.event.dom.client.ClickEvent e)
        Handle clicks on the opener.

        Parameters:
        e - the click event
      • getPopupHeight

        protected int getPopupHeight()
        Returns the offset height of the popup panel, should also work when the popup is currently not showing.

        Returns:
        the offset height
      • initOpener

        protected abstract void initOpener()
        The implementation of this method should initialize the opener of the select box.

      • initPreferredPopupWidth

        protected int initPreferredPopupWidth()
        Initializes the selector width.

        Returns:
        the preferred popup width
      • onDetach

        protected void onDetach()
        Overrides:
        onDetach in class com.google.gwt.user.client.ui.Composite
        See Also:
        Composite.onDetach()
      • onFocus

        @UiHandler("m_opener")
        protected void onFocus​(com.google.gwt.event.dom.client.FocusEvent event)
        Handles the focus event on the opener.

        Parameters:
        event - the focus event
      • onLoad

        protected void onLoad()
        Overrides:
        onLoad in class com.google.gwt.user.client.ui.Widget
        See Also:
        Widget.onLoad()
      • onUnload

        protected void onUnload()
        Overrides:
        onUnload in class com.google.gwt.user.client.ui.Widget
        See Also:
        Widget.onUnload()
      • onValueSelect

        protected void onValueSelect​(java.lang.String value)
        This method is called when a value is selected.

        Parameters:
        value - the selected value
      • onValueSelect

        protected void onValueSelect​(java.lang.String value,
                                     boolean fireEvents)
        Internal handler method which is called when a new value is selected.

        Parameters:
        value - the new value
        fireEvents - true if change events should be fired
      • open

        protected void open()
        Internal method which is called when the selector is opened.

      • truncateOpener

        protected abstract void truncateOpener​(java.lang.String prefix,
                                               int width)
        Abstract method whose implementation should truncate the opener widget(s).

        Parameters:
        prefix - the text metrics prefix
        width - the widget width
      • updateOpener

        protected abstract void updateOpener​(java.lang.String newValue)
        The implementation of this method should update the opener when a new value is selected by the user.

        Parameters:
        newValue - the value selected by the user