Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.4.0)

E13403-05

oracle.ide.controls.checkboxlist
Class CheckBoxListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by oracle.ide.controls.checkboxlist.CheckBoxListModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ListModel, Copyable

public class CheckBoxListModel
extends javax.swing.AbstractListModel
implements Copyable

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
CheckBoxListModel()
           
CheckBoxListModel(java.lang.Object[] userObjects)
          Creates CheckBoxListCellData objects for each element of the userObjects array with no icon, no checkbox, and a label set to whatever is returned by userObject.toString()
CheckBoxListModel(java.lang.Object[] userObjects, boolean hasCheckBox)
          Creates CheckBoxListCellData objects for each element of the userObjects array with no icon and a checkbox initially set to false
CheckBoxListModel(java.lang.Object[] userObjects, boolean hasCheckBox, boolean checkBoxState)
          Creates CheckBoxListCellData objects for each element of the userObjects array with no icon and a checkbox initially set to the value of checkBoxState
CheckBoxListModel(java.lang.Object[] userObjects, javax.swing.Icon icon, boolean hasCheckBox)
          Creates CheckBoxListCellData objects for each element of the userObjects array with the specified icon and a checkbox if hasCheckBox is true.
CheckBoxListModel(java.lang.Object[] userObjects, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState)
          Creates CheckBoxListCellData objects for each element of the userObjects array with the specified icon and a checkbox if hasCheckBox is true and an the checkbox is intialized to checkBoxState.
 
Method Summary
 void addCheckBoxStateListener(CheckBoxListItemStateListener listener)
          Adds the listener to each element in the list.
 void addElement(java.lang.Object userObject, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState)
          Adds an element to the model with the specified userObject and icon.
 void addElement(java.lang.Object userObject, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState, java.lang.String label)
          Adds an element to the model with the specified userObject and icon.
 void addElement(java.lang.Object userObject, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState, java.lang.String label, java.lang.String toolTipText)
          Adds an element to the model with the specified userObject and icon.
 void addElement(java.lang.Object userObject, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState, java.lang.String groupId, java.lang.String label, java.lang.String toolTipText)
           
 void addElement(java.lang.Object userObject, javax.swing.Icon icon, java.lang.String groupId, boolean hasCheckBox, boolean checkBoxState, boolean isGroupTitle, java.lang.String toolTip)
           
 void addElement(java.lang.Object userObject, javax.swing.Icon icon, java.lang.String label, java.lang.String toolTipText)
          Adds an element to the model with the specified userObject, icon, label and toolTipText.
 void addElementAt(int position, java.lang.Object userObject, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState)
           
 void addElementAt(int position, java.lang.Object userObject, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState, java.lang.String label)
           
 void addElementAt(int position, java.lang.Object userObject, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState, java.lang.String label, java.lang.String toolTipText)
           
 void addElementAt(int position, java.lang.Object userObject, javax.swing.Icon icon, boolean hasCheckBox, boolean checkBoxState, java.lang.String groupId, java.lang.String label, java.lang.String toolTipText)
           
 void addElementAt(int position, java.lang.Object userObject, javax.swing.Icon icon, java.lang.String groupId, boolean hasCheckBox, boolean checkBoxState, boolean isGroupTitle, java.lang.String toolTip)
           
 void addElementAt(int position, java.lang.Object userObject, javax.swing.Icon icon, java.lang.String label, java.lang.String toolTipText)
           
 void clear()
          Remove all elements from this ListModel
 java.lang.Object copyTo(java.lang.Object target)
          Copies the internal state of this object to the specified copy.
protected  void copyToImpl(CheckBoxListModel copy)
           
 void deselectAll()
          Sets the state of the checkbox to unchecked for all rows in the model.
 void deselectAllSelectables()
          Sets the state of the checkbox to unchecked for all rows in the model (only for checkboxes that are actually selectable.)
 int elementsWithCheckBoxCount()
           
 boolean equals(java.lang.Object o)
           
