org.wings
Class SComboBox

java.lang.Object
  extended by org.wings.SComponent
      extended by org.wings.SComboBox
All Implemented Interfaces:
ItemSelectable, Serializable, Cloneable, EventListener, ListDataListener, LowLevelEventListener, Renderable

public class SComboBox
extends SComponent
implements LowLevelEventListener, ListDataListener, ItemSelectable

Combobox widget to be used inside SForm elements.

Author:
Holger Engels
See Also:
ComboBoxModel, SListCellRenderer, Serialized Form

Field Summary
protected  String actionCommand
          action command to fire
protected  ComboBoxModel dataModel
          The model.
protected  int maximumRowCount
          how many rows are displayed in the popup window
protected  SListCellRenderer renderer
          The renderer used for cell rendering each cell.
protected  Object selectedItemReminder
          This protected field is implementation specific.
 
Fields inherited from class org.wings.SComponent
DONE_RENDERING, dynamicStyles, enabled, propertyChangeSupport, SELECTOR_ALL, START_RENDERING, visible, WHEN_FOCUSED_OR_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_FRAME
 
Constructor Summary
SComboBox()
          Creates a SComboBox with a default data model.
SComboBox(ComboBoxModel model)
          Creates a SComboBox that takes its items from an existing ComboBoxModel.
SComboBox(Object[] items)
          Creates a SComboBox that contains the elements in the specified array.
SComboBox(Vector items)
          Creates a SComboBox that contains the elements in the specified Vector.
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds an ActionListener.
 void addItem(Object object)
          Adds an item to the item list.
 void addItemListener(ItemListener listener)
          Adds an ItemListener.
 void contentsChanged(ListDataEvent e)
          This method is public as an implementation side effect.
protected  void fireActionEvent()
          Notify all listeners that have registered as ActionListeners if the selected item has changed
 void fireFinalEvents()
          Internal event trigger used by CGs.
 void fireIntermediateEvents()
          fire events which describes a "in progress" state change, like TreeWillExpand, or ListSelectionEvent with getIsAdjusting() true, ...
protected  void fireItemStateChanged(ItemEvent e)
          Notify all listeners that have registered as ItemListeners.
 String getActionCommand()
          Returns the action commnand that is included in the event sent to action listeners.
 ActionListener[] getActionListeners()
          Returns an array of all the ActionListeners added to this SComboBox
 SCellRendererPane getCellRendererPane()
           
 Object getItemAt(int index)
          Returns the list item at the specified index.
 int getItemCount()
          Returns the number of items in the list.
 ItemListener[] getItemListeners()
          Returns an array of all the ItemListeners added to this SComboBox
 int getMaximumRowCount()
          Returns the size-attribute
 ComboBoxModel getModel()
          Returns the data model currently used by the SComboBox.
 SListCellRenderer getRenderer()
           
 int getSelectedIndex()
          Returns the index of the currently selected item in the list.
 Object getSelectedItem()
          Returns the currently selected item.
 Object[] getSelectedObjects()
          Returns an array containing the selected item.
 String getSelectionParameter(int index)
           
 void insertItemAt(Object object, int index)
          Inserts an item into the item list at a given index.
 void intervalAdded(ListDataEvent e)
          Invoked when items have been added to the internal data model.
 void intervalRemoved(ListDataEvent e)
          Invoked when values have been removed from the data model.
 boolean isEpochCheckEnabled()
          Asks the low-level event listener if epoch checking should be perfomed on it.
 void processLowLevelEvent(String action, String[] values)
          Deliver low level/http events (parameters).
 void removeActionListener(ActionListener listener)
          Removes an ActionListener
 void removeAllItems()
          Removes all items from the item list.
 void removeItem(Object object)
          Removes an item from the item list.
 void removeItemAt(int index)
          Removes the item at index
 void removeItemListener(ItemListener listener)
          Removes an ItemListener
protected  void selectedItemChanged()
          This protected method is implementation specific.
 void setActionCommand(String command)
          Sets the action commnand that should be included in the event sent to action listeners.
 void setCG(ComboBoxCG cg)
           
 void setEpochCheckEnabled(boolean epochCheckEnabled)
           
 void setMaximumRowCount(int count)
          Sets the maximum number of rows the SComboBox displays.
 void setModel(ComboBoxModel model)
          Sets the data model that the SComboBox uses to obtain the list of items.
 void setParent(SContainer p)
          Sets the parent container.
protected  void setParentFrame(SFrame f)
          Sets the parent frame.
 void setRenderer(SListCellRenderer newRenderer)
           
 void setSelectedIndex(int index)
          Selects the item at index index.
 void setSelectedItem(Object object)
          Sets the selected item in the SComboBox.
 
