Class ScrolledFormText

All Implemented Interfaces:
Drawable

public class ScrolledFormText extends SharedScrolledComposite
ScrolledFormText is a control that is capable of scrolling an instance of the FormText class. It should be created in a parent that will allow it to use all the available area (for example, a shell, a view or an editor). The form text can be created by the class itself, or set from outside. In the later case, the form text instance must be a direct child of the ScrolledFormText instance.

The class assumes that text to be rendered contains formatting tags. In case of a string, it will enclose the text in 'form' root element if missing from the text as a convinience. For example:

 ftext.setText("<p>Some text here</>");
 

will not cause an error. The same behavior does not exist for content from the input stream, however - it must be well formed in that case.

Since:
3.0
See Also:
  • Constructor Details

    • ScrolledFormText

      public ScrolledFormText(Composite parent, boolean createFormText)
      Creates the new scrolled text instance in the provided parent
      Parameters:
      parent - the parent composite
      createFormText - if true, enclosing form text instance will be created in this constructor.
    • ScrolledFormText

      public ScrolledFormText(Composite parent, int style, boolean createFormText)
      Creates the new scrolled text instance in the provided parent
      Parameters:
      parent - the parent composite
      style - the style to pass to the scrolled composite
      createFormText - if true, enclosing form text instance will be created in this constructor.
  • Method Details

    • setFormText

      public void setFormText(FormText formText)
      Sets the form text to be managed by this scrolled form text. The instance must be a direct child of this class. If this method is used, false must be passed in either of the constructors to avoid creating form text instance.
      Parameters:
      formText - the form text instance to use.
    • setForeground

      public void setForeground(Color fg)
      Sets the foreground color of the scrolled form text.
      Overrides:
      setForeground in class SharedScrolledComposite
      Parameters:
      fg - the foreground color
    • setBackground

      public void setBackground(Color bg)
      Sets the background color of the scrolled form text.
      Overrides:
      setBackground in class SharedScrolledComposite
      Parameters:
      bg - the background color
    • setContent

      public final void setContent(Control c)
      The class sets the content widget. This method should not be called by classes that instantiate this widget.
      Overrides:
      setContent in class SharedScrolledComposite
      Parameters:
      c - content control
    • setText

      public void setText(String text)
      Sets the text to be rendered in the scrolled form text. The text must contain formatting tags.
      Parameters:
      text - the text to be rendered
    • setContents

      public void setContents(InputStream is)
      Sets the contents to rendered in the scrolled form text. The stream must contain formatting tags. The caller is responsible for closing the input stream. The call may be long running. For best results, call this method from another thread and call 'reflow' when done (but make both calls using 'Display.asyncExec' because these calls must be made in the event dispatching thread).
      Parameters:
      is - content input stream
    • getFormText

      public FormText getFormText()
      Returns the instance of the form text.
      Returns:
      the form text instance