The iselection interface has only one method:
Isempty ()
Because the iselection interface is relatively simple, the iselection subinterface istructuredselection is usually used.
The istructuredselection interface provides some convenient methods, such as obtaining the getfirstelement () of the first selected object ()
Method to obtain the iterator () method of all selected objects, the size () method of the selected number, and the tolist () method to convert all selected objects to list, and toarray () method to convert to an array
To expand iselection, you only need to implement the isempty () method. The following is an example of implementing the iselection interface:
Public class tabselection implements iselection
{
Private charttab;
Public tabselection (charttab)
{
This. charttab = charttab;
}
/* (Non-javadoc)
* @ See org. Eclipse. jface. Viewers. iselection # isempty ()
*/
Public Boolean isempty ()
{
Return charttab = NULL;
}
Public charttab getcharttab ()
{
Return charttab;
}
}
Sometimes, if you want to cancel the selection in a table or tree, you do not select any objects.
Setselection (OBJ) is used for setting.
An nullselection may be extended here. Nullselection implements the iselection interface.
Iselection only has one method isempty (). You only need to return the isempty () method to false.
Public class nullselection implements iselection {
Public nullselection (){
}
Public Boolean isempty (){
Return true;
}
}