Package | twaver |
Class | public class SelectionModel |
Inheritance | SelectionModel ![]() |
With selection model, you can visit all selected data, iterate all selected data, set data to unselected by removing the data from this selection model, etc.
You can set a data selected by setting data's selected
property, or adding a data into this selection model. Always
recommend to use selection model to set data selected status
or check whether a data is selected. The reason is, you can
add filter on selection model, so data.setSelected(true)
will not guarantee the data will be selected. Using
selectionMode.isSelectable(data)
to check whether this
data is really selected is a better idea.
Selection model will dispatch event to all installed listeners when data box selection is changed. Pressing key of "ctrl+a" will select all data, pressing "ctrl" or "shift" and with mouse click can appending/remove data selection on network canvas.
Property | Defined By | ||
---|---|---|---|
count : int [read-only]
Get total count of this selection model. | SelectionModel | ||
filterFunction : Function
Get the filter function. | SelectionModel | ||
firstData : IData [read-only]
Get the first added data of this selection model. | SelectionModel | ||
lastData : IData [read-only]
Get the last added data from this selection model. | SelectionModel | ||
selection : ICollection [read-only]
Get all data contains in this selection model as a collection. | SelectionModel | ||
selectionMode : String
Get current selection mode. | SelectionModel |
Method | Defined By | ||
---|---|---|---|
SelectionModel(dataBox:DataBox)
Constructor. | SelectionModel | ||
addPropertyChangeListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Add property change listener on this selection model. | SelectionModel | ||
addSelectionChangeListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Add selection change listener on this selection model. | SelectionModel | ||
appendSelection(datas:Object):void
Append more data into this selection model. | SelectionModel | ||
clearSelection():void
Clear all data from this selection model. | SelectionModel | ||
Check whether this selection model contains specified
data. | SelectionModel | ||
dispatchPropertyChangeEvent(property:String, oldValue:Object, newValue:Object):Boolean
Dispatch a selection change property to all selection change listeners. | SelectionModel | ||
isSelectable(data:IData):Boolean
Check whether specified data is selected. | SelectionModel | ||
removePropertyChangeListener(listener:Function):void
Remove the specified property change listener from this selection model. | SelectionModel | ||
removeSelection(datas:Object):void
Remove specified data from this selection model. | SelectionModel | ||
removeSelectionChangeListener(listener:Function):void
Remove the specified listener from this selection model. | SelectionModel | ||
selectAll():void
Call this method to select all data contains in the data box. | SelectionModel | ||
setSelection(datas:Object):void
Set all specified data to selected status. | SelectionModel | ||
toSelection(matchFunction:Function = null):ICollection
Get all selected data by specified filter function and return as a collection. | SelectionModel |
Constant | Defined By | ||
---|---|---|---|
MULTIPLE_SELECTION : String = multipleSelection [static]
Selection mode indicates this selection model in multiple
selection status. | SelectionModel | ||
NONE_SELECTION : String = noneSelection [static]
Selection mode indicates this selection model in
"no data can be selected" status. | SelectionModel | ||
SINGLE_SELECTION : String = singleSelection [static]
Selection mode indicates this selection model in single
selection status. | SelectionModel |
count | property |
count:int
[read-only] Get total count of this selection model. This tells you how many data selected in the connecting data box.
public function get count():int
filterFunction | property |
filterFunction:Function
Get the filter function. This filter can be used to determine whether a data can be selected. Use this filter to filter out the data that you never want it to be selected.
public function get filterFunction():Function
public function set filterFunction(value:Function):void
firstData | property |
firstData:IData
[read-only] Get the first added data of this selection model.
public function get firstData():IData
lastData | property |
lastData:IData
[read-only] Get the last added data from this selection model.
public function get lastData():IData
selection | property |
selection:ICollection
[read-only] Get all data contains in this selection model as a collection.
public function get selection():ICollection
selectionMode | property |
selectionMode:String
Get current selection mode. Selection mode can be:
NONE_SELECTION
,
SINGLE_SELECTION
,
MULTIPLE_SELECTION
.
public function get selectionMode():String
public function set selectionMode(value:String):void
SelectionModel | () | Constructor |
public function SelectionModel(dataBox:DataBox)
Constructor. Create selection model and connect to this data box.
ParametersdataBox:DataBox — the data box that this selection model
will be connected to.
|
addPropertyChangeListener | () | method |
public function addPropertyChangeListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Add property change listener on this selection model. This listener will be notified when any selection has been changed.
Parameters
listener:Function — the listener to be added
| |
priority:int (default = 0 ) — the priority of the listener.
| |
useWeakReference:Boolean (default = false ) — whether use weak reference for this listener.
|
addSelectionChangeListener | () | method |
public function addSelectionChangeListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Add selection change listener on this selection model.
Parameters
listener:Function — the listener to be added
| |
priority:int (default = 0 ) — the priority of this listener
| |
useWeakReference:Boolean (default = false ) — whether use weak reference for this listener.
|
appendSelection | () | method |
public function appendSelection(datas:Object):void
Append more data into this selection model. This will make all specified data selected.
Parameters
datas:Object — the data need to be selected.
|
clearSelection | () | method |
public function clearSelection():void
Clear all data from this selection model. This will set all selected data to unselected status. Note clear this selection model will not data removed from the connecting data box. This just unselect all contained data.
contains | () | method |
public function contains(data:IData):Boolean
Check whether this selection model contains specified data.
Parameters
data:IData — the data to be checked.
|
Boolean — true if contains the specified data,
false otherwise.
|
dispatchPropertyChangeEvent | () | method |
public function dispatchPropertyChangeEvent(property:String, oldValue:Object, newValue:Object):Boolean
Dispatch a selection change property to all selection change listeners.
Parameters
property:String — the property name of the change
| |
oldValue:Object — the old value before the change
| |
newValue:Object — the new value after the change
|
Boolean — true if dispatched successfully, false otherwise.
|
isSelectable | () | method |
public function isSelectable(data:IData):Boolean
Check whether specified data is selected.
Parameters
data:IData — the data to be checked.
|
Boolean — true if this data is selected, false otherwise.
|
removePropertyChangeListener | () | method |
public function removePropertyChangeListener(listener:Function):void
Remove the specified property change listener from this selection model.
Parameters
listener:Function — the property change listener to be removed.
|
removeSelection | () | method |
public function removeSelection(datas:Object):void
Remove specified data from this selection model. This will set all specified data to unselected status.
Parameters
datas:Object — the data to be unselected.
|
removeSelectionChangeListener | () | method |
public function removeSelectionChangeListener(listener:Function):void
Remove the specified listener from this selection model.
Parameters
listener:Function — the listener to be removed.
|
selectAll | () | method |
public function selectAll():void
Call this method to select all data contains in the data box.
setSelection | () | method |
public function setSelection(datas:Object):void
Set all specified data to selected status.
Parameters
datas:Object — all data to be selected.
|
toSelection | () | method |
public function toSelection(matchFunction:Function = null):ICollection
Get all selected data by specified filter function and return as a collection.
Parameters
matchFunction:Function (default = null ) — the filter that used to filter out data you don't want
to be returned in the result.
|
ICollection — a collection contains all selected data which match the
specified filter function.
|
MULTIPLE_SELECTION | Constant |
public static const MULTIPLE_SELECTION:String = multipleSelection
Selection mode indicates this selection model in multiple selection status. This is the default mode, any data can be selected in this data box in the same time.
NONE_SELECTION | Constant |
public static const NONE_SELECTION:String = noneSelection
Selection mode indicates this selection model in "no data can be selected" status. In this mode all data contains in the data box can not be selected.
SINGLE_SELECTION | Constant |
public static const SINGLE_SELECTION:String = singleSelection
Selection mode indicates this selection model in single selection status. In this case, only one data can be selected in this data box. Selecting a new data will make the old one unselected.