Class A_CmsSelectBox<OPTION extends A_CmsSelectCell>

java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Composite
org.opencms.gwt.client.ui.input.A_CmsSelectBox<OPTION>
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<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<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 
    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

    Nested classes/interfaces inherited from interface org.opencms.gwt.client.ui.input.I_CmsFormWidget

    I_CmsFormWidget.FieldType
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final I_CmsInputCss
    The layout bundle.
    protected CmsErrorWidget
    Error widget.
    protected com.google.gwt.event.shared.SimpleEventBus
    The event bus.
    protected com.google.gwt.event.shared.HandlerRegistration
    Handler registration for mouse wheel handlers.
    protected CmsPushButton
    The open-close button.
    protected com.google.gwt.user.client.ui.FocusPanel
    The opener widget.
    protected com.google.gwt.user.client.ui.Panel
    Container for the opener and error widget.
    protected com.google.gwt.user.client.ui.PopupPanel
    The popup panel inside which the selector will be shown.
    protected final CmsStyleVariable
    Style of the select box widget.
    protected Map<String,OPTION>
    The map of select options.
    protected String
    The value of the currently selected option.
    protected com.google.gwt.user.client.ui.Panel
    The selector which contains the select options.
    protected final CmsStyleVariable
    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
    Creates a new select box.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.gwt.event.shared.HandlerRegistration
    addFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler)
     
    void
    Adds a new select option to the select box.
    com.google.gwt.event.shared.HandlerRegistration
    addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<String> handler)
     
    void
    addWidget(com.google.gwt.user.client.ui.Widget widget)
    Adds a widget.
    protected void
    Internal helper method for clearing the select options.
    protected void
    Internal method which is called when the selector is closed.
    protected abstract OPTION
    Internal method to create a select option for an unknown value.
    boolean
    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.
    Returns the type of data this widget produces.
    Gets the selected/entered value from the widget.
    Gets the current value of the widget as a string.
    protected int
    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
    Returns the selector of this widget.
    protected abstract void
    The implementation of this method should initialize the opener of the select box.
    protected int
    Initializes the selector width.
    boolean
    Returns true if this widget is enabled.
    void
    onBrowserEvent(com.google.gwt.user.client.Event event)
     
    protected void
     
    protected void
    onFocus(com.google.gwt.event.dom.client.FocusEvent event)
    Handles the focus event on the opener.
    protected void
     
    protected void
     
    protected void
    This method is called when a value is selected.
    protected void
    onValueSelect(String value, boolean fireEvents)
    Internal handler method which is called when a new value is selected.
    protected void
    Internal method which is called when the selector is opened.
    protected void
    Deinstalls the window resize handler.
    void
    Resets the widget to its default state.
    void
    Helper method to set the current selected option.
    void
    setEnabled(boolean enabled)
    Enables or disables the widget.
    void
    setErrorMessage(String errorMessage)
    Sets the error message for this widget.
    void
    Sets the form value of this select box.
    void
    setFormValue(Object value, boolean fireEvents)
    Sets the form value of this select box.
    void
    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(String textMetricsPrefix, int widgetWidth)
    Truncates long text and sets the original text to the title attribute.
    protected abstract void
    truncateOpener(String prefix, int width)
    Abstract method whose implementation should truncate the opener widget(s).
    protected abstract void
    updateOpener(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

    Methods inherited from interface org.opencms.gwt.client.ui.input.I_CmsFormWidget

    getApparentValue, setAutoHideParent
  • Field Details

    • CSS

      protected static final I_CmsInputCss CSS
      The layout bundle.
    • m_error

      @UiField protected CmsErrorWidget m_error
      Error widget.
    • 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_openClose

      The open-close button.
    • 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_selectBoxState

      Style of the select box widget.
    • m_selectCells

      The map of select options.
    • 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.
    • m_selectorState

      Style of the select box widget.
  • Constructor Details

  • Method Details

    • 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<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
    • getFieldType

      Description copied from interface: I_CmsFormWidget
      Returns the type of data this widget produces.
      Specified by:
      getFieldType in interface I_CmsFormWidget
      Returns:
      the data type
      See Also:
    • getFormValue

      public Object getFormValue()
      Description copied from interface: I_CmsFormWidget
      Gets the selected/entered value from the widget.

      Specified by:
      getFormValue in interface I_CmsFormWidget
      Returns:
      the value
      See Also:
    • getFormValueAsString

      Description copied from interface: I_CmsFormWidget
      Gets the current value of the widget as a string.

      Specified by:
      getFormValueAsString in interface I_CmsFormWidget
      Returns:
      the current value of the widget
      See Also:
    • getSelectorPopup

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

      Returns:
      the selector of this widget
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: I_CmsFormWidget
      Returns true if this widget is enabled.

      Specified by:
      isEnabled in interface I_CmsFormWidget
      Returns:
      true if this widget is enabled
      See Also:
    • 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)
    • reset

      public void reset()
      Description copied from interface: I_CmsFormWidget
      Resets the widget to its default state.
      Specified by:
      reset in interface I_CmsFormWidget
      See Also:
    • selectValue

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

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

      Parameters:
      value - the new value
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: I_CmsFormWidget
      Enables or disables the widget.

      Specified by:
      setEnabled in interface I_CmsFormWidget
      Parameters:
      enabled - if true, the widget will be enabled, else disabled
      See Also:
    • setErrorMessage

      public void setErrorMessage(String errorMessage)
      Description copied from interface: I_CmsFormWidget
      Sets the error message for this widget.

      If the error message is null, no error message will be displayed.

      Specified by:
      setErrorMessage in interface I_CmsFormWidget
      Parameters:
      errorMessage - an error message or null
      See Also:
    • setFormValue

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

      Parameters:
      value - the new value
    • setFormValue

      public void setFormValue(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
    • setFormValueAsString

      public void setFormValueAsString(String formValue)
      Description copied from interface: I_CmsFormWidget
      Sets the current value of the widget as a string.

      Specified by:
      setFormValueAsString in interface I_CmsFormWidget
      Parameters:
      formValue - the new value of the widget
      See Also:
    • 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
    • truncate

      public void truncate(String textMetricsPrefix, int widgetWidth)
      Description copied from interface: I_CmsTruncable
      Truncates long text and sets the original text to the title attribute.

      Specified by:
      truncate in interface I_CmsTruncable
      Parameters:
      textMetricsPrefix - the key identifying the text metrics to use
      widgetWidth - the width to use in pixels
      See Also:
    • 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(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(String value)
      This method is called when a value is selected.

      Parameters:
      value - the selected value
    • onValueSelect

      protected void onValueSelect(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.

    • removeWindowResizeHandler

      protected void removeWindowResizeHandler()
      Deinstalls the window resize handler.

    • truncateOpener

      protected abstract void truncateOpener(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(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