Package org.opencms.gwt.client.ui.input
Class CmsMultiSelectBox
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<CmsMultiSelectCell>
org.opencms.gwt.client.ui.input.CmsMultiSelectBox
- 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_CmsFormWidget
,I_CmsHasGhostValue
public class CmsMultiSelectBox
extends A_CmsSelectBox<CmsMultiSelectCell>
implements I_CmsHasInit, I_CmsHasGhostValue
Widget for selecting one of multiple items from a drop-down list which opens
after the user clicks on the widget.
- Since:
- 8.5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opencms.gwt.client.ui.input.A_CmsSelectBox
A_CmsSelectBox.I_CmsSelectBoxUiBinder
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
FieldsModifier and TypeFieldDescriptionprotected String
The ghost value.protected CmsLabel
The widget displayed in the opener.static final String
The key for the text which should be displayed in the opener if no option is available.static final String
The 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_selectorState
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.CmsMultiSelectBox
(Map<String, String> items, boolean addNullOption) Creates a new select box, with the option of adding a "not selected" choice. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOption
(CmsMultiSelectCell cell) Adds a new selection cell.protected CmsMultiSelectCell
createUnknownOption
(String value) Internal method to create a select option for an unknown value.Returns the "apparent value", i.e.Returns all CmsCheckBoxes used.Gets the current value of the widget as a string.protected String
Helper method to get the title for a given select option.static void
Initializes this class.protected void
The implementation of this method should initialize the opener of the select box.protected void
onLoad()
void
selectValue
(String value) Helper method to set the current selected option.void
setAutoHideParent
(I_CmsAutoHider autoHideParent) Call this when auto hiding parents are shown.void
setFormValueAsString
(String value) Sets the current value of the widget as a string.void
setGhostMode
(boolean ghostMode) Enables or disables ghost mode, if possible.void
setGhostValue
(String value, boolean ghostMode) Sets the "ghost value" of the widget and optionally sets it to "ghost mode".void
Sets the text that is used for the "not selected" option.void
Sets the title for a select option.void
truncateOpener
(String prefix, int width) Abstract method whose implementation should truncate the opener widget(s).void
updateCell
(CmsMultiSelectCell cell) Updates a single select cell.void
Updates the select cells.protected void
updateOpener
(String newValue) The implementation of this method should update the opener when a new value is selected by the user.protected void
This 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, addValueChangeHandler, addWidget, clearItems, close, displayingAbove, doClickOpener, getFieldType, getFormValue, getPopupHeight, getSelectorPopup, initPreferredPopupWidth, isEnabled, onBrowserEvent, onDetach, onFocus, onUnload, onValueSelect, onValueSelect, open, removeWindowResizeHandler, reset, setEnabled, setErrorMessage, setFormValue, setFormValue, setPopupResize, truncate
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 Details
-
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
-
CmsMultiSelectBox
public CmsMultiSelectBox()Default constructor. -
CmsMultiSelectBox
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.- Overrides:
addOption
in classA_CmsSelectBox<CmsMultiSelectCell>
- Parameters:
cell
- the new selection cell
-
getApparentValue
Description copied from interface:I_CmsFormWidget
Returns the "apparent value", i.e. either the real value if available, or else the ghost value if available, or null otherwise.- Specified by:
getApparentValue
in interfaceI_CmsFormWidget
- Returns:
- the apparent value
- See Also:
-
getCheckboxes
Returns all CmsCheckBoxes used.- Returns:
- a list of CmsCheckBoxes
-
getFormValueAsString
Description copied from interface:I_CmsFormWidget
Gets the current value of the widget as a string.- Specified by:
getFormValueAsString
in interfaceI_CmsFormWidget
- Overrides:
getFormValueAsString
in classA_CmsSelectBox<CmsMultiSelectCell>
- Returns:
- the current value of the widget
- See Also:
-
selectValue
Description copied from class:A_CmsSelectBox
Helper method to set the current selected option.This method does not trigger the "value changed" event.
- Overrides:
selectValue
in classA_CmsSelectBox<CmsMultiSelectCell>
- Parameters:
value
- the new value- See Also:
-
setAutoHideParent
Description copied from interface:I_CmsFormWidget
Call this when auto hiding parents are shown.- Specified by:
setAutoHideParent
in interfaceI_CmsFormWidget
- Parameters:
autoHideParent
- the auto hide parent- See Also:
-
setFormValueAsString
Description copied from interface:I_CmsFormWidget
Sets the current value of the widget as a string.- Specified by:
setFormValueAsString
in interfaceI_CmsFormWidget
- Overrides:
setFormValueAsString
in classA_CmsSelectBox<CmsMultiSelectCell>
- Parameters:
value
- the new value of the widget- See Also:
-
setGhostMode
Description copied from interface:I_CmsHasGhostValue
Enables or disables ghost mode, if possible.- Specified by:
setGhostMode
in interfaceI_CmsHasGhostValue
- Parameters:
ghostMode
- if ghost mode should be enabled, else disabled- See Also:
-
setGhostValue
Description copied from interface:I_CmsHasGhostValue
Sets 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:
setGhostValue
in interfaceI_CmsHasGhostValue
- Parameters:
value
- the ghost valueghostMode
- if true, sets the widget to ghost mode- See Also:
-
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_CmsSelectBox
Abstract method whose implementation should truncate the opener widget(s).- Specified by:
truncateOpener
in classA_CmsSelectBox<CmsMultiSelectCell>
- Parameters:
prefix
- the text metrics prefixwidth
- the widget width- See Also:
-
updateCell
Updates a single select cell.- Parameters:
cell
- the select cell to update
-
updateCells
Updates the select cells. -
createUnknownOption
Description copied from class:A_CmsSelectBox
Internal method to create a select option for an unknown value.- Specified by:
createUnknownOption
in classA_CmsSelectBox<CmsMultiSelectCell>
- 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_CmsSelectBox
The implementation of this method should initialize the opener of the select box.- Specified by:
initOpener
in classA_CmsSelectBox<CmsMultiSelectCell>
- See Also:
-
onLoad
- Overrides:
onLoad
in classA_CmsSelectBox<CmsMultiSelectCell>
- See Also:
-
Widget.onLoad()
-
updateOpener
Description copied from class:A_CmsSelectBox
The implementation of this method should update the opener when a new value is selected by the user.- Specified by:
updateOpener
in classA_CmsSelectBox<CmsMultiSelectCell>
- 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.
-