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<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_CmsHasInit
,I_CmsTruncable
,I_CmsFormWidget
,I_CmsHasGhostValue
- Direct Known Subclasses:
CmsPropertyComboBox
public class CmsComboBox extends A_CmsSelectBox<CmsLabelSelectCell> 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.0.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
Fields Modifier and Type Field Description static java.lang.String
CSS_CLASS
CSS style name for combo boxes.protected java.lang.String
m_ghostValue
The ghost value.protected CmsSimpleTextBox
m_openerWidget
The widget displayed in the opener.static java.lang.String
NO_SELECTION_OPENER_TEXT
The key for the text which should be displayed in the opener if no option is available.static java.lang.String
NO_SELECTION_TEXT
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
-
-
Constructor Summary
Constructors Constructor Description CmsComboBox()
Default constructor.CmsComboBox(java.util.Map<java.lang.String,java.lang.String> items)
Constructs a new select box from a map.CmsComboBox(java.util.Map<java.lang.String,java.lang.String> items, boolean addNullOption)
Creates a new select box, with the option of adding a "not selected" choice.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOption(java.lang.String value, java.lang.String text)
Adds a new selection cell.com.google.gwt.event.shared.HandlerRegistration
addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<java.lang.String> handler)
void
closeSelector()
protected CmsLabelSelectCell
createUnknownOption(java.lang.String value)
Internal method to create a select option for an unknown value.java.lang.String
getApparentValue()
Returns the "apparent value", i.e.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.com.google.gwt.user.client.ui.Panel
getMainPanel()
Returns the mainpanel of this widget.com.google.gwt.user.client.ui.FocusPanel
getOpener()
Returns the opener of this widget.com.google.gwt.user.client.ui.TextBox
getTextBox()
Returns the text box of this widget.protected java.lang.String
getTitle(java.lang.String option, java.lang.String defaultValue)
Helper method to get the title for a given select option.static void
initClass()
Initializes this class.protected void
initOpener()
The implementation of this method should initialize the opener of the select box.protected void
onLoad()
void
openSelector()
void
selectValue(java.lang.String value)
Helper method to set the current selected option.void
setAutoHideParent(I_CmsAutoHider autoHideParent)
Call this when auto hiding parents are shown.void
setFormValue(java.lang.Object value)
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
setGhostMode(boolean ghostMode)
Enables or disables ghost mode, if possible.void
setGhostValue(java.lang.String value, boolean ghostMode)
Sets the "ghost value" of the widget and optionally sets it to "ghost mode".void
setItems(java.util.Map<java.lang.String,java.lang.String> items)
Sets the items using a map from option values to label texts.void
setText(java.lang.String text)
Sets the title for a select option.void
setTextForNullSelection(java.lang.String text)
Sets the text that is used for the "not selected" option.void
setTitle(java.lang.String option, java.lang.String title)
Sets the title for a select option.void
truncateOpener(java.lang.String prefix, int width)
Abstract method whose implementation should truncate the opener widget(s).protected void
updateCell(CmsLabelSelectCell cell)
Updates the select cell.void
updateCells()
Updates the select cells.protected void
updateOpener(java.lang.String newValue)
The implementation of this method should update the opener when a new value is selected by the user.protected void
updateStyle()
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, addOption, addWidget, clearItems, close, displayingAbove, doClickOpener, getFieldType, getPopupHeight, getSelectorPopup, initMaxCellWidth, isEnabled, onBrowserEvent, onDetach, onFocus, onUnload, onValueSelect, onValueSelect, open, removeWindowResizeHandler, reset, setEnabled, setErrorMessage, 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
-
-
-
-
Field Detail
-
NO_SELECTION_OPENER_TEXT
public static final java.lang.String NO_SELECTION_OPENER_TEXT
The key for the text which should be displayed in the opener if no option is available.- See Also:
- Constant Field Values
-
NO_SELECTION_TEXT
public static final java.lang.String NO_SELECTION_TEXT
The key for the text which should be displayed if no option is available.- See Also:
- Constant Field Values
-
CSS_CLASS
public static final java.lang.String CSS_CLASS
CSS style name for combo boxes.
-
m_ghostValue
protected java.lang.String m_ghostValue
The ghost value.
-
m_openerWidget
protected CmsSimpleTextBox m_openerWidget
The widget displayed in the opener.
-
-
Constructor Detail
-
CmsComboBox
public CmsComboBox()
Default constructor.
-
CmsComboBox
public CmsComboBox(java.util.Map<java.lang.String,java.lang.String> items)
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
public CmsComboBox(java.util.Map<java.lang.String,java.lang.String> items, boolean addNullOption)
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 Detail
-
initClass
public static void initClass()
Initializes this class.
-
addOption
public void addOption(java.lang.String value, java.lang.String text)
Adds a new selection cell.- Parameters:
value
- the value of the select optiontext
- the text to be displayed for 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<java.lang.String>
- Overrides:
addValueChangeHandler
in classA_CmsSelectBox<CmsLabelSelectCell>
- See Also:
A_CmsSelectBox.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
-
closeSelector
public void closeSelector()
-
getApparentValue
public java.lang.String 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:
I_CmsFormWidget.getApparentValue()
-
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
- Overrides:
getFormValue
in classA_CmsSelectBox<CmsLabelSelectCell>
- 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
- Overrides:
getFormValueAsString
in classA_CmsSelectBox<CmsLabelSelectCell>
- Returns:
- the current value of the widget
- See Also:
I_CmsFormWidget.getFormValueAsString()
-
getMainPanel
public com.google.gwt.user.client.ui.Panel getMainPanel()
Returns the mainpanel of this widget.- Returns:
- the mainpanel of this widget
-
getOpener
public com.google.gwt.user.client.ui.FocusPanel getOpener()
Returns the opener of this widget.- Returns:
- the opener of this widget
-
getTextBox
public com.google.gwt.user.client.ui.TextBox getTextBox()
Returns the text box of this widget.- Returns:
- the text box of this widget
-
openSelector
public void openSelector()
-
selectValue
public void selectValue(java.lang.String value)
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<CmsLabelSelectCell>
- Parameters:
value
- the new value- See Also:
A_CmsSelectBox.selectValue(java.lang.String)
-
setAutoHideParent
public void setAutoHideParent(I_CmsAutoHider autoHideParent)
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:
I_CmsFormWidget.setAutoHideParent(org.opencms.gwt.client.ui.I_CmsAutoHider)
-
setFormValue
public void setFormValue(java.lang.Object value)
Description copied from class:A_CmsSelectBox
Sets the form value of this select box.- Overrides:
setFormValue
in classA_CmsSelectBox<CmsLabelSelectCell>
- Parameters:
value
- the new value- See Also:
A_CmsSelectBox.setFormValue(java.lang.Object)
-
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
- Overrides:
setFormValueAsString
in classA_CmsSelectBox<CmsLabelSelectCell>
- Parameters:
formValue
- the new value of the widget- See Also:
I_CmsFormWidget.setFormValueAsString(java.lang.String)
-
setGhostMode
public void setGhostMode(boolean ghostMode)
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:
I_CmsHasGhostValue.setGhostMode(boolean)
-
setGhostValue
public void setGhostValue(java.lang.String value, boolean ghostMode)
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:
I_CmsHasGhostValue.setGhostValue(java.lang.String, boolean)
-
setItems
public void setItems(java.util.Map<java.lang.String,java.lang.String> items)
Sets the items using a map from option values to label texts.- Parameters:
items
- the map containing the select options
-
setText
public void setText(java.lang.String text)
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
public void setTextForNullSelection(java.lang.String text)
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
public void setTitle(java.lang.String option, java.lang.String title)
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
public void truncateOpener(java.lang.String prefix, int width)
Description copied from class:A_CmsSelectBox
Abstract method whose implementation should truncate the opener widget(s).- Specified by:
truncateOpener
in classA_CmsSelectBox<CmsLabelSelectCell>
- Parameters:
prefix
- the text metrics prefixwidth
- the widget width- See Also:
A_CmsSelectBox.truncateOpener(java.lang.String, int)
-
updateCells
public void updateCells()
Updates the select cells.
-
createUnknownOption
protected CmsLabelSelectCell createUnknownOption(java.lang.String value)
Description copied from class:A_CmsSelectBox
Internal method to create a select option for an unknown value.- Specified by:
createUnknownOption
in classA_CmsSelectBox<CmsLabelSelectCell>
- Parameters:
value
- the value for which to create the option- Returns:
- the new option
- See Also:
A_CmsSelectBox.createUnknownOption(java.lang.String)
-
getTitle
protected java.lang.String getTitle(java.lang.String option, java.lang.String defaultValue)
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
protected void 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<CmsLabelSelectCell>
- See Also:
A_CmsSelectBox.initOpener()
-
onLoad
protected void onLoad()
- Overrides:
onLoad
in classA_CmsSelectBox<CmsLabelSelectCell>
- See Also:
Widget.onLoad()
-
updateCell
protected void updateCell(CmsLabelSelectCell cell)
Updates the select cell.- Parameters:
cell
- the select cell
-
updateOpener
protected void updateOpener(java.lang.String newValue)
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<CmsLabelSelectCell>
- Parameters:
newValue
- the value selected by the user- See Also:
A_CmsSelectBox.updateOpener(java.lang.String)
-
updateStyle
protected void updateStyle()
This method should be used to make changes to the CSS style of the select box when the value changes.
-
-