Business Components

oracle.jbo.uicli.jui
Class JUComboBoxBinding

java.lang.Object
  |
  +--oracle.jbo.uicli.binding.JUControlBinding
        |
        +--oracle.jbo.uicli.binding.JUCtrlValueBinding
              |
              +--oracle.jbo.uicli.binding.JUCtrlAttrsBinding
                    |
                    +--oracle.jbo.uicli.binding.JUCtrlListBinding
                          |
                          +--oracle.jbo.uicli.jui.JUComboBoxBinding
All Implemented Interfaces:
java.awt.event.ActionListener, AttributeList, javax.swing.ComboBoxModel, java.util.EventListener, javax.swing.ListModel, javax.swing.MutableComboBoxModel, RowNavigationListener, RowSetListener

public class JUComboBoxBinding
extends JUCtrlListBinding
implements java.awt.event.ActionListener, javax.swing.MutableComboBoxModel

Implements binding a swing JComboBox to a BC4J Attribute or ViewObject or as LOV.

A combobox can be bound in the following ways:

  • display a single or multiple attributes for rows in a RowSet and iterate the rowset currency.
  • display a single attribute from rows in a RowSet and update another attribute in a different ViewObject.
  • display a single or multiple attributes from rows in a RowSet and update one or multiple attributes in a different ViewObject. (quite like a lov).
  • to display a static list of values and update one attribute in a BC4J row.

    This class also implements ActionListener interface and listens to ActionEvents from the bound combobox. On an action event, it either performs an update of the target ViewObject attributes, or iterates a target ViewObject as per the list operation mode set in the constructor.


    Fields inherited from class oracle.jbo.uicli.binding.JUCtrlListBinding
    LIST_OPER_NAVIGATE, LIST_OPER_SET_ATTRIBUTE, mListAttrNames, mListDisplayAttrNames, mListIterBinding, mStaticList, mValueList
     
    Constructor Summary
    JUComboBoxBinding(javax.swing.JComboBox cb, JUIteratorBinding iterBinding, java.lang.String[] attrNames, int listOperMode)
              Binds a ComboBox to a RowSet associated with the given iterator binding and based on listOperMode setting, either iterates the currency on the target iterator or updates the attribute value for the given attribute (in attrNames) in the current row in the target RowSet.
    JUComboBoxBinding(javax.swing.JComboBox cb, JUIteratorBinding iterBinding, java.lang.String[] attrNames, JUIteratorBinding listIterBinding, java.lang.String[] listAttrNames, java.lang.String[] listDisplayAttrNames)
              Binds separate ViewObject/RowSets for display and update to the same ComboBox.
    JUComboBoxBinding(javax.swing.JComboBox cb, JUIteratorBinding iterBinding, java.lang.String[] attrNames, java.lang.Object[] valueList)
              Binds a combobox to an attribute in the associated RowSet.
     
    Method Summary
    TypeMethod
     void actionPerformed(java.awt.event.ActionEvent e)
              Based on listOperMode, this binding either navigates the target rowset to the selected row or sets the attribute/attributes as per the settings in the constructor.
     void addControlToPanel(java.lang.Object panel, java.lang.Object layoutObject, java.lang.Object layoutCons)
              *** For internal framework use only ***
     void addElement(java.lang.Object obj)
               
     void addListDataListener(javax.swing.event.ListDataListener l)
               
    static javax.swing.MutableComboBoxModel createEnumerationBinding(JUFormBinding formBinding, javax.swing.JComboBox control, java.lang.String voInstanceName, java.lang.String voIterName, java.lang.String voIterBindingName, java.lang.String attrName, java.lang.Object[] values)
              Use this method to bind a combobox control to a ViewObject/RowSet identified by voInstanceName when a static list of values are displayed in the combobox, and the combobox is used to display update the same attribute in the same viewobject.
    static javax.swing.MutableComboBoxModel createLovBinding(JUFormBinding formBinding, javax.swing.JComboBox control, java.lang.String voInstanceName, java.lang.String voIterName, java.lang.String voIterBindingName, java.lang.String[] voAttrNames, java.lang.String lovVOInstanceName, java.lang.String[] lovVOAttrNames, java.lang.String[] lovVODisplayedAttrNames, javax.swing.ListCellRenderer cellRenderer, javax.swing.ComboBoxEditor editor)
              Use this binding when two ViewObjects are to be used in this combobox, one for displaying the list of values and the other ViewObject, rows of which are updated.
    static javax.swing.MutableComboBoxModel createNavigationBinding(JUFormBinding formBinding, javax.swing.JComboBox control, java.lang.String voInstanceName, java.lang.String voIterName, java.lang.String voIterBindingName, java.lang.String[] voAttrNames, javax.swing.ListCellRenderer cellRenderer, javax.swing.ComboBoxEditor editor)
              Use this binding when the given combobox is used as a navigation control to iterate through a range or rows in a RowSet.
     java.lang.Object getElementAt(int index)
               
    static javax.swing.MutableComboBoxModel getInstance(JUFormBinding formBinding, javax.swing.JComboBox control, java.lang.String voInstanceName, java.lang.String voIterName, java.lang.String voIterBindingName, java.lang.String[] voAttrNames, java.lang.String lovVOInstanceName, java.lang.String[] lovVOAttrNames, java.lang.String[] lovVODisplayedAttrNames, javax.swing.ListCellRenderer cellRenderer, javax.swing.ComboBoxEditor editor)
              Deprecated. since 9.0.2 use createEnumerationBinding, createNavigationBinding or createLovBinding instead
    static javax.swing.MutableComboBoxModel getInstance(JUFormBinding formBinding, javax.swing.JComboBox control, java.lang.String voInstanceName, java.lang.String voIterName, java.lang.String voIterBindingName, java.lang.String attrName, java.lang.Object[] values)
              Deprecated. since 9.0.2 use createEnumerationBinding, createNavigationBinding or createLovBinding instead
    protected  javax.swing.MutableComboBoxModel getModelImpl(javax.swing.JComboBox control)
              Sets the model reference in this binding class by using the current model in the combobox.
     java.lang.Object getSelectedItem()
               
     int getSize()
               
     java.lang.Object getValueAt(int attrIndex)
              Returns the currently selected item from the list model.
     void insertElementAt(java.lang.Object obj, int index)
               
     void removeElement(java.lang.Object obj)
               
     void removeElementAt(int index)
               
     void removeListDataListener(javax.swing.event.ListDataListener l)
               
     void setAttribute(int index, java.lang.Object value)
              A Helper method that sets the attribute at the index (into the attrNames array as provided in the constructor) with the given value.
     void setDataValueAt(java.lang.Object value, int attrIndex)
              Should be used by applications to update both the combobox selection and the correpsonding attributes in the current row of the target viewobject.
     void setSelectedIndex(int listIndex)
              Sets the item at the given index as current selection in the listbox.
     void setSelectedItem(java.lang.Object anItem)
               
    protected  void setupListItems(boolean clean, boolean keepSelectedIndex)
              This method is used by the framwork to setup the list of values that will be displayed in this combobox.
     void setValueAt(java.lang.Object value, int attrIndex)
              Finds the item in the combobox that matches the given value and sets it as the current item
     
    Methods inherited from class oracle.jbo.uicli.binding.JUCtrlListBinding
    convertValueList, findListIndex, findMatchingListValue, findValue, getAttrValuesFromRSI, getListOperMode, getSelectedIndex, getSelectedValue, getValueFromList, getValueList, isSingleAttrList, matchTargetWithLov, navigated, rangeRefreshed, rangeScrolled, rowDeleted, rowInserted, rowUpdated, setAttributeFromValueList, setListOperMode, setSingleAttrList, setTargetAttrsFromLovRow, setValueList, updateValuesFromRow
     
    Methods inherited from class oracle.jbo.uicli.binding.JUCtrlAttrsBinding
    updateNavigated, updateRangeScrolled, updateValuesFromRows
     
    Methods inherited from class oracle.jbo.uicli.binding.JUCtrlValueBinding
    findAttributeDef, getAttribute, getAttribute, getAttributeCount, getAttributeDef, getAttributeDefs, getAttributeFromRow, getAttributeFromRow, getAttributeFromRow, getAttributeFromRow, getAttributeFromRow, getAttributeIndexOf, getAttributeNames, isAttributeUpdateable, setAttribute, setAttributeInRow, setAttributeInRow, setAttributeInRow, setAttributeInRow, setAttributeInRow, setAttributeInRow, stopEditing, updateRowDeleted, updateRowInserted
     
    Methods inherited from class oracle.jbo.uicli.binding.JUControlBinding
    executeQuery, executeQueryIfNeeded, getAllRowsInRange, getApplicationModule, getControl, getCurrentRow, getDef, getFormBinding, getIteratorBinding, getLayoutObject, getName, getRowAtRangeIndex, getRowIterator, getTransaction, getViewObject, isControlQueriable, reportException, setFormBinding, setName
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    JUComboBoxBinding

    public JUComboBoxBinding(javax.swing.JComboBox cb,
                             JUIteratorBinding iterBinding,
                             java.lang.String[] attrNames,
                             int listOperMode)
    Binds a ComboBox to a RowSet associated with the given iterator binding and based on listOperMode setting, either iterates the currency on the target iterator or updates the attribute value for the given attribute (in attrNames) in the current row in the target RowSet. Note that the combobox will display and (optionally)udpate the same attribute from a RowSet.
    Parameters:
    cb - ComboBox to associate this binding with.
    iterBinding - provides the RowSet from which this binding accesses data to display in the combobox and optionally the current row in which attribute(s) is to be updated.
    attrNames - an ordered array of attribute names to display and optionally update in a ViewObject.
    listOperMode - Can be one of two values:
  • LIST_OPER_SET_ATTRIBUTE (also the default) to indicate that this combobox is to be used to update attributes in the current row of the associated RowSet.
  • LIST_OPER_NAVIGATE to indicate that this combobox should be used to iterate currency in the associated RowSet.

  • JUComboBoxBinding

    public JUComboBoxBinding(javax.swing.JComboBox cb,
                             JUIteratorBinding iterBinding,
                             java.lang.String[] attrNames,
                             java.lang.Object[] valueList)
    Binds a combobox to an attribute in the associated RowSet. The values displayed in combobox is provided by the valueList objects.
    Parameters:
    cb - ComboBox to associate this binding with.
    iterBinding - provides the RowSet that is used to update current selection from the combobox into the current row in the rowset.
    attrNames - provides the name of an attribute (only one attribute is updateable in this mode).
    valueList - a static list of values that are displayed as options in the combobox to select from.

    JUComboBoxBinding

    public JUComboBoxBinding(javax.swing.JComboBox cb,
                             JUIteratorBinding iterBinding,
                             java.lang.String[] attrNames,
                             JUIteratorBinding listIterBinding,
                             java.lang.String[] listAttrNames,
                             java.lang.String[] listDisplayAttrNames)
    Binds separate ViewObject/RowSets for display and update to the same ComboBox. Use this binding constructor to provide a separate iterator binding for update and a separate iterator binding which provides rows for display in the combobox. Optionally the attributes displayed can be different from the attributes that should be used to update a corresponding set of attributes in the target/updateable ViewObject.

    Parameters:
    cb - ComboBox to associate this binding with.
    iterBinding - provides the RowSet in which the current row is updated based on selection in the combobox.
    attrNames - an ordered array of attribute names to update in a ViewObject. This list should have the same number of attributes as in listAttrNames which provides the corresponding attribute names from the display ViewObject/RowSet.
    listIterBinding - provides the RowSet which is used to display data in the combobox.
    listAttrNames - An ordered list of attribute names which are used to get the values to update into the attributes from the attrNames list in the target ViewObject. If this list is null, the attribute names for display are set the same as attrNames
    listDisplayAttrNames - An ordered list of attribute names that specify the attributes to display from rows in the display ViewObject/RowSet. If this list is null, attribute names are assumed to be same as in attrNames
    Method Detail

    getModelImpl

    protected javax.swing.MutableComboBoxModel getModelImpl(javax.swing.JComboBox control)
    Sets the model reference in this binding class by using the current model in the combobox. Returns the same model reference. If there's no model in the combobox, creates a DefaultComboBoxModel and returns that.

    addControlToPanel

    public void addControlToPanel(java.lang.Object panel,
                                  java.lang.Object layoutObject,
                                  java.lang.Object layoutCons)
    *** For internal framework use only ***
    Overrides:
    addControlToPanel in class JUControlBinding

    setupListItems

    protected void setupListItems(boolean clean,
                                  boolean keepSelectedIndex)
    This method is used by the framwork to setup the list of values that will be displayed in this combobox.
    Overrides:
    setupListItems in class JUCtrlListBinding
    Parameters:
    clean - means whether to clean the existing entries in the combobox.
    keepSelectedIndex - indicates whether to maintain current index as the selected index after the display data is updated. If this value is true, the current index is maintained. However if the current index is more than the number of items in the combobox, the selection is reset to the first item.

    getValueAt

    public java.lang.Object getValueAt(int attrIndex)
    Returns the currently selected item from the list model. This is used by the framework to update the values into the target rowset.
    Overrides:
    getValueAt in class JUCtrlListBinding
    Parameters:
    attrIndex - This argument is ignored by this method

    setValueAt

    public void setValueAt(java.lang.Object value,
                           int attrIndex)
    Finds the item in the combobox that matches the given value and sets it as the current item
    Overrides:
    setValueAt in class JUCtrlAttrsBinding
    Parameters:
    value - This value is used in findMatchingListValue method to find out the item in the combobox that represents the given value. If the value is not found, no item is selected in the list.
    attrIndex - This argument is ignored by this method

    setDataValueAt

    public void setDataValueAt(java.lang.Object value,
                               int attrIndex)
    Should be used by applications to update both the combobox selection and the correpsonding attributes in the current row of the target viewobject.
    Overrides:
    setDataValueAt in class JUCtrlAttrsBinding
    Parameters:
    value - This value is used in findMatchingListValue method to find out the item in the combobox that represents the given value. If the value is not found, no item is selected in the list.
    attrIndex - This argument is ignored by this method

    setSelectedIndex

    public void setSelectedIndex(int listIndex)
    Sets the item at the given index as current selection in the listbox.
    Overrides:
    setSelectedIndex in class JUCtrlListBinding

    setAttribute

    public void setAttribute(int index,
                             java.lang.Object value)
    A Helper method that sets the attribute at the index (into the attrNames array as provided in the constructor) with the given value.
    Overrides:
    setAttribute in class JUCtrlValueBinding
    Following copied from interface: oracle.jbo.AttributeList
    Parameters:
    index - the attribute's index.
    value - the value to be assigned to the attribute.

    actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent e)
    Based on listOperMode, this binding either navigates the target rowset to the selected row or sets the attribute/attributes as per the settings in the constructor.
    Specified by:
    actionPerformed in interface java.awt.event.ActionListener

    setSelectedItem

    public void setSelectedItem(java.lang.Object anItem)
    Specified by:
    setSelectedItem in interface javax.swing.ComboBoxModel

    getSelectedItem

    public java.lang.Object getSelectedItem()
    Specified by:
    getSelectedItem in interface javax.swing.ComboBoxModel

    getSize

    public int getSize()
    Specified by:
    getSize in interface javax.swing.ListModel

    getElementAt

    public java.lang.Object getElementAt(int index)
    Specified by:
    getElementAt in interface javax.swing.ListModel

    addListDataListener

    public void addListDataListener(javax.swing.event.ListDataListener l)
    Specified by:
    addListDataListener in interface javax.swing.ListModel

    removeListDataListener

    public void removeListDataListener(javax.swing.event.ListDataListener l)
    Specified by:
    removeListDataListener in interface javax.swing.ListModel

    addElement

    public void addElement(java.lang.Object obj)
    Specified by:
    addElement in interface javax.swing.MutableComboBoxModel

    removeElement

    public void removeElement(java.lang.Object obj)
    Specified by:
    removeElement in interface javax.swing.MutableComboBoxModel

    insertElementAt

    public void insertElementAt(java.lang.Object obj,
                                int index)
    Specified by:
    insertElementAt in interface javax.swing.MutableComboBoxModel

    removeElementAt

    public void removeElementAt(int index)
    Specified by:
    removeElementAt in interface javax.swing.MutableComboBoxModel

    createEnumerationBinding

    public static javax.swing.MutableComboBoxModel createEnumerationBinding(JUFormBinding formBinding,
                                                                            javax.swing.JComboBox control,
                                                                            java.lang.String voInstanceName,
                                                                            java.lang.String voIterName,
                                                                            java.lang.String voIterBindingName,
                                                                            java.lang.String attrName,
                                                                            java.lang.Object[] values)
    Use this method to bind a combobox control to a ViewObject/RowSet identified by voInstanceName when a static list of values are displayed in the combobox, and the combobox is used to display update the same attribute in the same viewobject.

    getInstance

    public static javax.swing.MutableComboBoxModel getInstance(JUFormBinding formBinding,
                                                               javax.swing.JComboBox control,
                                                               java.lang.String voInstanceName,
                                                               java.lang.String voIterName,
                                                               java.lang.String voIterBindingName,
                                                               java.lang.String attrName,
                                                               java.lang.Object[] values)
    Deprecated. since 9.0.2 use createEnumerationBinding, createNavigationBinding or createLovBinding instead


    createLovBinding

    public static javax.swing.MutableComboBoxModel createLovBinding(JUFormBinding formBinding,
                                                                    javax.swing.JComboBox control,
                                                                    java.lang.String voInstanceName,
                                                                    java.lang.String voIterName,
                                                                    java.lang.String voIterBindingName,
                                                                    java.lang.String[] voAttrNames,
                                                                    java.lang.String lovVOInstanceName,
                                                                    java.lang.String[] lovVOAttrNames,
                                                                    java.lang.String[] lovVODisplayedAttrNames,
                                                                    javax.swing.ListCellRenderer cellRenderer,
                                                                    javax.swing.ComboBoxEditor editor)
    Use this binding when two ViewObjects are to be used in this combobox, one for displaying the list of values and the other ViewObject, rows of which are updated. Optionally, a UI can provide a cell renderer for the list and a editor which can be used to implement ComboBox customization. By default, if this binding method creates an instance of JUMultiAttrListCellRenderer and JUMultiAttrListCellEditor to display and edit LOVs.

    createNavigationBinding

    public static javax.swing.MutableComboBoxModel createNavigationBinding(JUFormBinding formBinding,
                                                                           javax.swing.JComboBox control,
                                                                           java.lang.String voInstanceName,
                                                                           java.lang.String voIterName,
                                                                           java.lang.String voIterBindingName,
                                                                           java.lang.String[] voAttrNames,
                                                                           javax.swing.ListCellRenderer cellRenderer,
                                                                           javax.swing.ComboBoxEditor editor)
    Use this binding when the given combobox is used as a navigation control to iterate through a range or rows in a RowSet. Optionally, a UI can provide a cell renderer for the list and a editor which can be used to implement ComboBox customization. By default, if this binding method creates an instance of JUMultiAttrListCellRenderer and JUMultiAttrListCellEditor to display and edit LOVs.

    getInstance

    public static javax.swing.MutableComboBoxModel getInstance(JUFormBinding formBinding,
                                                               javax.swing.JComboBox control,
                                                               java.lang.String voInstanceName,
                                                               java.lang.String voIterName,
                                                               java.lang.String voIterBindingName,
                                                               java.lang.String[] voAttrNames,
                                                               java.lang.String lovVOInstanceName,
                                                               java.lang.String[] lovVOAttrNames,
                                                               java.lang.String[] lovVODisplayedAttrNames,
                                                               javax.swing.ListCellRenderer cellRenderer,
                                                               javax.swing.ComboBoxEditor editor)
    Deprecated. since 9.0.2 use createEnumerationBinding, createNavigationBinding or createLovBinding instead


    Business Components