Packagecom.developmentarc.framework.controllers
Classpublic class SelectionController

Provides a set of controls that allows any object that implement ISelectable to behave as a selection group. This Controller allows a you to generate a group id and then group ISelectable items using this id value. Once a group has been defined a you can then select a single item in the group and the other items will be deselected similarlary to a radio group, you can deselect all items or select items when using mutliple select.

Items can be selected outside of the SelectionController and the selection of other items will not be modified unless the selection action is made through the SelectionController. This allows developers to create multi-selectable groupings and only when the selection of a specific item, group deselection or group selection is required should the SelectionController be used.



Public Methods
 MethodDefined by
  
addItem(item:ISelectable, groupId:int):void
[static] Adds a Selectable item to a specificed group id.
SelectionController
  
[static] This method removes all items and groups from the SelectionController.
SelectionController
  
deselectAll(group:int):void
[static] Used to deselect all items in a selection group.
SelectionController
  
[static] Used to generate a unique group id.
SelectionController
  
getAllItemsInGroup(group:int):Array
[static] Returns a list of items that are members of the provided group.
SelectionController
  
[static] Returns the specified item's group id number.
SelectionController
  
getSelected(groupId:int):Array
[static] Method returns an array of all currently selected items in the specified group.
SelectionController
  
removeAllItems(groupId:int):void
[static] Removes all the items and the group id from the controller.
SelectionController
  
[static] Removes the item from the manager and the boung group.
SelectionController
  
selectAll(group:int):void
[static] Used to select all the items within a selection group.
SelectionController
  
[static] Sets the selected property for the specified item and deselects any other items within the same group as the specified item.
SelectionController
Method detail
addItem()method
public static function addItem(item:ISelectable, groupId:int):void

Adds a Selectable item to a specificed group id. The group id should be a unique id that defines the group the item belongs to. Use the generateNewId() method on this class to generate a unique that the id which is not in use within the manager.

If an item is already assigne to a group id this method will remove the item from the previous group and re-assign the item to a new group. Items can only be assigned to one group id within the SelectionController.

Parameters
item:ISelectable — The item to add to the group.
 
groupId:int — The group id to add the item to.
clearAllGroups()method 
public static function clearAllGroups():void

This method removes all items and groups from the SelectionController. This method is considered a full reset and removes all references and group ids from the instance.

deselectAll()method 
public static function deselectAll(group:int):void

Used to deselect all items in a selection group. This method sets the selected value on all the group items to false.

Parameters
group:int
generateNewId()method 
public static function generateNewId():int

Used to generate a unique group id. This should be called when creating a new g rouping to verify that the provided id is unique in the system.

Returns
int — A unique generated group id.
getAllItemsInGroup()method 
public static function getAllItemsInGroup(group:int):Array

Returns a list of items that are members of the provided group. This is a cloned array of the internal list and modifying the order or content of the Array will not affect group membership or order. If the provided group id is not used or found then an empty Array is returned.

Parameters
group:int — The group id to lookup.

Returns
Array — The list of ISelectable items bound to the provided group.
getItemGroup()method 
public static function getItemGroup(item:ISelectable):int

Returns the specified item's group id number. This method looks up the item in the SelectionController and provides the group id that is currently assigned to an item. If the item is not being tracked / assigned to a group id then the value -1 is returned which represents no group id.

Parameters
item:ISelectable — Item to look group up on.

Returns
int — The group the item is a member of.
getSelected()method 
public static function getSelected(groupId:int):Array

Method returns an array of all currently selected items in the specified group.

Parameters
groupId:int — group id.

Returns
Array — An Array containing all items currently selected.
removeAllItems()method 
public static function removeAllItems(groupId:int):void

Removes all the items and the group id from the controller.

Parameters
groupId:int — The group to remove the items from.
removeItem()method 
public static function removeItem(item:ISelectable):void

Removes the item from the manager and the boung group. If the item is the last of the group, the group is removed from the SelectionController and is no longer considered a valid group id. The group id can be re-used when calling addItem() but verify that the no other items are assigned to the group at the time of reuse.

Parameters
item:ISelectable — The item to remove from the group.
selectAll()method 
public static function selectAll(group:int):void

Used to select all the items within a selection group. This method sets the selected value on all the group items to true.

Parameters
group:int — The selection group to select.
selectItem()method 
public static function selectItem(item:ISelectable):void

Sets the selected property for the specified item and deselects any other items within the same group as the specified item. This method is responsible for looking up the group id for the specified item. If the item is not within a defined group which is being tracked by the SelectionController then only the provided item will be selected and the any other items in the SelectionController will be unaffected.

Parameters
item:ISelectable — The item to select.