com.sas.visuals
Class SelectionGroup

com.sas.visuals.SelectionGroup
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.collection.CollectionInterface, com.sas.collection.ContentsChangedSource, com.sas.collection.OrderedCollectionInterface, com.sas.collection.Sortable, com.sas.collection.StaticCollectionInterface, com.sas.collection.StaticOrderedCollectionInterface, com.sas.ComponentInterface, com.sas.DeepClonable, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, com.sas.PublicClonable, com.sas.util.Countable, com.sas.util.Enumerable, com.sas.util.EventGateInterface, IndexedGetInterface, IndexedSetInterface, com.sas.ViewInterface, MultipleValueEventSourceInterface, SelectionGroupInterface, java.awt.ItemSelectable, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class SelectionGroup
implements java.beans.PropertyChangeListener, SelectionGroupInterface

SelectionGroup is a class used to group and manipulate SelectableInterface objects. SelectableInterface objects have a buttonModel that holds the selected state for that SelectableInterface object. The SelectionGroup handles setting the state of the buttonModel when the SelectableInterface object is selected or deselected. The SelectionGroup is a non-visual group of objects that can be visual or not.

Notes:


See Also:
SelectableInterface, Serialized Form

Field Summary
static java.lang.String RB_KEY
           
 
Constructor Summary
SelectionGroup()
          The Default Constructor
 
Method Summary
 void add(java.lang.Object selectableObject)
          Adds a SelectableInterface object to the SelectionGroup.
 void add(java.lang.Object selectableObject, int index)
          Adds a SelectableInterface object to the SelectionGroup at the specified index.
 void addItemListener(java.awt.event.ItemListener l)
          Add a listener to receive item events when the state of an item changes.
 void addItems(java.util.Enumeration items)
          Add all items in the specified Enumeration.
 void addItems(java.util.Enumeration items, int index)
          Add all items in the specified Enumeration at the specified index.
 boolean containsItem(java.lang.Object item)
          Test for the presence of an object set as the item property on one of the SelectableInterface objects in the collection.
 com.sas.util.transforms.TransformInterface getDisplayTransform()
          Gets the transform used to change the item property for display on the SelectableInterface.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this SelectionGroup.
 int getIndex(SelectableInterface selectableObject)
          Gets the index of the specified SelectableInterface object.
 com.sas.util.transforms.TransformInterface getInputTransform()
          Gets the transform used to change the item property for input to the SelectableInterface.
 java.lang.Object getItem(int index)
          Gets the Item object of the SelectableInterface object at the specified index.
 int getItemIndex(java.lang.Object item)
          Gets the index of the SelectableInterface object with the specified item property.
 java.util.Enumeration getItemsData()
          Gets an enumeration of the objects used as item properties on the SelectableInterface objects.
 com.sas.util.transforms.TransformInterface getOutputTransform()
          Gets the transform used to change the item property for output on the SelectableInterface.
 int getSelectedIndex()
          Gets the index of the selected SelectableInterface.
 java.lang.Object getSelectedItem()
          Gets the item property of the selected SelectableInterface.
 java.lang.Object[] getSelectedObjects()
          Gets the selected SelectableInterface object.
 boolean isDeselectable()
          Returns whether or not the SelectionGroup can have no SelectableInterface objects selected.
protected  void processItemEvent(java.awt.event.ItemEvent e)
          Processes item events occurring on this checkbox by dispatching them to any registered ItemListener objects.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Handles any property changes on the transforms.
 boolean remove(java.lang.Object selectableObject)
          Remove a SelectableInterface from the SelectionGroup.
 void removeAll()
          Remove all SelectableInterface objects from the SelectionGroup.
 java.lang.Object removeAt(int index)
          Remove the SelectableInterface object at the specified index from the SelectionGroup.
 void removeItemListener(java.awt.event.ItemListener l)
          Removes an item listener.
 void select(SelectableInterface selectableObject)
          Select the specified SelectableInterface object.
 void set(int index, java.lang.Object selectableObject)
          Sets the selectableObject at the specified index.
 void setDefaultValues()
          This method sets the initial values to the default values.
 void setDeselectable(boolean deselect)
          Sets the SelectionGroup to deselectable, so all of the SelectableInterface objects can be deselected at the same time.
 void setDisplayTransform(com.sas.util.transforms.TransformInterface transform)
          Sets the transform used to change the item property for display on the SelectableInterface.
 void setInputTransform(com.sas.util.transforms.TransformInterface transform)
          Sets the transform used to change the item property for input to the SelectionGroup.
 void setOutputTransform(com.sas.util.transforms.TransformInterface transform)
          Sets the transform used to change the item property for output from the SelectionGroup.
 void setSelectedIndex(int index)
          Sets the selected SelectableInterface based on the specified index.
 void setSelectedItem(java.lang.Object selectedItem)
          Sets the selected SelectableInterface based on the item.
 
Methods inherited from interface com.sas.util.Enumerable
getItems
 
Methods inherited from interface com.sas.util.IndexedGetInterface
get
 
Methods inherited from interface com.sas.util.Countable
count
 

Field Detail

RB_KEY

