Class FormattedTextView

  • All Implemented Interfaces:
    org.eclipse.ui.services.IDisposable

    public class FormattedTextView
    extends Object
    implements org.eclipse.ui.services.IDisposable
    View to display formatted text content. Based on Chromium SWT Browser.
    • Constructor Detail

      • FormattedTextView

        public FormattedTextView​(org.eclipse.swt.chromium.Browser browser,
                                 String content,
                                 IV8Project v8Project,
                                 IMdObjectByTypeProvider objectByTypeProvider,
                                 IColorProvider colorProvider,
                                 IFontProvider fontProvider,
                                 int scale,
                                 double preferredWidth,
                                 double preferredHeight,
                                 FormattedStringSettings formattedStringSettings)
        Creates new view of formatted text.
        Parameters:
        browser - the Browser instance to which to attach this view, cannot be null
        content - formatted text content
        v8Project - V8 project, cannot be null
        objectByTypeProvider - object by type provider, cannot be null
        colorProvider - the color provider, cannot be null
        fontProvider - the font provider, cannot be null
        scale - the form scale in percent
        preferredWidth - the preferred width of the formatted text, use SWT.DEFAULT to ignore limit
        preferredHeight - the preferred height of the formatted text, use SWT.DEFAULT to ignore limit
        formattedStringSettings - the formatted text default settings, can be null
    • Method Detail

      • getContentSize

        public org.eclipse.swt.graphics.Point getContentSize()
        Returns size of the loaded content.
        Returns:
        content size calculated or (-1,-1) in case of problems
      • updateFormattedStringSettings

        public void updateFormattedStringSettings​(FormattedStringSettings settings)
        Updates the FormattedStringSettings. If default font style is changed you should use this method to set correct settings.
        Parameters:
        settings - new formatted text settings, can't be null
      • resizeView

        public void resizeView​(double width,
                               double height)
        Resizes view containment.
        Parameters:
        width - new width for view
        height - new height for view
        onContentLoaded - callback to be called when content has been loaded
      • dispose

        public void dispose()
        Specified by:
        dispose in interface org.eclipse.ui.services.IDisposable
      • setInitialContent

        protected void setInitialContent​(String html)
        Sets HTML content to the view. Browser engine works asynchronuosly, so that after setting a formatted text to the browser we create a progress listener and produce additional rendering of the formatted text on completion. See render()
        Parameters:
        html - the content to set
      • evaluateScript

        protected Object evaluateScript​(String script)
        Evaluates java script in browser engine
        Parameters:
        script - script to be evaluated
        Returns:
        Object, can be null