Methods inherited from class org.wings.SComponent
addComponentListener, addDynamicStyle, addEventListener, addNotify, addParentFrameListener, addPropertyChangeListener, addPropertyChangeListener, addRenderListener, addScriptListener, addStyle, clone, fireComponentChangeEvent, fireKeyEvents, fireRenderEvent, getActionMap, getBackground, getBorder, getCG, getClientProperty, getComponentPopupMenu, getDynamicStyle, getDynamicStyles, getFocusTraversalIndex, getFont, getForeground, getHorizontalAlignment, getInputMap, getInputMap, getListenerCount, getListenerList, getListeners, getLowLevelEventId, getName, getParent, getParentFrame, getPreferredSize, getRequestURL, getResidesInForm, getScriptListenerList, getScriptListeners, getSession, getShowAsFormComponent, getStyle, getToolTipText, getVerticalAlignment, invite, isDifferent, isEnabled, isFocusOwner, isRecursivelyVisible, isReloadForced, isUpdatePossible, isVisible, paramString, processComponentEvent, processKeyEvents, putClientProperty, reload, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, removeComponentListener, removeDynamicStyle, removeEventListener, removeNotify, removeParentFrameListener, removePropertyChangeListener, removePropertyChangeListener, removeRenderListener, removeScriptListener, removeStyle, requestFocus, scrollRectToVisible, setActionMap, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setBackground, setBorder, setCG, setComponentPopupMenu, setDynamicStyles, setEnabled, setFocusTraversalIndex, setFont, setForeground, setHorizontalAlignment, setInputMap, setInputMap, setName, setNameRaw, setPreferredSize, setReloadForced, setShowAsFormComponent, setStyle, setToolTipText, setVerticalAlignment, setVisible, toString, update, updateCG, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.wings.LowLevelEventListener
getLowLevelEventId, getName, isEnabled
 

Field Detail

dataModel

protected ComboBoxModel dataModel
The model.

See Also:
ComboBoxModel

renderer

protected SListCellRenderer renderer
The renderer used for cell rendering each cell.

See Also:
SListCellRenderer

maximumRowCount

protected int maximumRowCount
how many rows are displayed in the popup window


actionCommand

protected String actionCommand
action command to fire


selectedItemReminder

protected Object selectedItemReminder
This protected field is implementation specific. Do not access directly or override.

Constructor Detail

SComboBox

public SComboBox(ComboBoxModel model)
Creates a SComboBox that takes its items from an existing ComboBoxModel.

Parameters:
model - the ComboBoxModel that provides the displayed list of items

SComboBox

public SComboBox(Object[] items)
Creates a SComboBox that contains the elements in the specified array.


SComboBox

public SComboBox(Vector items)
Creates a SComboBox that contains the elements in the specified Vector.


SComboBox

public SComboBox()
Creates a SComboBox with a default data model. The default data model is an empty list of objects. Use addItem to add items.

Method Detail

setModel

public void setModel(ComboBoxModel model)
Sets the data model that the SComboBox uses to obtain the list of items.

Parameters:
model - the ComboBoxModel that provides the displayed list of items

getModel

public final ComboBoxModel getModel()
Returns the data model currently used by the SComboBox.

Returns:
the ComboBoxModel that provides the displayed list of items

setMaximumRowCount

public void setMaximumRowCount(int count)
Sets the maximum number of rows the SComboBox displays. If shown as a formComponent, this value is used for the size-attribute.

Parameters:
count - size-attribute

getMaximumRowCount

public int getMaximumRowCount()
Returns the size-attribute

Returns:
the value used for the size-attribute

setRenderer

public void setRenderer(SListCellRenderer newRenderer)
Parameters:
newRenderer - the SListCellRenderer that displays the selected item.

getRenderer

public SListCellRenderer getRenderer()
Returns:
the ListCellRenderer that displays the selected item.

setSelectedItem

public void setSelectedItem(Object object)
Sets the selected item in the SComboBox.

Parameters:
object - the list object to select

getSelectedItem

public Object getSelectedItem()
Returns the currently selected item.

Returns:
the currently selected list object from the data model

setSelectedIndex

public void setSelectedIndex(int index)
Selects the item at index index.

Parameters:
index - the item to be selected

getSelectedIndex

public int getSelectedIndex()
Returns the index of the currently selected item in the list.

Returns:
the selected item in the list or -1 if no item is selected or if the currently selected item (text field) is not in the list

addItem

public void addItem(Object object)
Adds an item to the item list.

Parameters:
object - the Object to add to the list

insertItemAt

public void insertItemAt(Object object,
                         int index)
Inserts an item into the item list at a given index.

Parameters:
object - the Object to add to the list
index - an int specifying the position at which to add the item

removeItem

public void removeItem(Object object)
Removes an item from the item list. This method works only if the SComboBox uses the default data model. SComboBox uses the default data model when created with the empty constructor and no other model has been set.

Parameters:
object - the object to remove from the item list

removeItemAt

public void removeItemAt(int index)
Removes the item at index

Parameters:
index - an int specifying the idex of the item to remove, where 0 indicates the first item in the list

removeAllItems

public void removeAllItems()
Removes all items from the item list.


addItemListener

public void addItemListener(ItemListener listener)
Adds an ItemListener. The listener will receive an action event when the user changed the selection.

