It is possible to achieve highly polished results using images, hyperlinks and text snippets mixed together in a form. However, when the mix of these elements is needed as part of one integral text, it is very hard to do. To remedy the problem, UI Forms offer a rudimentary text control that can do the following:
Render plain wrapped text
Render plain text but convert any segment that starts with http:// into a hyperlink on the fly
Render text with XML tags
In all the modes, FormText
control is capable of
rendering either a string or an input stream.
FormText rtext = toolkit.createFormText(form.getBody(), true); String data = "Here is some plain text for the text to render."; rtext.setText(data, false, false);
Second argument set to false
means that we will
treat input text as-is, and the third that we will not try to expand URLs if
found.
It is possible to still handle the text as normal but automatically convert segments with http:// protocol into hyperlinks:
FormText rtext = toolkit.createFormText(form.getBody(), true); String data = "Here is some plain text for the text to render; "+ "this text is at http://www.eclipse.org web site."; rtext.setText(data, false, true);
Similar to the Hyperlink
control,
FormText
accepts listeners that implement HyperlinkListener
.
These listeners will be notified about events related to the hyperlink
segments within the control.