protected  boolean equalsImpl(CheckBoxListModel other)
           
 int findElementByText(java.lang.String value)
          Returns the index of the element with label equals to the specified value.
 java.lang.String findTextForElement(int index)
          Returns the String for the specified element.
 void findUserObjectAndMark(java.lang.Object findObject, boolean selectObject)
          Searches the model for a userObject that equals the specified findObject and sets the state of the checkbox for that element to checked or unchecked based on the value of selectObject.
 java.lang.Object getElementAt(int index)
          Gets the object at the specified index.
 java.util.List getSelectionList()
          This method should be called to get a list of userObjects for rows that have been selected in the CheckBoxList.
 int getSize()
          The number of elements in the model.
 java.lang.String getToolTipTextForElement(int index)
          Gets the string used to represent the tooltip for the specified element.
 java.lang.Object getUserObjectAt(int index)
          Returns the userObject from the model element at the specified index.
 boolean isElementSelected(int index)
          Returns true of the element at the specified index has been checked.
 void putCheckBoxListCellDataAt(int index, CheckBoxListCellData data)
           
 void removeElementByIndex(int index)
          Removes the element from the model with the index specified by index.
 void removeElementByText(java.lang.String value)
          Removes the element from the model where the label equals the specified value.
 void selectAll()
          Sets the state of the checkbox to checked for all rows in the model.
 void selectAllSelectables()
          Sets the state of the checkbox to checked for all rows in the model (only for checkboxes that are actually selectable.)
 void setCheckBoxVisible(boolean checkboxVisible, boolean checkboxState)
          Goes through the model and sets each element to make the checkbox displayed or not based on the value of checkboxVisible.
 void setElementSelected(int index)
          Sets the element at the specified index to checked.
 void sort()
          Sorts the elements in the model according to the label.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckBoxListModel

public CheckBoxListModel()

CheckBoxListModel

public CheckBoxListModel(java.lang.Object[] userObjects)
Creates CheckBoxListCellData objects for each element of the userObjects array with no icon, no checkbox, and a label set to whatever is returned by userObject.toString()

Parameters:
userObjects - the array of objects to store in the CheckBoxListModel

CheckBoxListModel

public CheckBoxListModel(java.lang.Object[] userObjects,
                         javax.swing.Icon icon,
                         boolean hasCheckBox)
Creates CheckBoxListCellData objects for each element of the userObjects array with the specified icon and a checkbox if hasCheckBox is true. If hasCheckBox == true then the checkbox state will be set to false

Parameters:
userObjects - the array of objects to store in the CheckBoxListModel
icon - the Icon to display for all the entries
hasCheckBox - true if a checkbox should be displayed; false otherwise

CheckBoxListModel

public CheckBoxListModel(java.lang.Object[] userObjects,
                         javax.swing.Icon icon,
                         boolean hasCheckBox,
                         boolean checkBoxState)
Creates CheckBoxListCellData objects for each element of the userObjects array with the specified icon and a checkbox if hasCheckBox is true and an the checkbox is intialized to checkBoxState.

Parameters:
userObjects - the array of objects to store in the CheckBoxListModel
icon - the Icon to display for all the entries
hasCheckBox - true if a checkbox should be displayed; false otherwise
checkBoxState - the initial state of the checkbox

CheckBoxListModel

public CheckBoxListModel(java.lang.Object[] userObjects,
                         boolean hasCheckBox)
Creates CheckBoxListCellData objects for each element of the userObjects array with no icon and a checkbox initially set to false

Parameters:
userObjects - the array of objects to store in the CheckBoxListModel
hasCheckBox - true if a checkbox should be displayed; false otherwise

CheckBoxListModel

public CheckBoxListModel(java.lang.Object[] userObjects,
                         boolean hasCheckBox,
                         boolean checkBoxState)
Creates CheckBoxListCellData objects for each element of the userObjects array with no icon and a checkbox initially set to the value of checkBoxState

Parameters:
userObjects - the array of objects to store in the CheckBoxListModel
hasCheckBox - true if a checkbox should be displayed; false otherwise
checkBoxState - the initial state fo the checkbox
Method Detail

addElement

public void addElement(java.lang.Object userObject,
                       javax.swing.Icon icon,
                       java.lang.String label,
                       java.lang.String toolTipText)
Adds an element to the model with the specified userObject, icon, label and toolTipText. No checkbox will be displayed.

Parameters:
userObject - the userObject portion of the data
icon - the Icon to display
label - the String to display in the CheckBoxList
toolTipText - the text to display as a tooltip

addElementAt

public void addElementAt(int position,
                         java.lang.Object userObject,
                         javax.swing.Icon icon,
                         java.lang.String label,
                         java.lang.String toolTipText)

addElement

public void addElement(java.lang.Object userObject,
                       javax.swing.Icon icon,
                       boolean hasCheckBox,
                       boolean checkBoxState)
Adds an element to the model with the specified userObject and icon. A checkbox will be displayed if hasCheckBox is true and it will take the initial state specified by checkBoxState.

Parameters:
userObject - the userObject portion of the data
icon - the Icon to display
hasCheckBox - true if a checkbox is to be displayed; false otherwise
checkBoxState - true if the checkbox should initially be checked; false otherwise.

