com.sas.swing.visuals
Class TriStateCheckBoxListSelectionModel

com.sas.swing.visuals.TriStateCheckBoxListSelectionModel
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.ListSelectionModel

public class TriStateCheckBoxListSelectionModel

Default data model for TriStateCheckBoxList selections. Instead of setting a new selection no matter what their currently selected state is as in regular listboxes, new selections have their values incremented in the selection list based on their current selection state and whether cycling is enabled.

See Also:
TriStateCheckBoxList, Serialized Form

Field Summary
protected  boolean cycleEnabled
          Whether the checkBox cycles through all three values
protected  boolean updateEnabled
          Used internally to signal when values can be updated.
 
Fields inherited from class com.sas.swing.visuals.CheckBoxListSelectionModel
isAdjusting, RB_KEY, selectionMode
 
Constructor Summary
TriStateCheckBoxListSelectionModel()
           
 
Method Summary
 void addMixedSelectionInterval(int index0, int index1)
          Sets all of the values to MIXED for all indices within range.
 void addSelectionInterval(int index0, int index1)
          Sets all of the values to ON for all indices within range.
 void clearSelection()
          Sets all of the values to OFF for all indices.
 int getSelectedIndexValue(int index)
          Returns the value at the given index.
 void insertIndexInterval(int index, int length, boolean before)
          Insert length indices beginning before/after index.
 boolean isCycleEnabled()
          Returns whether the checkbox cycles through all three values.
 boolean isUpdateEnabled()
          Used internally to return whether values can be updated.
 void removeIndexInterval(int index0, int index1)
          Remove the indices in the interval index0,index1 (inclusive) from the selection model.
 void removeSelectionInterval(int index0, int index1)
          Sets all of the values to OFF for all indices within range.
 void setCycleEnabled(boolean b)
          Sets whether each checkBox in the list should cycle through all three values.
protected  void setMixedState(int index, boolean state)
          Sets the given index to the given mixed state.
 void setSelectedIndexValue(int index, int value)
          Sets the given index to the given value.
protected  void setSelectedState(int index, boolean state)
          Sets the given index to the given selected state.
 void setSelectionInterval(int index0, int index1)
          Increments the values of all indices within the range if update is enabled.
protected  void setStates(int index, boolean mixedState, boolean selectedState)
          Sets the given index to the given mixed and selected state.
 void setUpdateEnabled(boolean b)
          Used internally to set whether values can be updated.
 
Methods inherited from class com.sas.swing.visuals.CheckBoxListSelectionModel
getValueIsAdjusting, setSelectionMode, setValueIsAdjusting
 

Field Detail

cycleEnabled

protected boolean cycleEnabled
Whether the checkBox cycles through all three values


updateEnabled

protected boolean updateEnabled
Used internally to signal when values can be updated.

Constructor Detail

TriStateCheckBoxListSelectionModel

public TriStateCheckBoxListSelectionModel()
Method Detail

setSelectedIndexValue

public void setSelectedIndexValue(int index,
                                  int value)
Sets the given index to the given value.

Parameters:
index - The index in which to change
value - The new value to be set

getSelectedIndexValue

public int getSelectedIndexValue(int index)
Returns the value at the given index.

Parameters:
index - The index to search on
Returns:
The current value

setSelectionInterval

public void setSelectionInterval(int index0,
                                 int index1)
Increments the values of all indices within the range if update is enabled.

Specified by:
setSelectionInterval in interface javax.swing.ListSelectionModel
Overrides:
setSelectionInterval in class CheckBoxListSelectionModel
Parameters:
index0 - The beginning index
index1 - The ending index

addMixedSelectionInterval

public void addMixedSelectionInterval(int index0,
                                      int index1)
Sets all of the values to MIXED for all indices within range.

Parameters:
index0 - The beginning index
index1 - The ending index

addSelectionInterval

public void addSelectionInterval(int index0,
                                 int index1)
Sets all of the values to ON for all indices within range.

Specified by:
addSelectionInterval in interface javax.swing.ListSelectionModel
Overrides:
addSelectionInterval in class javax.swing.DefaultListSelectionModel
Parameters:
index0 - The beginning index
index1 - The ending index

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)
Sets all of the values to OFF for all indices within range.

Specified by:
removeSelectionInterval in interface javax.swing.ListSelectionModel
Overrides:
removeSelectionInterval in class javax.swing.DefaultListSelectionModel
Parameters:
index0 - The beginning index
index1 - The ending index

clearSelection

public void clearSelection()
Sets all of the values to OFF for all indices.

Specified by:
clearSelection in interface javax.swing.ListSelectionModel
Overrides:
clearSelection in class javax.swing.DefaultListSelectionModel

insertIndexInterval

public void insertIndexInterval(int index,
                                int length,
                                boolean before)
Insert length indices beginning before/after index. If the value at index is itself selected, set all of the newly inserted items, otherwise leave them unselected. This method is typically called to sync the selection model with a corresponding change in the data model.

Specified by:
insertIndexInterval in interface javax.swing.ListSelectionModel
Overrides:
insertIndexInterval in class javax.swing.DefaultListSelectionModel

removeIndexInterval

public void removeIndexInterval(int index0,
                                int index1)
Remove the indices in the interval index0,index1 (inclusive) from the selection model. This is typically called to sync the selection model width a corresponding change in the data model. Note that (as always) index0 need not be <= index1.

Specified by:
removeIndexInterval in interface javax.swing.ListSelectionModel
Overrides:
removeIndexInterval in class javax.swing.DefaultListSelectionModel

setStates

protected void setStates(int index,
                         boolean mixedState,
                         boolean selectedState)
Sets the given index to the given mixed and selected state.


setMixedState

protected void setMixedState(int index,
                             boolean state)
Sets the given index to the given mixed state.


setSelectedState

protected void setSelectedState(int index,
                                boolean state)
Sets the given index to the given selected state.


setCycleEnabled

public void setCycleEnabled(boolean b)
Sets whether each checkBox in the list should cycle through all three values.

Parameters:
b - if true, the checkBox cycles, or else the checkBox switches between ON and OFF once those values have been reached.

isCycleEnabled

public boolean isCycleEnabled()
Returns whether the checkbox cycles through all three values.


setUpdateEnabled

public void setUpdateEnabled(boolean b)
Used internally to set whether values can be updated.


isUpdateEnabled

public boolean isUpdateEnabled()
Used internally to return whether values can be updated.




Copyright © 2009 SAS Institute Inc. All Rights Reserved.