An advanced component of the Eclipse forms design Beautiful UI

Source: Internet
Author: User

Eclipse Forms provides 4 advanced components so you can build beautiful ui:expandable composite,section,image hyperlink and form text. Let's take a closer look at each of them in turn.

Expandable composite

One common feature in Web pages is that you have the ability to scale a portion of the Web content with a single button, and Eclipse forms provides such a component: Expandablecomposite.

ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(),
ExpandableComposite.TREE_NODE|
ExpandableComposite.CLIENT_INDENT);
ec.setText("Expandable Composite title");
String ctext = "We will now create a somewhat long text so that "+
"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);
}
});

This composite accepts some style parameters to control its behavior. The TreeNode style uses buttons in the tree component to stretch or shrink content, and Twistie style creates a button for a square line. When you use expanded, the initial state is stretched. If you use compact style, the component will report the width of the title width appropriately and render the contraction state. , Client_indent aligns the content with the title (otherwise, the content is based on the width of the component).

Expandablecomposite has the responsibility to handle button components and headers. The customer component that expands and shrinks must be a direct child of expandablecomposite. We need to add a extension listener to the component and "Notify (Reflow)" form when the state changes. This is because stretching changes the size of the expandable composite, but it has no effect on parent before the next layout of parent (so it needs to be forced to tell it). In general, every time you make a layout change in form, you need to " Reflow "This form." Reflowing "This form will allow all components to follow the new dimension layout and update the scroll bars.

Our view now looks like this:

Figure 11: Expandable Composite example of a shrinking state

When you click on the title "+", composite stretches out and shows the customer:

Figure 12:expandable Composite stretching state

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.