addElement

public void addElement(java.lang.Object userObject,
                       javax.swing.Icon icon,
                       java.lang.String groupId,
                       boolean hasCheckBox,
                       boolean checkBoxState,
                       boolean isGroupTitle,
                       java.lang.String toolTip)

addElementAt

public void addElementAt(int position,
                         java.lang.Object userObject,
                         javax.swing.Icon icon,
                         java.lang.String groupId,
                         boolean hasCheckBox,
                         boolean checkBoxState,
                         boolean isGroupTitle,
                         java.lang.String toolTip)

addElementAt

public void addElementAt(int position,
                         java.lang.Object userObject,
                         javax.swing.Icon icon,
                         boolean hasCheckBox,
                         boolean checkBoxState)

addElement

public void addElement(java.lang.Object userObject,
                       javax.swing.Icon icon,
                       boolean hasCheckBox,
                       boolean checkBoxState,
                       java.lang.String label)
Adds an element to the model with the specified userObject and icon. A checkbox will be displayed if hasCheckBox is true and it will take the initial state specified by checkBoxState. It will be displayed with the label set to the value of label, but will not have any tooltip.

Parameters:
userObject - the userObject portion of the data
icon - the Icon to display
hasCheckBox - true if a checkbox is to be displayed; false otherwise
checkBoxState - true if the checkbox should initially be checked; false otherwise.
label - the label to display in the CheckBoxList

addElementAt

public void addElementAt(int position,
                         java.lang.Object userObject,
                         javax.swing.Icon icon,
                         boolean hasCheckBox,
                         boolean checkBoxState,
                         java.lang.String label)

addElement

public void addElement(java.lang.Object userObject,
                       javax.swing.Icon icon,
                       boolean hasCheckBox,
                       boolean checkBoxState,
                       java.lang.String label,
                       java.lang.String toolTipText)
Adds an element to the model with the specified userObject and icon. A checkbox will be displayed if hasCheckBox is true and it will take the intial state specified by checkBoxState. It will be displayed with the label set to the value of label and will have the tooltip specified by toolTipText.

Parameters:
userObject - the userObject portion of the data
icon - the Icon to display
hasCheckBox - true if a checkbox is to be displayed; false otherwise
checkBoxState - true if the checkbox should initially be checked; false otherwise.
label - the label to display in the CheckBoxList
toolTipText - the text to display as a tooltip

addElement

public void addElement(java.lang.Object userObject,
                       javax.swing.Icon icon,
                       boolean hasCheckBox,
                       boolean checkBoxState,
                       java.lang.String groupId,
                       java.lang.String label,
                       java.lang.String toolTipText)

addElementAt

public void addElementAt(int position,
                         java.lang.Object userObject,
                         javax.swing.Icon icon,
                         boolean hasCheckBox,
                         boolean checkBoxState,
                         java.lang.String label,
                         java.lang.String toolTipText)

addElementAt

public void addElementAt(int position,
                         java.lang.Object userObject,
                         javax.swing.Icon icon,
                         boolean hasCheckBox,
                         boolean checkBoxState,
                         java.lang.String groupId,
                         java.lang.String label,
                         java.lang.String toolTipText)

addCheckBoxStateListener

public void addCheckBoxStateListener(CheckBoxListItemStateListener listener)
Adds the listener to each element in the list.


selectAll

public void selectAll()
Sets the state of the checkbox to checked for all rows in the model.


selectAllSelectables

public void selectAllSelectables()
Sets the state of the checkbox to checked for all rows in the model (only for checkboxes that are actually selectable.)


deselectAll

public void deselectAll()
Sets the state of the checkbox to unchecked for all rows in the model.


deselectAllSelectables

public void deselectAllSelectables()
Sets the state of the checkbox to unchecked for all rows in the model (only for checkboxes that are actually selectable.)


getSelectionList

public java.util.List getSelectionList()
This method should be called to get a list of userObjects for rows that have been selected in the CheckBoxList. **Note** This method only works when the CheckBoxList is used to display rows that have a checkbox displayed since it checks the state of the checkbox.


elementsWithCheckBoxCount

public int elementsWithCheckBoxCount()

findUserObjectAndMark

public void findUserObjectAndMark(java.lang.Object findObject,
                                  boolean selectObject)
Searches the model for a userObject that equals the specified findObject and sets the state of the checkbox for that element to checked or unchecked based on the value of selectObject.

Parameters:
findObject - the userObject to find in the model
selectObject - true if the row should be marked as checked; false otherwise.

isElementSelected

