com.sap.ui.commons.client
Class ListBoxWidget

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.sap.ui.core.client.ControlWidget
              extended by com.sap.ui.commons.client.ListBoxWidget
All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget

public class ListBoxWidget
extends com.sap.ui.core.client.ControlWidget

The class ListBox is the GWT wrapper for the Phoenix control: sap.ui.commons.ListBox.

Provides a list of items from which users can choose an item. For the design of the listbox, features such as defining the listbox height, fixing the number of visible items, choosing one item to be the item that is marked by default when the listbox is shown, or a scrollbar for large listboxes are available.

Version:
0.18.0-SNAPSHOT
Author:
GENERATOR (JavaScript control: SAP AG)

Nested Class Summary
 
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
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
  ListBoxWidget()
          constructs the class ListBoxWidget
protected ListBoxWidget(ListBox control)
          constructs the class ListBoxWidget
  ListBoxWidget(String id)
          constructs the class ListBoxWidget
 
Method Summary
 void addItem(com.sap.ui.core.client.Item item)
          Appends some item to the items-aggregation.
 void addSelectedIndex(int index)
          Adds the given index to current selection.
 void addSelectedIndices(Integer[] indices)
          Adds the given indices to selection.
 void attachSelectEvent(com.sap.ui.core.client.event.EventListener listener)
          attach an EventListener Event is fired when selection is changed by user interaction.
 void clearSelection()
          Removes complete selection.
 void destroyItems()
          Destroys all the items in the Items-aggregation.
 void detachSelectEvent(com.sap.ui.core.client.event.EventListener listener)
          detach an EventListener Event is fired when selection is changed by user interaction.
 ListBox getControl()
          returns the reference to the Phoenix Control
 String getHeight()
          Getter for property height Control height as common CSS-size (px or % as unit, for example).
 com.sap.ui.core.client.js.JsArray<com.sap.ui.core.client.Item> getItems()
          Getter for aggregation items Aggregation of items to be displayed.
 String getMaxWidth()
          Getter for property maxWidth The maximum width of the ListBox.
 String getMinWidth()
          Getter for property minWidth The minimum width of the ListBox.
 int getScrollTop()
          Getter for property scrollTop Scrollbar position from the top.
 com.sap.ui.core.client.TextAlign getSecondaryValueTextAlign()
          Getter for property secondaryValueTextAlign The text alignment in the secondary (optional) text column of the ListBox.
 int getSelectedIndex()
          Zero-based index of selected item.
 Integer[] getSelectedIndices()
          Zero-based indices of selected items, wrapped in an array.
 com.sap.ui.core.client.Item getSelectedItem()
          Returns selected item.
 com.sap.ui.core.client.js.JsArray<com.sap.ui.core.client.Item> getSelectedItems()
          Returns an array containing the selected items.
 com.sap.ui.core.client.TextAlign getValueTextAlign()
          Getter for property valueTextAlign The text alignment in the primary column of the ListBox.
 int getVisibleItems()
          Getter for property visibleItems The control height in number of items to be completely displayed without scrolling.
 String getWidth()
          Getter for property width Control width as common CSS-size (px or % as unit, for example).
 int indexOfItem(com.sap.ui.core.client.Item item)
          Checks for the provided com.sap.ui.core.client.Item in the items-aggregation and returns its index if found or -1 otherwise.
 void insertItem(com.sap.ui.core.client.Item item, int index)
          Inserts some item into the aggregation named items.
 boolean isAllowMultiSelect()
          Getter for property allowMultiSelect Specifies whether multiple selection is allowed.
 boolean isDisplayIcons()
          Getter for property displayIcons Defines whether the icons of the list items should also be displayed.
 boolean isDisplaySecondaryValues()
          Getter for property displaySecondaryValues Indicates whether the additionalText property that can be set on sap.ui.core.ListItems shall be displayed, or not.
 boolean isEditable()
          Getter for property editable Value "true" makes the listbox interactive.
 boolean isEnabled()
          Getter for property enabled Disabled controls have another color display depending on custom settings.
 boolean isIndexSelected(int index)
          Returns whether the given index is selected.
 boolean isVisible()
          Getter for property visible Invisible controls are not rendered.
 void removeAllItems()
          Removes all the items in the items-aggregation.
 void removeItem(int index)
          Removes the item at position index in the items-aggregation named.
 void removeSelectedIndex(int index)
          Removes the given index from this selection.
 void scrollToIndex(int index, boolean lazy)
          If the ListBox has a scrollbar because the number of items is larger than the number of visible items, this method scrolls to the item with the given index.
 void setAllowMultiSelect(boolean value)
          Setter for property allowMultiSelect
