Eclipse Form Programming Guide (3)

Source: Internet
Author: User
Tags new features client
Program | design
4. Complex controls

(1) Expandablecomposite

L A common theme in Web pages is the ability to shrink part of a page's content







L The Eclipse form also provides such a control: Expandablecomposite







L The following code fragment is an example of using Expandablecomposite:







Expandablecomposite EC = toolkit.createexpandablecomposite (Body,



Expandablecomposite.tree_node



| Expandablecomposite.client_indent);



Ec.settext ("Expandable composite title");



String Ctext = "We'll now create a somewhat long text"



+ "We can use it as content for the expandable composite."



+ "Expandable composite is used to hide or show the text using the"



+ "Toggle Control";



Label client = Toolkit.createlabel (EC, Ctext, SWT. WRAP);



Ec.setclient (client);



td = New Tablewrapdata ();



Td.colspan = 2;



Ec.setlayoutdata (TD);



Ec.addexpansionlistener (New Expansionadapter () {



public void expansionstatechanged (Expansionevent e) {



Form.reflow (TRUE);



}



});



L This control has many styles, Tree_node makes the control have the expand and shrink function of the tree node, and Twistie makes the control have the Triangle arrow style







L expanded makes initial expansion display







L Client_indent makes the CLIENT content indent







L Expandablecomposite is rendered as activating control and caption, while the contents that can be expanded and shrunk are called client







L Client must be expandable composite (the previous example is a Label control)







L finally need to add expansion listener when the state changes, the Reflow Form (that is, reposition and update the scroll bar based on the new size of the control)







L The following is the result of the operation of the previous example:





(2) Section







The most common custom control in the Eclipse form is the section (visible everywhere in the PDE)







L section extension Expandablecomposite, but has the following new features:







n There is a separate control under the heading







n You can have a descriptive text below the separator control







L The following code snippet is an example of using a section, the code is not much different from the expandablecomposite, and here is the Twistie style:







Section section = toolkit.createsection (Body, section.description



| Section.twistie | section.expanded);



td = New Tablewrapdata (Tablewrapdata.fill);



Td.colspan = 2;



Section.setlayoutdata (TD);



Section.addexpansionlistener (New Expansionadapter () {



public void expansionstatechanged (Expansionevent e) {



Form.reflow (TRUE);



}



});



Section.settext ("section title");



Toolkit.createcompositeseparator (section);



Section



. SetDescription ("This is the description that goes below the title");



Composite sectionclient = toolkit.createcomposite (section);



Sectionclient.setlayout (New GridLayout ());



button = Toolkit.createbutton (Sectionclient, "Radio 1", SWT. RADIO);



button = Toolkit.createbutton (Sectionclient, "Radio 2", SWT. RADIO);



Section.setclient (sectionclient);



L The following is the result of the operation of the previous example:








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.