Class AbstractInformationControl

    • Constructor Detail

      • AbstractInformationControl

        public AbstractInformationControl​(Shell parentShell,
                                          String statusFieldText)
        Creates an abstract information control with the given shell as parent. The control will not be resizable and optionally show a status line with the given status field text.

        Important: Subclasses are required to call create() at the end of their constructor.

        Parameters:
        parentShell - the parent of this control's shell
        statusFieldText - the text to be used in the status field or null to hide the status field
      • AbstractInformationControl

        public AbstractInformationControl​(Shell parentShell,
                                          ToolBarManager toolBarManager)
        Creates an abstract information control with the given shell as parent. The control will be resizable and optionally show a tool bar managed by the given tool bar manager.

        Important: Subclasses are required to call create() at the end of their constructor.

        Parameters:
        parentShell - the parent of this control's shell
        toolBarManager - the manager or null if toolbar is not desired
      • AbstractInformationControl

        public AbstractInformationControl​(Shell parentShell,
                                          boolean isResizable)
        Creates an abstract information control with the given shell as parent.

        Important: Subclasses are required to call create() at the end of their constructor.

        Parameters:
        parentShell - the parent of this control's shell
        isResizable - true if the control should be resizable
    • Method Detail

      • getShell

        public final Shell getShell()
        The shell of the popup window.
        Returns:
        the shell used for the popup window
        Since:
        3.13
      • getToolBarManager

        protected final ToolBarManager getToolBarManager()
        The toolbar manager used to manage the toolbar, or null if no toolbar is shown.
        Returns:
        the tool bar manager or null
      • create

        protected final void create()
        Creates the content of this information control. Subclasses must call this method at the end of their constructor(s).
      • createContent

        protected abstract void createContent​(Composite parent)
        Creates the content of the popup window.

        Implementors will usually take over Control.getBackground() and Control.getForeground() from parent.

        Implementors must either use the dialog font or override computeSizeConstraints(int, int).

        Implementors are expected to consider isResizable(): If true, they should show scrollbars if their content may exceed the size of the information control. If false, they should never show scrollbars.

        The given parent comes with a FillLayout. Subclasses may set a different layout.

        Parameters:
        parent - the container of the content
      • isResizable

        public boolean isResizable()
        Returns whether the information control is resizable.
        Returns:
        true if the information control is resizable, false if it is not resizable.
      • setVisible

        public void setVisible​(boolean visible)
        Description copied from interface: IInformationControl
        Controls the visibility of this information control.

        Note: The information control must not grab focus when made visible.

        Specified by:
        setVisible in interface IInformationControl
        Parameters:
        visible - true if the control should be visible
      • handleDispose

        protected void handleDispose()
        Frees all resources allocated by this information control. Internally called when the information control's shell has been disposed.
        Since:
        3.6
      • setSize

        public void setSize​(int width,
                            int height)
        Description copied from interface: IInformationControl
        Sets the size of this information control.
        Specified by:
        setSize in interface IInformationControl
        Parameters:
        width - the width of the control
        height - the height of the control
      • setSizeConstraints

        public void setSizeConstraints​(int maxWidth,
                                       int maxHeight)
        Description copied from interface: IInformationControl
        Sets the information control's size constraints. A constraint value of SWT.DEFAULT indicates no constraint. This method must be called before IInformationControl.computeSizeHint() is called.

        Note: An information control which implements IInformationControlExtension3 may ignore this method or use it as hint for its very first appearance.

        Specified by:
        setSizeConstraints in interface IInformationControl
        Parameters:
        maxWidth - the maximal width of the control to present the information, or SWT.DEFAULT for not constraint
        maxHeight - the maximal height of the control to present the information, or SWT.DEFAULT for not constraint
      • getSizeConstraints

        protected final Point getSizeConstraints()
        Returns the size constraints.
        Returns:
        the size constraints or null if not set
        See Also:
        setSizeConstraints(int, int)
      • computeSizeHint

        public Point computeSizeHint()
        Description copied from interface: IInformationControl
        Computes and returns a proposal for the size of this information control depending on the information to present. The method tries to honor known size constraints but might return a size that exceeds them.
        Specified by:
        computeSizeHint in interface IInformationControl
        Returns:
        the computed size hint
      • computeTrim

        public Rectangle computeTrim()
        Computes the trim (status text and tool bar are considered as trim). Subclasses can extend this method to add additional trim (e.g. scroll bars for resizable information controls).
        Specified by:
        computeTrim in interface IInformationControlExtension3
        Returns:
        The receiver's trim. x and y denote the upper left corner of the trimming relative to this control's location i.e. this will most likely be negative values. width and height represent the border sizes (the sum of the horizontal and vertical trimmings, respectively).
        See Also:
        IInformationControlExtension3.computeTrim()
      • getBounds

        public Rectangle getBounds()
        Description copied from interface: IInformationControlExtension3
        Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null).

        Note: If the receiver is already disposed then this methods must return the last valid location and size.

        Specified by:
        getBounds in interface IInformationControlExtension3
        Returns:
        the receiver's bounding rectangle
      • restoresSize

        public boolean restoresSize()
        Tells whether this control allows to restore the previously used size.

        Note: This is not a static property - it can change during the lifetime of this control.

        The default implementation always returns false.

        Specified by:
        restoresSize in interface IInformationControlExtension3
        Returns:
        true if restoring size is supported
        See Also:
        IInformationControlExtension3.restoresSize()
      • addDisposeListener

        public void addDisposeListener​(DisposeListener listener)
        Description copied from interface: IInformationControl
        Adds the given listener to the list of dispose listeners. If the listener is already registered it is not registered again.
        Specified by:
        addDisposeListener in interface IInformationControl
        Parameters:
        listener - the listener to be added
      • removeDisposeListener

        public void removeDisposeListener​(DisposeListener listener)
        Description copied from interface: IInformationControl
        Removes the given listeners from the list of dispose listeners. If the listener is not registered this call has no effect.
        Specified by:
        removeDisposeListener in interface IInformationControl
        Parameters:
        listener - the listener to be removed
      • setForegroundColor

        public void setForegroundColor​(Color foreground)
        Description copied from interface: IInformationControl
        Sets the foreground color of this information control.
        Specified by:
        setForegroundColor in interface IInformationControl
        Parameters:
        foreground - the foreground color of this information control
      • setBackgroundColor

        public void setBackgroundColor​(Color background)
        Description copied from interface: IInformationControl
        Sets the background color of this information control.
        Specified by:
        setBackgroundColor in interface IInformationControl
        Parameters:
        background - the background color of this information control
      • isFocusControl

        public boolean isFocusControl()
        Returns whether this information control (or one of its children) has the focus. The suggested implementation is like this (fShell is this information control's shell):
        return fShell.getDisplay().getActiveShell() == fShell

        Note that implementations of IInformationControlExtension5 are required to use this suggested implementation.

        This method is not intended to be overridden by subclasses.
        Specified by:
        isFocusControl in interface IInformationControl
        Returns:
        true when the information control has the focus, otherwise false
      • addFocusListener

        public void addFocusListener​(FocusListener listener)
        Adds the given listener to the list of focus listeners. If the listener is already registered it is not registered again.

        The suggested implementation is to install listeners for SWT.Activate and SWT.Deactivate on the shell and forward events to the focus listeners. Clients are encouraged to subclass AbstractInformationControl, which does this for free.

        This method is not intended to be overridden by subclasses.
        Specified by:
        addFocusListener in interface IInformationControl
        Parameters:
        listener - the listener to be added
      • removeFocusListener

        public void removeFocusListener​(FocusListener listener)
        Removes the given listeners from the list of focus listeners. If the listener is not registered this call has no effect. This method is not intended to be overridden by subclasses.
        Specified by:
        removeFocusListener in interface IInformationControl
        Parameters:
        listener - the listener to be removed
      • setStatusText

        public void setStatusText​(String statusFieldText)
        Sets the text of the status field.

        The default implementation currently only updates the status field when the popup shell is not visible. The status field can currently only be shown if the information control has been created with a non-null status field text.

        Specified by:
        setStatusText in interface IInformationControlExtension4
        Parameters:
        statusFieldText - the text to be used in the optional status field or null if the status field should be hidden
        See Also:
        IInformationControlExtension4.setStatusText(java.lang.String)
      • containsControl

        public boolean containsControl​(Control control)
        Description copied from interface: IInformationControlExtension5
        Tests whether the given control is this information control or a child of this information control.
        Specified by:
        containsControl in interface IInformationControlExtension5
        Parameters:
        control - the control to test
        Returns:
        true iff the given control is this information control or a child of this information control
      • getInformationPresenterControlCreator

        public IInformationControlCreator getInformationPresenterControlCreator()
        Returns the rich information control creator for this information control.

        The returned information control creator is used to create an enriched version of this information control, e.g. when the mouse is moved into this control and it needs to be enriched or when it needs to be made sticky for other reasons.

        The returned information control creator must create information controls that implement IInformationControlExtension3 and IInformationControlExtension2, and whose IInformationControlExtension2.setInput(Object) accepts all inputs that are also supported by this information control.

        Note that automatic enriching of this information control works only if it also implements IInformationControlExtension3.

        This method may be called frequently, so implementors should ensure it returns quickly, e.g. by caching the returned creator.

        This default implementation returns null. Subclasses may override.
        Specified by:
        getInformationPresenterControlCreator in interface IInformationControlExtension5
        Returns:
        the information presenter control creator or null to disable enriching