Default value is: false
 void setDisplayIcons(boolean value)
          Setter for property displayIcons
Default value is: false
 void setDisplaySecondaryValues(boolean value)
          Setter for property displaySecondaryValues
Default value is: false
 void setEditable(boolean value)
          Setter for property editable
Default value is: true
 void setEnabled(boolean value)
          Setter for property enabled
Default value is: true
 void setHeight(String value)
          Setter for property height
 ListBox setItems(com.sap.ui.core.client.js.JsArray<com.sap.ui.core.client.ListItem> items, boolean destroyItems)
          Allows setting the list items for this instance of ListBox as array.
 void setMaxWidth(String value)
          Setter for property maxWidth
 void setMinWidth(String value)
          Setter for property minWidth
 void setScrollTop(int value)
          Setter for property scrollTop
Default value is: -1
 void setSecondaryValueTextAlign(com.sap.ui.core.client.TextAlign value)
          Setter for property secondaryValueTextAlign
Default value is: Begin
 void setSelectedIndex(int index)
          Sets the zero-based index of the currently selected item.
 void setSelectedIndices(Integer[] indices)
          Zero-based indices of selected items, wrapped in an array.
 void setValueTextAlign(com.sap.ui.core.client.TextAlign value)
          Setter for property valueTextAlign
Default value is: Begin
 void setVisible(boolean value)
          Setter for property visible
Default value is: true
 void setVisibleItems(int value)
          Setter for property visibleItems
Default value is:
 void setWidth(String value)
          Setter for property width
 
Methods inherited from class com.sap.ui.core.client.ControlWidget
destroy, doAttachChildren, doDetachChildren, isDesignTime, wrap
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
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, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, sinkBitlessEvent, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListBoxWidget

public ListBoxWidget()
constructs the class ListBoxWidget


ListBoxWidget

public ListBoxWidget(String id)
constructs the class ListBoxWidget

Parameters:
id - id of the ListBoxWidget

ListBoxWidget

protected ListBoxWidget(ListBox control)
constructs the class ListBoxWidget

Parameters:
control - reference to an existing ListBox
Method Detail

getControl

public ListBox getControl()
returns the reference to the Phoenix Control

Overrides:
getControl in class com.sap.ui.core.client.ControlWidget
Returns:
reference to the Phoenix Control

isEditable

public boolean isEditable()
Getter for property editable Value "true" makes the listbox interactive.

Returns:
the value of property editable

setEditable

public void setEditable(boolean value)
Setter for property editable
Default value is: true

Parameters:
value - boolean

isEnabled

public boolean isEnabled()
Getter for property enabled Disabled controls have another color display depending on custom settings.

Returns:
the value of property enabled

setEnabled

public void setEnabled(boolean value)
Setter for property enabled
Default value is: true

Parameters:
value - boolean

isAllowMultiSelect

public boolean isAllowMultiSelect()
Getter for property allowMultiSelect Specifies whether multiple selection is allowed.

Returns:
the value of property allowMultiSelect

setAllowMultiSelect

public void setAllowMultiSelect(boolean value)
Setter for property allowMultiSelect
Default value is: false

Parameters:
value - boolean

isVisible

public boolean isVisible()
Getter for property visible Invisible controls are not rendered.

Overrides:
isVisible in class com.google.gwt.user.client.ui.UIObject
Returns:
the value of property visible

setVisible

public void setVisible(boolean value)
Setter for property visible
Default value is: true

Overrides:
setVisible in class com.google.gwt.user.client.ui.UIObject
Parameters:
value - boolean

getWidth

public String getWidth()
Getter for property width Control width as common CSS-size (px or % as unit, for example). The setting overrides any definitions made for the setVisibleItems() method.

Returns:
the value of property width

setWidth

public void setWidth(String value)
Setter for property width

Overrides:
setWidth in class com.google.gwt.user.client.ui.UIObject
Parameters:
value - String

getHeight

public String getHeight()
Getter for property height Control height as common CSS-size (px or % as unit, for example). The setting overrides any definitions made for the setVisibleItems() method.

Returns:
the value of property height

setHeight

public void setHeight(String value)
Setter for property height

Overrides:
setHeight in class com.google.gwt.user.client.ui.UIObject
Parameters:
value - String

getScrollTop