Specified by:
addItemListener in interface ItemSelectable
Parameters:
listener - the ItemListener that is to be notified

removeItemListener

public void removeItemListener(ItemListener listener)
Removes an ItemListener

Specified by:
removeItemListener in interface ItemSelectable
Parameters:
listener - the ItemListener to remove

getItemListeners

public ItemListener[] getItemListeners()
Returns an array of all the ItemListeners added to this SComboBox

Returns:
all ItemListeners added or an empty array if there are no such listeners

addActionListener

public void addActionListener(ActionListener listener)
Adds an ActionListener. The listener will receive an action event when the user changed the selection.

Parameters:
listener - the ActionListener that is to be notified

removeActionListener

public void removeActionListener(ActionListener listener)
Removes an ActionListener

Parameters:
listener - the ActionListener to remove

getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the ActionListeners added to this SComboBox

Returns:
all ActionListeners added or an empty array if there are no such listeners

setActionCommand

public void setActionCommand(String command)
Sets the action commnand that should be included in the event sent to action listeners.

Parameters:
command - a string containing the "command" that is sent to action listeners. The same listener can then do different things depending on the command it receives.

getActionCommand

public String getActionCommand()
Returns the action commnand that is included in the event sent to action listeners.

Returns:
the string containing the "command" that is sent to action listeners.

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent e)
Notify all listeners that have registered as ItemListeners.

See Also:
EventListenerList

fireActionEvent

protected void fireActionEvent()
Notify all listeners that have registered as ActionListeners if the selected item has changed

See Also:
EventListenerList

getSelectedObjects

public Object[] getSelectedObjects()
Returns an array containing the selected item.

Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
an array of Objects containing the selected item

contentsChanged

public void contentsChanged(ListDataEvent e)
This method is public as an implementation side effect. do not call or override.

Specified by:
contentsChanged in interface ListDataListener
See Also:
ListDataListener

intervalAdded

public void intervalAdded(ListDataEvent e)
Invoked when items have been added to the internal data model. The "interval" includes the first and last values added.

Specified by:
intervalAdded in interface ListDataListener
See Also:
ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent e)
Invoked when values have been removed from the data model. The"interval" includes the first and last values removed.

Specified by:
intervalRemoved in interface ListDataListener
See Also:
ListDataListener

getItemCount

public int getItemCount()
Returns the number of items in the list.

Returns:
an int equal to the number of items in the list

getItemAt

public Object getItemAt(int index)
Returns the list item at the specified index.

Parameters:
index - an int indicating the list position
Returns:
the Object at that list position

selectedItemChanged

protected void selectedItemChanged()
This protected method is implementation specific. Do not access directly or override.


processLowLevelEvent

public void processLowLevelEvent(String action,
                                 String[] values)
Description copied from interface: LowLevelEventListener
Deliver low level/http events (parameters). The name-value-pairs of the HTTPRequest are considered low level events.

Specified by:
processLowLevelEvent in interface LowLevelEventListener
Overrides:
processLowLevelEvent in class SComponent
Parameters:
action - the name-value-pair's name
values - the name-value-pair's values

setParent

public void setParent(SContainer p)
Description copied from class: SComponent
Sets the parent container. Also gets the parent frame from the parent.

Overrides:
setParent in class SComponent
Parameters:
p - the container

setParentFrame

protected void setParentFrame(SFrame f)
Description copied from class: SComponent
Sets the parent frame.

Overrides:
setParentFrame in class SComponent
Parameters:
f - the frame

fireIntermediateEvents

public void fireIntermediateEvents()
Description copied from interface: LowLevelEventListener
fire events which describes a "in progress" state change, like TreeWillExpand, or ListSelectionEvent with getIsAdjusting() true, ...

Specified by:
fireIntermediateEvents in interface LowLevelEventListener

fireFinalEvents

public void fireFinalEvents()
Description copied from class: SComponent
Internal event trigger used by CGs. This Method is called internal and should not be called directly

Specified by:
fireFinalEvents in interface LowLevelEventListener
Overrides:
fireFinalEvents in class SComponent

isEpochCheckEnabled

public boolean isEpochCheckEnabled()
Description copied from interface: LowLevelEventListener
Asks the low-level event listener if epoch checking should be perfomed on it. If true the Dispatcher will ignore request originating from old views (typically iniated by triggering browser back and clicking somewhere.)

Specified by:
isEpochCheckEnabled in interface LowLevelEventListener
Returns:
true if epoch checking should be perfomed, false if all request for this component should be processed.
See Also:
LowLevelEventListener.isEpochCheckEnabled()

setEpochCheckEnabled

public void setEpochCheckEnabled(boolean epochCheckEnabled)
See Also:
LowLevelEventListener.isEpochCheckEnabled()

getCellRendererPane

public final SCellRendererPane getCellRendererPane()

setCG

public void setCG(ComboBoxCG cg)

getSelectionParameter

public String getSelectionParameter(int index)


wingS Swings ;-)