Package org.opencms.gwt.client.ui.input
Class CmsComboBox
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<CmsLabelSelectCell>
org.opencms.gwt.client.ui.input.CmsComboBox
- 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_CmsHasInit,I_CmsTruncable,I_CmsHasPlaceholder,I_CmsFormWidget,I_CmsHasGhostValue
- Direct Known Subclasses:
CmsPropertyComboBox
public class CmsComboBox
extends A_CmsSelectBox<CmsLabelSelectCell>
implements I_CmsHasInit, I_CmsHasGhostValue, I_CmsHasPlaceholder
Widget for selecting one of multiple items from a drop-down list which opens
after the user clicks on the widget.
- Since:
- 8.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opencms.gwt.client.ui.input.A_CmsSelectBox
A_CmsSelectBox.I_CmsSelectBoxUiBinderNested 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.DebugIdImplEnabledNested classes/interfaces inherited from interface org.opencms.gwt.client.ui.input.I_CmsFormWidget
I_CmsFormWidget.FieldType -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCSS style name for combo boxes.protected StringThe ghost value.protected CmsSimpleTextBoxThe widget displayed in the opener.static final StringThe key for the text which should be displayed in the opener if no option is available.static final StringThe key for the text which should be displayed if no option is available.Fields inherited from class org.opencms.gwt.client.ui.input.A_CmsSelectBox
CSS, m_error, m_eventBus, m_mousewheelRegistration, m_openClose, m_opener, m_panel, m_popup, m_selectBoxState, m_selectCells, m_selectedValue, m_selector, m_selectorStateFields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.CmsComboBox(Map<String, String> items) Constructs a new select box from a map.CmsComboBox(Map<String, String> items, boolean addNullOption) Creates a new select box, with the option of adding a "not selected" choice. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new selection cell.com.google.gwt.event.shared.HandlerRegistrationaddValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<String> handler) voidprotected CmsLabelSelectCellcreateUnknownOption(String value) Internal method to create a select option for an unknown value.Returns the "apparent value", i.e.Gets the selected/entered value from the widget.Gets the current value of the widget as a string.com.google.gwt.user.client.ui.PanelReturns the mainpanel of this widget.com.google.gwt.user.client.ui.FocusPanelReturns the opener of this widget.com.google.gwt.user.client.ui.TextBoxReturns the text box of this widget.protected StringHelper method to get the title for a given select option.static voidInitializes this class.protected voidThe implementation of this method should initialize the opener of the select box.protected voidonLoad()voidvoidselectValue(String value) Helper method to set the current selected option.voidsetAutoHideParent(I_CmsAutoHider autoHideParent) Call this when auto hiding parents are shown.voidsetFormValue(Object value) Sets the form value of this select box.voidsetFormValueAsString(String formValue) Sets the current value of the widget as a string.voidsetGhostMode(boolean ghostMode) Enables or disables ghost mode, if possible.voidsetGhostValue(String value, boolean ghostMode) Sets the "ghost value" of the widget and optionally sets it to "ghost mode".voidSets the items using a map from option values to label texts.voidsetPlaceholder(String placeholder) Sets the placeholder in the widget.voidSets the title for a select option.voidSets the text that is used for the "not selected" option.voidSets the title for a select option.voidtruncateOpener(String prefix, int width) Abstract method whose implementation should truncate the opener widget(s).protected voidupdateCell(CmsLabelSelectCell cell) Updates the select cell.voidUpdates the select cells.protected voidupdateOpener(String newValue) The implementation of this method should update the opener when a new value is selected by the user.protected voidThis method should be used to make changes to the CSS style of the select box when the value changes.Methods inherited from class org.opencms.gwt.client.ui.input.A_CmsSelectBox
addFocusHandler, addOption, addWidget, clearItems, close, displayingAbove, doClickOpener, getFieldType, getPopupHeight, getSelectorPopup, initPreferredPopupWidth, isEnabled, onBrowserEvent, onDetach, onFocus, onUnload, onValueSelect, onValueSelect, open, removeWindowResizeHandler, reset, setEnabled, setErrorMessage, setFormValue, setPopupResize, truncateMethods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, render, render, resolvePotentialElement, setWidgetMethods 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, unsinkEventsMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Field Details
-
CSS_CLASS
CSS style name for combo boxes. -
NO_SELECTION_OPENER_TEXT
The key for the text which should be displayed in the opener if no option is available.- See Also:
-
NO_SELECTION_TEXT
The key for the text which should be displayed if no option is available.- See Also:
-
m_ghostValue
The ghost value. -
m_openerWidget
The widget displayed in the opener.
-
-
Constructor Details
-
CmsComboBox
public CmsComboBox()Default constructor. -
CmsComboBox
Constructs a new select box from a map.The keys of the map are the values of the select options, and the values of the map are the labels to be displayed for each option.
- Parameters:
items- the map of select options
-
CmsComboBox
Creates a new select box, with the option of adding a "not selected" choice.- Parameters:
items- the map of select optionsaddNullOption- if true, a "not selected" option will be added to the select box
-
-
Method Details
-
initClass
Initializes this class. -
addOption
Adds a new selection cell.- Parameters:
value- the value of the select optiontext- the text to be displayed for the select option
-
closeSelector
-
getApparentValue
Description copied from interface:I_CmsFormWidgetReturns the "apparent value", i.e. either the real value if available, or else the ghost value if available, or null otherwise.- Specified by:
getApparentValuein interfaceI_CmsFormWidget- Returns:
- the apparent value
- See Also:
-
getFormValue
Description copied from interface:I_CmsFormWidgetGets the selected/entered value from the widget.- Specified by:
getFormValuein interfaceI_CmsFormWidget- Overrides:
getFormValuein classA_CmsSelectBox<CmsLabelSelectCell>- Returns:
- the value
- See Also:
-
getFormValueAsString
Description copied from interface:I_CmsFormWidgetGets the current value of the widget as a string.- Specified by:
getFormValueAsStringin interfaceI_CmsFormWidget- Overrides:
getFormValueAsStringin classA_CmsSelectBox<CmsLabelSelectCell>- Returns:
- the current value of the widget
- See Also:
-
getMainPanel
Returns the mainpanel of this widget.- Returns:
- the mainpanel of this widget
-
getOpener
Returns the opener of this widget.- Returns:
- the opener of this widget
-
getTextBox
Returns the text box of this widget.- Returns:
- the text box of this widget
-
openSelector
-
selectValue
Description copied from class:A_CmsSelectBoxHelper method to set the current selected option.This method does not trigger the "value changed" event.
- Overrides:
selectValuein classA_CmsSelectBox<CmsLabelSelectCell>- Parameters:
value- the new value- See Also:
-
setAutoHideParent
Description copied from interface:I_CmsFormWidgetCall this when auto hiding parents are shown.- Specified by:
setAutoHideParentin interfaceI_CmsFormWidget- Parameters:
autoHideParent- the auto hide parent- See Also:
-
setFormValue
Description copied from class:A_CmsSelectBoxSets the form value of this select box.- Overrides:
setFormValuein classA_CmsSelectBox<CmsLabelSelectCell>- Parameters:
value- the new value- See Also:
-
setFormValueAsString
Description copied from interface:I_CmsFormWidgetSets the current value of the widget as a string.- Specified by:
setFormValueAsStringin interfaceI_CmsFormWidget- Overrides:
setFormValueAsStringin classA_CmsSelectBox<CmsLabelSelectCell>- Parameters:
formValue- the new value of the widget- See Also:
-
setGhostMode
Description copied from interface:I_CmsHasGhostValueEnables or disables ghost mode, if possible.- Specified by:
setGhostModein interfaceI_CmsHasGhostValue- Parameters:
ghostMode- if ghost mode should be enabled, else disabled- See Also:
-
setGhostValue
Description copied from interface:I_CmsHasGhostValueSets the "ghost value" of the widget and optionally sets it to "ghost mode"."Ghost mode" can be used to show the user the value (called "ghost value") which will be used if he either doesn't choose an option in the widget, or explicitly chooses an "empty" or "default" option.
- Specified by:
setGhostValuein interfaceI_CmsHasGhostValue- Parameters:
value- the ghost valueghostMode- if true, sets the widget to ghost mode- See Also:
-
setItems
Sets the items using a map from option values to label texts.- Parameters:
items- the map containing the select options
-
setPlaceholder
Description copied from interface:I_CmsHasPlaceholderSets the placeholder in the widget.This *should* be called before the widget is actually attached to the DOM, as it is required by some of the implementations.
- Specified by:
setPlaceholderin interfaceI_CmsHasPlaceholder- Parameters:
placeholder- the placeholder string (null or empty for no placeholder)- See Also:
-
setText
Sets the title for a select option.Note: This will only affect select options added *after* calling this method!
- Parameters:
text- the new title for the option
-
setTextForNullSelection
Sets the text that is used for the "not selected" option.- Parameters:
text- the text which should be used for the "not selected" option
-
setTitle
Sets the title for a select option.Note: This will only affect select options added *after* calling this method!
- Parameters:
option- the select option valuetitle- the new title for the option
-
truncateOpener
Description copied from class:A_CmsSelectBoxAbstract method whose implementation should truncate the opener widget(s).- Specified by:
truncateOpenerin classA_CmsSelectBox<CmsLabelSelectCell>- Parameters:
prefix- the text metrics prefixwidth- the widget width- See Also:
-
updateCells
Updates the select cells. -
createUnknownOption
Description copied from class:A_CmsSelectBoxInternal method to create a select option for an unknown value.- Specified by:
createUnknownOptionin classA_CmsSelectBox<CmsLabelSelectCell>- Parameters:
value- the value for which to create the option- Returns:
- the new option
- See Also:
-
getTitle
Helper method to get the title for a given select option.- Parameters:
option- the select option valuedefaultValue- the value to return when no title for the value was found- Returns:
- the title for the select option
-
initOpener
Description copied from class:A_CmsSelectBoxThe implementation of this method should initialize the opener of the select box.- Specified by:
initOpenerin classA_CmsSelectBox<CmsLabelSelectCell>- See Also:
-
onLoad
- Overrides:
onLoadin classA_CmsSelectBox<CmsLabelSelectCell>- See Also:
-
updateCell
Updates the select cell.- Parameters:
cell- the select cell
-
updateOpener
Description copied from class:A_CmsSelectBoxThe implementation of this method should update the opener when a new value is selected by the user.- Specified by:
updateOpenerin classA_CmsSelectBox<CmsLabelSelectCell>- Parameters:
newValue- the value selected by the user- See Also:
-
updateStyle
This method should be used to make changes to the CSS style of the select box when the value changes.
-