public int getScrollTop()
Getter for property scrollTop Scrollbar position from the top. Setting the scrollTop property and calling scrollToIndex are two operations influencing the same "physical" property, so the last call "wins".

Returns:
the value of property scrollTop

setScrollTop

public void setScrollTop(int value)
Setter for property scrollTop
Default value is: -1

Parameters:
value - int

isDisplayIcons

public boolean isDisplayIcons()
Getter for property displayIcons Defines whether the icons of the list items should also be displayed. Enabling icons causes some space to be reserved for them, regardless of how many of the items actually have icons assigned. Displaying icons can also influence the width and height of a single item, which affects the height of the ListBox when it is defined in number of items. In particular with differently-sized icons the total ListBox height will not accomodte exactly the given number of items, then.

Returns:
the value of property displayIcons

setDisplayIcons

public void setDisplayIcons(boolean value)
Setter for property displayIcons
Default value is: false

Parameters:
value - boolean

isDisplaySecondaryValues

public boolean isDisplaySecondaryValues()
Getter for property displaySecondaryValues Indicates whether the additionalText property that can be set on sap.ui.core.ListItems shall be displayed, or not.

Returns:
the value of property displaySecondaryValues

setDisplaySecondaryValues

public void setDisplaySecondaryValues(boolean value)
Setter for property displaySecondaryValues
Default value is: false

Parameters:
value - boolean

getValueTextAlign

public com.sap.ui.core.client.TextAlign getValueTextAlign()
Getter for property valueTextAlign The text alignment in the primary column of the ListBox.

Returns:
the value of property valueTextAlign

setValueTextAlign

public void setValueTextAlign(com.sap.ui.core.client.TextAlign value)
Setter for property valueTextAlign
Default value is: Begin

Parameters:
value - com.sap.ui.core.client.TextAlign

getSecondaryValueTextAlign

public com.sap.ui.core.client.TextAlign getSecondaryValueTextAlign()
Getter for property secondaryValueTextAlign The text alignment in the secondary (optional) text column of the ListBox.

Returns:
the value of property secondaryValueTextAlign

setSecondaryValueTextAlign

public void setSecondaryValueTextAlign(com.sap.ui.core.client.TextAlign value)
Setter for property secondaryValueTextAlign
Default value is: Begin

Parameters:
value - com.sap.ui.core.client.TextAlign

getMinWidth

public String getMinWidth()
Getter for property minWidth The minimum width of the ListBox. If not set, there is no minimum width.

Returns:
the value of property minWidth

setMinWidth

public void setMinWidth(String value)
Setter for property minWidth

Parameters:
value - String

getMaxWidth

public String getMaxWidth()
Getter for property maxWidth The maximum width of the ListBox. If not set, there is no maximum width.

Returns:
the value of property maxWidth

setMaxWidth

public void setMaxWidth(String value)
Setter for property maxWidth

Parameters:
value - String

getVisibleItems

public int getVisibleItems()
Getter for property visibleItems The control height in number of items to be completely displayed without scrolling. Setting this overwrites any height in terms of CSS size previously set. When items have different heights, the height of the first item is used for all calculations. If between the visible ListBox items there are one or more separators, the specified number of items will not exactly fit. If the value is retrieved it will equal the previously set value if it was set, otherwise it will be the number of items completely fitting into the ListBox without scrolling if the control was already rendered. If the control was not rendered, the behavior is undefined, it may return -1 or any other number.

Returns:
the value of property visibleItems

setVisibleItems

public void setVisibleItems(int value)
Setter for property visibleItems
Default value is:

Parameters:
value - int

getItems

public com.sap.ui.core.client.js.JsArray<com.sap.ui.core.client.Item> getItems()
Getter for aggregation items Aggregation of items to be displayed. Must be either of type sap.ui.core.ListItem or sap.ui.core.SeparatorItem.

Returns:
com.sap.ui.core.client.Item[]

insertItem

public void insertItem(com.sap.ui.core.client.Item item,
                       int index)
Inserts some item into the aggregation named items.

Parameters:
item - the item to insert
index - int the 0-based index the item should be inserted at.

addItem

public void addItem(com.sap.ui.core.client.Item item)
Appends some item to the items-aggregation.

Parameters:
item - com.sap.ui.core.client.Item the item to add

removeItem

public void removeItem(int index)
Removes the item at position index in the items-aggregation named.

Parameters:
index - int the position of the item to remove.

removeAllItems

public void removeAllItems()
Removes all the items in the items-aggregation.


indexOfItem