public static java.lang.String RB_KEY
Constructor Detail

SelectionGroup

public SelectionGroup()
The Default Constructor

Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this SelectionGroup.

Returns:
the ExtendedBeanInfo for this class

add

public void add(java.lang.Object selectableObject)
Adds a SelectableInterface object to the SelectionGroup. The object is added as the last object in the OrderedCollection.

Specified by:
add in interface com.sas.collection.CollectionInterface
Overrides:
add in class com.sas.collection.OrderedCollection
Parameters:
selectableObject - the SelectableInterface object to add to the group.

add

public void add(java.lang.Object selectableObject,
                int index)
Adds a SelectableInterface object to the SelectionGroup at the specified index.

Specified by:
add in interface com.sas.collection.OrderedCollectionInterface
Overrides:
add in class com.sas.collection.OrderedCollection
Parameters:
selectableObject - the SelectableInterface to add to the group.
index - the index at which to add the SelectableInterface.

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Add a listener to receive item events when the state of an item changes.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
l - the listener to recieve events.

addItems

public void addItems(java.util.Enumeration items)
Add all items in the specified Enumeration. The objects are added at the end of the OrderedCollection.

Specified by:
addItems in interface com.sas.collection.CollectionInterface
Overrides:
addItems in class com.sas.collection.OrderedCollection
Parameters:
items - an Enumeration of SelectableInterface objects to add.

addItems

public void addItems(java.util.Enumeration items,
                     int index)
Add all items in the specified Enumeration at the specified index.

Specified by:
addItems in interface com.sas.collection.OrderedCollectionInterface
Overrides:
addItems in class com.sas.collection.OrderedCollection
Parameters:
items - an Enumeration of SelectableInterface objects to add.
index - the index to add the items at.

containsItem

public boolean containsItem(java.lang.Object item)
Test for the presence of an object set as the item property on one of the SelectableInterface objects in the collection. The item is transformed using the inputTransform before the search.

Specified by:
containsItem in interface SelectionGroupInterface
Parameters:
item - the item to search for
Returns:
true if item is found, false otherwise.
See Also:
OrderedCollection.contains(java.lang.Object)

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Gets the selected SelectableInterface object. For compatibility with java.awt.ItemSelectable.

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
a one element array containing the selected SelectableInterface object.

getDisplayTransform

public com.sas.util.transforms.TransformInterface getDisplayTransform()
Gets the transform used to change the item property for display on the SelectableInterface.

Specified by:
getDisplayTransform in interface SelectionGroupInterface
Returns:
the transform used on the item property of the SelectableInterface.
See Also:
setDisplayTransform(com.sas.util.transforms.TransformInterface)

getInputTransform

public com.sas.util.transforms.TransformInterface getInputTransform()
Gets the transform used to change the item property for input to the SelectableInterface.

Specified by:
getInputTransform in interface SelectionGroupInterface
Returns:
the transform used on the item property of the SelectableInterface.
See Also:
setInputTransform(com.sas.util.transforms.TransformInterface)

getItemsData

public java.util.Enumeration getItemsData()
Gets an enumeration of the objects used as item properties on the SelectableInterface objects. The item objects are transformed first using the outputTransform before being returned.

Specified by:
getItemsData in interface SelectionGroupInterface
Returns:
an Enumeration of the item properties on the SelectableInterface objects.

getItem

public java.lang.Object getItem(int index)
Gets the Item object of the SelectableInterface object at the specified index. The item object is transformed using the outputTransform before being returned.

Specified by:
getItem in interface SelectionGroupInterface
Parameters:
index - the index of the SelectableInterface object to get.
Returns:
the transformed item of the SelectableInterface object at index.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of bounds

getOutputTransform

public com.sas.util.transforms.TransformInterface getOutputTransform()
Gets the transform used to change the item property for output on the SelectableInterface.

Specified by:
getOutputTransform in interface SelectionGroupInterface
Returns:
the transform used on the item property of the SelectableInterface.
See Also:
setOutputTransform(com.sas.util.transforms.TransformInterface)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Handles any property changes on the transforms.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class com.sas.Component
Parameters:
event - property event that was changed
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

setDisplayTransform

public void setDisplayTransform(com.sas.util.transforms.TransformInterface transform)
Sets the transform used to change the item property for display on the SelectableInterface.

Specified by:
setDisplayTransform in interface SelectionGroupInterface
Parameters:
transform - the new TransformInterface for the displayTransform
See Also:
getDisplayTransform()

setInputTransform

public void setInputTransform(com.sas.util.transforms.TransformInterface transform)
Sets the transform used to change the item property for input to the SelectionGroup.

Specified by:
setInputTransform in interface SelectionGroupInterface
Parameters:
transform - the new TransformInterface for the inputTransform
See Also:
getInputTransform()

setOutputTransform

public void setOutputTransform(com.sas.util.transforms.TransformInterface transform)
Sets the transform used to change the item property for output from the SelectionGroup.

Specified by:
setOutputTransform in interface SelectionGroupInterface
Parameters:
transform - the new TransformInterface for the outputTransform
See Also:
getOutputTransform()

getIndex