public boolean isElementSelected(int index)
Returns true of the element at the specified index has been checked. **Note** It makes no sense to call this method if the model elements have not been created with hasCheckBox = true.

Parameters:
index - the index of the element that should be tested to see if it's marked as checked

setElementSelected

public void setElementSelected(int index)
Sets the element at the specified index to checked. **Note** It makes no sense to call this method if the model elements have not been created with hasCheckBox = true.

Parameters:
index - the index of the element that should be marked as checked

getUserObjectAt

public java.lang.Object getUserObjectAt(int index)
Returns the userObject from the model element at the specified index.

Parameters:
index - the index of the element in the CheckBoxList
Returns:
the userObject stored in the model at the specified index

setCheckBoxVisible

public void setCheckBoxVisible(boolean checkboxVisible,
                               boolean checkboxState)
Goes through the model and sets each element to make the checkbox displayed or not based on the value of checkboxVisible. It also sets the state of the checkbox to checked or unchecked based on the value of checkboxState.

Parameters:
checkboxVisible - true if checkboxes should be displayed in the CheckBoxList; false otherwise
checkboxState - true if the checkbox should be checked; false otherwise

sort

public void sort()
Sorts the elements in the model according to the label.


clear

public void clear()
Remove all elements from this ListModel


removeElementByText

public void removeElementByText(java.lang.String value)
Removes the element from the model where the label equals the specified value.

Parameters:
value - the String representation of the element to be removed from the CheckBoxListModel

removeElementByIndex

public void removeElementByIndex(int index)
Removes the element from the model with the index specified by index.

Parameters:
index - the index of the element that should be removed from the CheckBoxListModel

findElementByText

public int findElementByText(java.lang.String value)
Returns the index of the element with label equals to the specified value.

Parameters:
value - the displayed string to find in the CheckBoxListModel
Returns:
the position of the element with the String value specified; -1 if no such element is found.

findTextForElement

public java.lang.String findTextForElement(int index)
Returns the String for the specified element.

Parameters:
index - the index of the element
Returns:
the String value used for display for the specified element index

getToolTipTextForElement

public java.lang.String getToolTipTextForElement(int index)
Gets the string used to represent the tooltip for the specified element.

Parameters:
index - the position of the element to find the tooltip for
Returns:
the tooltip for the specified index

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

equalsImpl

protected final boolean equalsImpl(CheckBoxListModel other)

putCheckBoxListCellDataAt

public void putCheckBoxListCellDataAt(int index,
                                      CheckBoxListCellData data)

getElementAt

public java.lang.Object getElementAt(int index)
Gets the object at the specified index. This returns the CheckBoxListCellData element.

Specified by:
getElementAt in interface javax.swing.ListModel
Parameters:
index - the position of the value to be found

getSize

public int getSize()
The number of elements in the model.

Specified by:
getSize in interface javax.swing.ListModel
Returns:
the number of elements in the model

copyTo

public java.lang.Object copyTo(java.lang.Object target)
Description copied from interface: Copyable
Copies the internal state of this object to the specified copy. If copy is null, then this method should create a new instance of this class and proceed to copy the internal state to the newly created object. Generally, only the persistent state of the object should be copied, but whether or not it is appropriate to copy transient properties is at the discretion of the individual implementor.

Regardless of whether the copy occurs to an existing object or to a newly created object, the return value is object to which this object's state was copied.

There is a standard implementation pattern for the copyTo method that helps avoid problems that arise when a Copyable object is subclassed. The pattern is:


    public Object copyTo( Object target )
    {
      final <this_class> copy =
        target != null ? (<this_class>) target : new <this_class>();
      copyToImpl( copy );
      return copy;
    }

    protected final void copyToImpl( <this_class> copy )
    {
      super.copyToImpl( copy );  //  if necessary
      //  put code here for copying the properties of <this_class>
    }
  
The parameter passed into the copyToImpl method is the same type of this class. The responsibility of copyToImpl is to copy the state of this class through direct access of the fields. The copyToImpl method should not use getters and setters since these may be overridden, causing the state of this class to be incompletely copied.

Specified by:
copyTo in interface Copyable
Parameters:
target - The target object to which the state of this object should be copied. If target is null, then the copyTo method will return a new instance of this class.
Returns:
The object to which the state of this object was copied. If the target was non-null, then the return value is the same as the target object that was passed in; otherwise, the return value is a new instance of this class.

copyToImpl

protected final void copyToImpl(CheckBoxListModel copy)

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.4.0)

E13403-05

Copyright © 1997, 2011, Oracle. All rights reserved.