Eclipse RCP Series 6 Treeview

Source: Internet
Author: User

The use of Treeview is similar to that of tableview. The difference is that the implementation interfaces of contentprovider and labelprovider are different. The following is an example. I believe you can understand it.
Class kindlabelprovider extends labelprovider {
Public String gettext (Object OBJ ){
If (OBJ instanceof kind ){
Return obj. tostring ();
}
Return NULL;
}

Public Image getimage (Object OBJ ){
// String imagekey = isharedimages. img_obj_element;
If (OBJ instanceof kind ){
String imagekey = isharedimages. img_obj_folder;
Platformui. getworkbench (). get1_dimages (). getimage (imagekey );
}
Return NULL;
}
}

Class kindcontentprovider implements istructuredcontentprovider,
Itreecontentprovider {

Public object [] getelements (Object parent ){
If (parent instanceof kind ){
Return getchildren (parent );
}
Return NULL;
}

Public object getparent (Object child ){
If (Child instanceof node ){
Return (node) Child). getparent ();
}
Return NULL;
}

Public object [] getchildren (Object parent ){
If (parent instanceof kind ){
Arraylist children = (kind) parent). getchildren ();

Return children. toarray (new node [children. Size ()]);

}
Return new object [0];
}

Public Boolean haschildren (Object parent ){
If (parent instanceof kind)
Return (kind) parent). haschildren ();
Return false;
}

Public void dispose (){
// Todo auto-generated method stub

}

Public void inputchanged (viewer, object oldinput, object newinput ){
// Todo auto-generated method stub

}
}

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.