Eclipse Forms: fat client doing pretty UI (translation, Part III)

  Abstract: Eclipse Forms: fat client doing pretty UI (translation, Part III) 

  Senior components (Complex controls) 
  Eclipse Forms provides four senior components, so you can build beautiful UI    : Expandable composite, section, image hyperlink and form text. Let us turn to look carefully at each of them. 

  Expandable composite 
  There is a page in the general function is to let you have the ability to take part of the content of the sites with a button    Scalable to it. Eclipse Forms provide such a component: ExpandableComposite  ExpandableComposite.

  ExpandableComposite ec = toolkit.createExpandableComposite    CreateExpandableComposite (form.getBody D ([ "mb ","(), \ n ExpandableComposite.TREE_NODE | \ n ExpandableComposite.CLIENT_INDENT    CLIENT_INDENT); \ n ec.setText ( "Expandable Composite title"); \ n String ctext \ u003d "We will now create a somewhat long text so that" + \ n "we can use it as content for the expandable composite." + \ n "Expandable composite is used to hide or show the text using the" \ n "toggle control" \ n Label client \ u003d toolkit.createLabel (ec, ctext, SWT.WRAP); \ n ec.setClient (client ) \ n td \ u003d new TableWrapData (); \ n td.colspan \ u003d 2; \ n ec.setLayoutData (td); \ n ec.addExpansionListener (new ExpansionAdapter () (\ n public void expansionStateChanged (ExpansionEvent    ExpansionEvent e) (\ n form.reflow (true); \ n) \ n)); 

  \ N 

  This composite accept some style parameters to control the performance of its acts    . TREENODE style tree components will be used in the button to extend or contraction, TWISTIE style will be put to the creation of a button. EXPANDED use, the initial state is extended. COMPACT If style, and the components will be heading width of the width of the right and show contraction. Lastly, the content will CLIENT_INDENT heading alignment with the (otherwise    , Which is in accordance with the width of components). 

  \ N 

  ExpandableComposite have a responsibility to tackle the button component and title    . To the expansion and contraction, components must be expandablecomposite    Expandablecomposite direct child. Components we need to add and extend sniffers "notice (reflow)" form in the state of change. Extension of this change is because the size of the expandable composite, but in the next layout parent before the parent    Parent has no impact (and therefore need to forcibly tell it). Generally    , To form each time you change the layout, you need "reflow    "This form." Reflowing "This will let all of the components form    According to the new layout and the size of the update rolling \ n 

  \ N our view now looks like this: \ n? \ N 
  Figure 11: a contraction of expandable composite examples \ n 
  When you click on the heading "+", stretching out and display composite Client: \ n \ n Figure 12: expandable composite was extending the state \ n 

  Expandable composite used an internal layout, the layout    Eclipse Forms ILayoutExtension realized interface. So you can use it added TableWrapLayout    TableWrapLayout layout of the parent, as we have done in the above example the same. 

  \ N 

  Paragraphs (Section) 
  Eclipse Forms custom components is one of the most versatile Section    Section. Inherited expandable composite It also introduced the concept of the following: 
  1. Segregation (Separator) - one can create under the heading of the separator    Separator components. 
  2. Description (Description) - under the heading optional description. 
  3. Column heading (Title bar) - under the heading in a column heading (Note separator and the title, "1]); //(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT    CLIENT_INDENT); ec.setText ( "Expandable Composite title"); String ctext = "We will now create a somewhat long text so that the" + "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    ExpansionEvent e) (form.reflow (true);))); 

  This composite accept some style parameters to control the performance of its acts    . TREENODE style tree components will be used in the button to extend or contraction, TWISTIE style will be put to the creation of a button. EXPANDED use, the initial state is extended. COMPACT If style, and the components will be heading width of the width of the right and show contraction. Lastly, the content will CLIENT_INDENT heading alignment with the (otherwise    , Which is in accordance with the width of components). 

  ExpandableComposite have a responsibility to tackle the button component and title    . To the expansion and contraction, components must be expandablecomposite    Expandablecomposite direct child. Components we need to add and extend sniffers "notice (reflow)" form in the state of change. Extension of this change is because the size of the expandable composite, but in the next layout parent before the parent    Parent has no impact (and therefore need to forcibly tell it). Generally    , To form each time you change the layout, you need "reflow    "This form." Reflowing "This will let all of the components form    According to the new layout and the size of the update rolling. 

  Our view now looks like this: 
  Figure 11: a contraction of expandable composite examples when you click on the title of "+", stretching out and display composite Client: Figure 12: expandable composite was extending the state 

  Expandable composite used an internal layout, the layout    Eclipse Forms ILayoutExtension realized interface. So you can use it added TableWrapLayout    TableWrapLayout layout of the parent, as we have done in the above example the same. 

  Paragraphs (Section) 
  Eclipse Forms custom components is one of the most versatile Section    Section. Inherited expandable composite It also introduced the concept of the following: 
  1. Segregation (Separator) - one can create under the heading of the separator    Separator components. 
  2. Description (Description) - under the heading optional description. 
  3. Column heading (Title bar) - under the heading in a column heading (Note separator and heading D ([ "mb", "    Column can not be used) \ n 

  \ N The following code example and almost expandable composite code: 

  Section section \ u003d toolkit.createSection (form.getBody () \ n Section.DESCRIPTION | Section    . TITLE_BAR | \ n Section.TWISTIE | Section    . EXPANDED); \ n td \ u003d new TableWrapData (TableWrapData.FILL); \ n td.colspan \ u003d 2; \ n section.setLayoutData (td); \ n section.addExpansionListener (new ExpansionAdapter () (\ n public void expansionStateChanged (ExpansionEvent    ExpansionEvent e) (\ n form.reflow (true); \ n) \ n)); \ n section.setText ( "Section title"); \ n section.setDescription ( "This is the description that goes" + \ n below the title "); \ n Composite sectionClient \ u003d toolkit.createComposite (section); \ n sectionClient.setLayout (new GridLayout ()); \ n button \ u003d toolkit.createButton (sectionClient," Radio 1 ", SWT.RADIO ) \ n button \ u003d toolkit.createButton (sectionClient, "Radio 2", SWT.RADIO); \ n section.setClient (sectionClient); 

  \ N 
  This time, we spent TWISTIE style, add a description and requested title bar. This view should look like this: \ n? \ N 
  Figure 13: a title bar and can be described in the section stretching \ n 

  Photo hyperlinks (Image hyperlink) 
  Hyperlinks picture is super-sub-category links, links in the text above it adds a picture. This unusual combination of a very meaningful    . This component can be just a picture (when not equipped with any text), plus links or pictures. Picture in the normal, hover, and can be activated when the state set. 

  \ N 

  Below is a picture with hyperlinks examples: 

  \ N \ n Photo 14: Eclipse welcome in the form pages \ nForm nForm text components to label (labels), hyperlinks, pictures and TableWrapLayout    TableWrapLayout combine to create a complex and powerful forms. However there are still some things it is very difficult to do    . Consider PDE manifest editor examples: 
  ? \ N \ n Photo 15: A mixture of text, pictures and hyperlinks example of the complexity Eclipse form \ n 

  Attention to the picture, hyperlinks and text is how mixed. Here use a separate labels and hyperlinks component is a very difficult    Difficult. To solve this problem, Eclipse Forms provides a powerful plug-in the text components, which have the following features: 
  Recognition of the ordinary parcels text recognition ordinary text, but if the beginning of the text to http:// hyperlinks to show identification as HTML text of the same language 

  \ N 

  In all modes, form text components can identify a string or input streams (input stream). 

  \ N 

  "1]); / /    Column can not be used) 

  The following code example and almost expandable composite code: 

  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 (ExpansionEvent    ExpansionEvent e) (form.reflow (true);))); section.setText ( "Section title"); 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); 

  This time, we spent TWISTIE style, add a description and requested title bar. This view should look like this: 
  Figure 13: title bar and a description of the section may be extended 

  Photo hyperlinks (Image hyperlink) 
  Hyperlinks picture is super-sub-category links, links in the text above it adds a picture. This unusual combination of a very meaningful    . This component can be just a picture (when not equipped with any text), plus links or pictures. Picture in the normal, hover, and can be activated when the state set. 

  Below is a picture with hyperlinks examples: 

  Photo 14: Eclipse welcome page form Form text components of the label (labels), hyperlinks, pictures and TableWrapLayout    TableWrapLayout combine to create a complex and powerful forms. However there are still some things it is very difficult to do    . Consider PDE manifest editor examples: 
  Photo 15: A mixture of text, pictures and hyperlinks example of the complexity Eclipse form 

  Attention to the picture, hyperlinks and text is how mixed. Here use a separate labels and hyperlinks component is a very difficult    Difficult. To solve this problem, Eclipse Forms provides a powerful plug-in the text components, which have the following features: 
  Recognition of the ordinary parcels text recognition ordinary text, but if the beginning of the text to http:// hyperlinks to show identification as HTML text of the same language 

  In all modes, form text components can identify a string or input streams (input stream). 

  D ([ "mb", "Recognition ordinary text (labels mode) 
  FormText formText \ u003d toolkit.createFormText (form.getBody (), true); 
  ? Td \ u003d new TableWrapData (TableWrapData.FILL); 
  ? Td.colspan \ u003d 2; 
  ? FormText.setLayoutData (td); 
  ? String text \ u003d "Here is some plain text for the text to render."; \ N 
  ? FormText.setText (text, false, false); 
  The second parameter set to false, which means we do not have analytical html tags    , And the third parameter set to false, which means we need to expand URLs. 

  \ N URLs will be automatically converted into hyperlinks 
  Now we will add a text of the hyperlink, and the first three parameters set true: 
  FormText formText \ u003d toolkit.createFormText (form.getBody (), true); 
  ? Td \ u003d new TableWrapData (TableWrapData.FILL); 
  ? Td.colspan \ u003d 2; 
  ? FormText. SetLayoutData (td); \ n 
  ? String text \ u003d "Here is some plain text for the text to render" + 
  ? This text is at http://www.eclipse.org web site. "; 
  ? FormText. SetText (text, false, true); \ n 
  If we look at our view, is this: \ n? \ N 
  Figure 16: Form text components will be automatically converted into URL hyperlink \ n 

  URL is converted to links. Parcel of this link is part of the text of the    — We do not need to create a separate components and then hyperlink try it caught in the middle of two labels. 
  Because the form text hyperlinks to identify components, it used to receive before us sniffers. Created when the toolkit, the toolkit will form text hyperlinks group settings as a new hyperlink settings. 

  \ N ", 0]); D ([" ce "]); D ([" ms "," 220a "]); / / identification ordinary text (labels mode) 
  FormText formText = toolkit.createFormText (form.getBody (), true); 
  Td = new TableWrapData (TableWrapData.FILL); 
  Td.colspan = 2; 
  FormText.setLayoutData (td); 
  String text = "Here is some plain text for the text to render."; 
  FormText.setText (text, false, false); 
  The second parameter set to false, which means we do not have analytical html tags    , And the third parameter set to false, which means we need to expand URLs. 

  URLs will be automatically converted into hyperlinks 
  Now we will add a text of the hyperlink, and the first three parameters set true: 
  FormText formText = toolkit.createFormText (form.getBody (), true); 
  Td = new TableWrapData (TableWrapData.FILL); 
  Td.colspan = 2; 
  FormText. SetLayoutData (td); 
  String text = "Here is some plain text for the text to render" + 
  This text is at http://www.eclipse.org web site. "; 
  FormText. SetText (text, false, true); 
  If we look at our view, is this: 
  Figure 16: Form text URL components will be automatically converted into hyperlinks 

  URL is converted to links. Parcel of this link is part of the text of the    — We do not need to create a separate components and then hyperlink try it caught in the middle of two labels. 
  Because the form text hyperlinks to identify components, it used to receive before us sniffers. Created when the toolkit, the toolkit will form text hyperlinks group settings as a new hyperlink settings. 

  ↑ Back 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Recommend Articles

Comments

Leave a Reply