public int getIndex(SelectableInterface selectableObject)
Gets the index of the specified SelectableInterface object.

Specified by:
getIndex in interface SelectionGroupInterface
Parameters:
selectableObject - the SelectableInterface to get the index of
Returns:
the index of the selectableObject or -1 if not found
See Also:
getItemIndex(java.lang.Object)

getItemIndex

public int getItemIndex(java.lang.Object item)
Gets the index of the SelectableInterface object with the specified item property. The item is transformed using the inputTransform before the search.

Specified by:
getItemIndex in interface SelectionGroupInterface
Parameters:
selectableObject - the SelectableInterface item property value to get the index of
Returns:
the index of the SelectableInterface object with the specifed item property or -1 if not found
See Also:
getItem(int)

getSelectedItem

public java.lang.Object getSelectedItem()
Gets the item property of the selected SelectableInterface. The item is transformed using the outputTransform before being returned.

Specified by:
getSelectedItem in interface SelectionGroupInterface
Returns:
the item property of the selected SelectableInterface object or null if no object is selected.
See Also:
setSelectedItem(java.lang.Object)

getSelectedIndex

public int getSelectedIndex()
Gets the index of the selected SelectableInterface.

Specified by:
getSelectedIndex in interface SelectionGroupInterface
Returns:
the index of the selected SelectableInterface, or -1 if no SelectableInterface is selected.
See Also:
setSelectedIndex(int)

isDeselectable

public boolean isDeselectable()
Returns whether or not the SelectionGroup can have no SelectableInterface objects selected.

Specified by:
isDeselectable in interface SelectionGroupInterface
Returns:
true, when all SelectableInterface objects in the group can be deselected at the same time, false when one SelectableInterface object must be selected.
See Also:
setDeselectable(boolean)

processItemEvent

protected void processItemEvent(java.awt.event.ItemEvent e)
Processes item events occurring on this checkbox by dispatching them to any registered ItemListener objects.

Parameters:
e - the item event

remove

public boolean remove(java.lang.Object selectableObject)
Remove a SelectableInterface from the SelectionGroup.

Specified by:
remove in interface com.sas.collection.CollectionInterface
Overrides:
remove in class com.sas.collection.OrderedCollection
Parameters:
selectableObject - the specific SelectableInterface to remove from the group.
Returns:
true if the object was removed, false if the object was not in the SelectionGroup

removeAll

public void removeAll()
Remove all SelectableInterface objects from the SelectionGroup. Will set all SelectableInterface SelectionGroups to "null".

Specified by:
removeAll in interface com.sas.collection.CollectionInterface
Overrides:
removeAll in class com.sas.collection.OrderedCollection

removeAt

public java.lang.Object removeAt(int index)
Remove the SelectableInterface object at the specified index from the SelectionGroup.

Specified by:
removeAt in interface com.sas.collection.OrderedCollectionInterface
Overrides:
removeAt in class com.sas.collection.OrderedCollection
Parameters:
index - the index of the SelectableInterface object to remove from the group.
Returns:
the SelectableInterface object removed.

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Removes an item listener.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
l - the item listener to remove

select

public void select(SelectableInterface selectableObject)
Select the specified SelectableInterface object. This fires a vetoableChange event that can stop the selection of the specified object.

Specified by:
select in interface SelectionGroupInterface
Parameters:
selectableObject - the SelectableInterface object to set the selected state to true.

set

public void set(int index,
                java.lang.Object selectableObject)
Sets the selectableObject at the specified index. Removes the previous object and adds the new one at the index.

Specified by:
set in interface com.sas.collection.OrderedCollectionInterface
Specified by:
set in interface IndexedSetInterface
Overrides:
set in class com.sas.collection.OrderedCollection
Parameters:
index - the index of the selectableObject value to set
selectableObject - the new value at index.

setDefaultValues

public void setDefaultValues()
This method sets the initial values to the default values. This method is called by the Component constructors. The setDefaultValues method of each class is responsible for setting its own initial values.

Specified by:
setDefaultValues in interface com.sas.ComponentInterface
Overrides:
setDefaultValues in class com.sas.Component
See Also:
ComponentInterface.setDefaultValues()

setDeselectable

public void setDeselectable(boolean deselect)
Sets the SelectionGroup to deselectable, so all of the SelectableInterface objects can be deselected at the same time.

Specified by:
setDeselectable in interface SelectionGroupInterface
Parameters:
deselect - if true, all SelectableInterface objects can be deselected.
See Also:
isDeselectable()

setSelectedItem

public void setSelectedItem(java.lang.Object selectedItem)
Sets the selected SelectableInterface based on the item. The inputTransform will be used on the selectedItem before the search for the SelectableInterface object.

Specified by:
setSelectedItem in interface SelectionGroupInterface
Parameters:
selectedItem - the item of the SelectableInterface to set selected.
See Also:
getSelectedItem()

setSelectedIndex

public void setSelectedIndex(int index)
Sets the selected SelectableInterface based on the specified index.

Specified by:
setSelectedIndex in interface SelectionGroupInterface
Parameters:
index - the index of the SelectableInterface to set selected.
See Also:
getSelectedIndex()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.