public int indexOfItem(com.sap.ui.core.client.Item item)
Checks for the provided com.sap.ui.core.client.Item in the items-aggregation and returns its index if found or -1 otherwise.

Parameters:
item - the item whose index is looked for.
Returns:
the index of the provided control in the aggregation.

destroyItems

public void destroyItems()
Destroys all the items in the Items-aggregation.


attachSelectEvent

public void attachSelectEvent(com.sap.ui.core.client.event.EventListener listener)
attach an EventListener Event is fired when selection is changed by user interaction.
Event Parameters:
{string} id ID of the ListBox which triggered the event.
{int} selectedIndex The currently selected index of the ListBox. In case of multiselect this is ONE of the selected indices (the one whose selection has triggered the selection change); use "selectedIndices" to get all currently selected indices.
{sap.ui.core/Item} selectedItem The currently selected item of the ListBox. In case of multiselect this is ONE of the selected items (the one whose selection has triggered the selection change).
{int[]} selectedIndices Array containing the indices which are selected.

Parameters:
listener - reference to the EventListener

detachSelectEvent

public void detachSelectEvent(com.sap.ui.core.client.event.EventListener listener)
detach an EventListener Event is fired when selection is changed by user interaction.

Parameters:
listener - reference to the EventListener

getSelectedIndex

public int getSelectedIndex()
Zero-based index of selected item. Index value for no selection is -1. When multi-selection is enabled and multiple items are selected, the method returns the first selected item.


setSelectedIndex

public void setSelectedIndex(int index)
Sets the zero-based index of the currently selected item. This method removes any previous selections. When the given index is invalid, the call is ignored.

Parameters:
index - Index to be selected.

addSelectedIndex

public void addSelectedIndex(int index)
Adds the given index to current selection. When multi-selection is disabled, this replaces the current selection. When the given index is invalid, the call is ignored.

Parameters:
index - Index to add to selection.

removeSelectedIndex

public void removeSelectedIndex(int index)
Removes the given index from this selection. When the index is invalid or not selected, the call is ignored.

Parameters:
index - Index that shall be removed from selection.

getSelectedIndices

public Integer[] getSelectedIndices()
Zero-based indices of selected items, wrapped in an array. An empty array means "no selection".


setSelectedIndices

public void setSelectedIndices(Integer[] indices)
Zero-based indices of selected items, wrapped in an array. An empty array means "no selection". When multi-selection is disabled and multiple items are given, the selection is set to the index of the first valid index in the given array. Any invalid indices are ignored.

Parameters:
indices - Indices of the items to be selected.

addSelectedIndices

public void addSelectedIndices(Integer[] indices)
Adds the given indices to selection. Any invalid indices are ignored.

Parameters:
indices - Indices of the items that shall additionally be selected.

isIndexSelected

public boolean isIndexSelected(int index)
Returns whether the given index is selected.

Parameters:
index - Index which is checked for selection state.

getSelectedItem

public com.sap.ui.core.client.Item getSelectedItem()
Returns selected item. When no item is selected, "null" is returned. When multi-selection is enabled and multiple items are selected, only the first selected item is returned.


getSelectedItems

public com.sap.ui.core.client.js.JsArray<com.sap.ui.core.client.Item> getSelectedItems()
Returns an array containing the selected items. In the case of no selection, an empty array is returned.


clearSelection

public void clearSelection()
Removes complete selection.


scrollToIndex

public void scrollToIndex(int index,
                          boolean lazy)
If the ListBox has a scrollbar because the number of items is larger than the number of visible items, this method scrolls to the item with the given index. If there are enough items, this item will then appear at the topmost visible position in the ListBox. If bLazy is true, it only scrolls as far as required to make the item visible. Setting the scrollTop property and calling scrollToIndex are two operations influencing the same "physical" property, so the last call "wins".

Parameters:
index - The index to which the ListBox should scroll.
lazy - If set to true, the ListBox only scrolls if the item is not completely visible, and it scrolls just enough to make it fully visible. If set to false (and by default), the item is scrolled to the top position if possible.

setItems

public ListBox setItems(com.sap.ui.core.client.js.JsArray<com.sap.ui.core.client.ListItem> items,
                        boolean destroyItems)
Allows setting the list items for this instance of ListBox as array.

Parameters:
items - The items to set for this ListBox.
destroyItems - Optional boolean parameter to indicate that the formerly set items should be destroyed instead of just removed. If omitted defaults to false, i.e. no not destroy.


Copyright © 2011 SAP. All Rights Reserved.