Package org.opencms.gwt.client.ui.input
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<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
-
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 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.
-
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()
Returnstrue
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 org.opencms.gwt.client.ui.input.I_CmsFormWidget
getApparentValue, setAutoHideParent
-
-
-
-
Field Detail
-
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
protected CmsPushButton 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
protected final CmsStyleVariable m_selectBoxState
Style of the select box widget.
-
m_selectCells
protected java.util.Map<java.lang.String,OPTION extends A_CmsSelectCell> m_selectCells
The map of select options.
-
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.
-
m_selectorState
protected final CmsStyleVariable m_selectorState
Style of the select box widget.
-
-
Constructor Detail
-
A_CmsSelectBox
public A_CmsSelectBox()
Creates a new select box.
-
-
Method Detail
-
addFocusHandler
public com.google.gwt.event.shared.HandlerRegistration addFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler)
- Specified by:
addFocusHandler
in interfacecom.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 interfacecom.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
public I_CmsFormWidget.FieldType getFieldType()
Description copied from interface:I_CmsFormWidget
Returns the type of data this widget produces.- Specified by:
getFieldType
in interfaceI_CmsFormWidget
- Returns:
- the data type
- See Also:
I_CmsFormWidget.getFieldType()
-
getFormValue
public java.lang.Object getFormValue()
Description copied from interface:I_CmsFormWidget
Gets the selected/entered value from the widget.- Specified by:
getFormValue
in interfaceI_CmsFormWidget
- Returns:
- the value
- See Also:
I_CmsFormWidget.getFormValue()
-
getFormValueAsString
public java.lang.String getFormValueAsString()
Description copied from interface:I_CmsFormWidget
Gets the current value of the widget as a string.- Specified by:
getFormValueAsString
in interfaceI_CmsFormWidget
- Returns:
- the current value of the widget
- See Also:
I_CmsFormWidget.getFormValueAsString()
-
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
Returnstrue
if this widget is enabled.- Specified by:
isEnabled
in interfaceI_CmsFormWidget
- Returns:
true
if this widget is enabled- See Also:
I_CmsFormWidget.isEnabled()
-
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event event)
- Specified by:
onBrowserEvent
in interfacecom.google.gwt.user.client.EventListener
- Overrides:
onBrowserEvent
in classcom.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 interfaceI_CmsFormWidget
- See Also:
I_CmsFormWidget.reset()
-
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
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:I_CmsFormWidget
Enables or disables the widget.- Specified by:
setEnabled
in interfaceI_CmsFormWidget
- Parameters:
enabled
- if true, the widget will be enabled, else disabled- See Also:
I_CmsFormWidget.setEnabled(boolean)
-
setErrorMessage
public void setErrorMessage(java.lang.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 interfaceI_CmsFormWidget
- Parameters:
errorMessage
- an error message or null- See Also:
I_CmsFormWidget.setErrorMessage(java.lang.String)
-
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 valuefireEvents
- true if change events should be fired
-
setFormValueAsString
public void setFormValueAsString(java.lang.String formValue)
Description copied from interface:I_CmsFormWidget
Sets the current value of the widget as a string.- Specified by:
setFormValueAsString
in interfaceI_CmsFormWidget
- Parameters:
formValue
- the new value of the widget- See Also:
I_CmsFormWidget.setFormValueAsString(java.lang.String)
-
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(java.lang.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 interfaceI_CmsTruncable
- Parameters:
textMetricsPrefix
- the key identifying the text metrics to usewidgetWidth
- the width to use in pixels- See Also:
I_CmsTruncable.truncate(java.lang.String, int)
-
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 classcom.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 classcom.google.gwt.user.client.ui.Widget
- See Also:
Widget.onLoad()
-
onUnload
protected void onUnload()
- Overrides:
onUnload
in classcom.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 valuefireEvents
- 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(java.lang.String prefix, int width)
Abstract method whose implementation should truncate the opener widget(s).- Parameters:
prefix
- the text metrics prefixwidth
- 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
-
-