An advanced component of the Eclipse forms design Beautiful UI

Source: Internet
Author: User
Tags html tags string client
Advanced | Design Eclipse Forms provides 4 advanced components so you can build a nice UI : Expandable composite,section,image hyperlink and form text. Let's take a closer look at each of them in turn.

Expandable composite

A common feature in Web pages is that you have the ability to use a single button on a portion of your Web page content. To scale it, Eclipse forms provides such a component: Expandablecompos Ite
Expandablecomposite EC = Toolkit.createexpandablecomposite (Form.getbody (),       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 compos Ite. "+  " 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 . Customer components that can be expanded and contracted must be expandablecompos ITE a direct child. We need to add the extension listener to the component and the "Notify (reflow)" form when the state changes. This is because stretching changes the size of the expandable composite, but before parent's next layout, the PA Rent has no effect (so it needs to be forced to tell it). , every time you make a change in the form's layout, you need to "reflow "This form." Reflowing "This form will let all components 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

Expandable composite used an internal layout, this layout Implements the Eclipse Forms Ilayoutextension interface. So you can add it to the use of T Ablewraplayout layout of the parent, as we have done in the above example.

paragraph (section)

One of the most versatile components of Eclipse forms customization is Sectio N. It inherits the expandable composite and introduces the following concepts:

1. Separator bar (Separator)-a separato that can be created under the heading R component.

2. Description (Description)-An optional description under the heading.

3. title bar-can be under the title of a title bar (note separator and title Column cannot be used at the same time)

The following code is similar to the expandable Composite code example:
Section section = Toolkit.createsection (Form.getbody (),    section.description| Section. title_bar|   section.twistie| Section. EXPANDED);  td = New Tablewrapdata (Tablewrapdata.fill);  Td.colspan = 2;  Section.setlayoutdata (TD);  Section.addexpansionlistener (New Expansionadapter () {public   void expansionstatechanged (expansion  Event e) {    form.reflow (true);   }  });  Section.settext ("section title");  Section.setdescription ("This are 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);

This time we used the Twistie style, added a description and asked for a title bar. This view should look like this:


Figure 13: An extensible section with a title bar and description

Picture hyperlink (Image hyperlink)

A picture hyperlink is a subclass of a hyperlink that adds a picture to the linked text. This common combination makes a lot of sense.This component can be just a picture (when no text is set), or a picture plus a link. The picture is normal, hover, and the state of the activation can be set.

Here is an example of a hyperlink with a picture:



The form in the 14:eclipse Welcome page of the picture

Form Text Component

Make tags (labels), hyperlinks, pictures and TablewraplayOut combine to create complex and powerful forms. But there are still things that are hard to do.. Consider the PDE manifest editor Example:




Picture 15: An example of a complex eclipse form that mixes text, pictures, and hyperlinks

Notice how the picture, hyperlink, and text are mixed. Here, using separate tags and hyperlink components is very sleepydifficult. To solve this problem, the Eclipse forms plug-in provides a powerful text component that has the following features:

Identify the text of an ordinary parcel

recognizes normal text, but if text beginning with http://is displayed as a hyperlink

Identify text like an HTML language

In all modes, the form text component recognizes a string or input stream (input stream).

recognize plain text (label mode)

FormText FormText = Toolkit.createformtext (Form.getbody (), true);
td = New Tablewrapdata (Tablewrapdata.fill);
Td.colspan = 2;
Formtext.setlayoutdata (TD);
String Text = "Here's some plain text for the text to render.";
Formtext.settext (text, False, false);

The second argument is set to false, meaning we don't need to parse HTML tags, the third argument is set to false, meaning that we do not need to extend the URLs.

Automatically convert URLs to hyperlinks

Now we're going to add a hyperlink to the text and set the 3rd argument to true:

FormText FormText = Toolkit.createformtext (Form.getbody (), true);
td = New Tablewrapdata (Tablewrapdata.fill);
Td.colspan = 2;
FormText. Setlayoutdata (TD);
String Text = "Here's some plain text for the text to render;" +
This text was athttp://www.eclipse.orgWeb site. ";
FormText. SetText (text, False, true);

If you look at our view, it will be like this:


Figure 16:form Text component automatically converts a URL into a hyperlink

URLs are converted to links. This link is part of the text of the parcel-We don't need to create a separate hyperlink component and then try to clip it between two tabs.

Because the form text component recognizes hyperlinks, it receives the listener that we used earlier. When created by toolkit, form text sets the toolkit group of hyperlinks as the new hyperlink setting.



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.