Iselection interface for eclipse API Learning

Source: Internet
Author: User

 

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;

}

}

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.