Package org.eclipse.jface.text

# Class AbstractInformationControl

java.lang.Object
org.eclipse.jface.text.AbstractInformationControl

All Implemented Interfaces:
  `IInformationControl`, `IInformationControlExtension`, `IInformationControlExtension3`, `IInformationControlExtension4`, `IInformationControlExtension5`

Direct Known Subclasses:
  `DefaultInformationControl`

public abstract class AbstractInformationControl extends Object implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension4, IInformationControlExtension5
An abstract information control that can show content inside a shell. The information control can be created in two styles:

- non-resizable tooltip with optional status
- resizable tooltip with optional tool bar

Additionally it can present either a status line containing a status text or a toolbar containing toolbar buttons.

Subclasses must either override `IInformationControl.setInformation(String)` or implement `IInformationControlExtension2`. They should also extend `computeTrim()` if they create a content area with additional trim (e.g. scrollbars) and override `getInformationPresenterControlCreator()`.

Since:
  3.4

## Constructor Summary

Constructors
Constructor
Description
`AbstractInformationControl(Shell parentShell, boolean isResizable)`
Creates an abstract information control with the given shell as parent.
`AbstractInformationControl(Shell parentShell, String statusFieldText)`
Creates an abstract information control with the given shell as parent.
`AbstractInformationControl(Shell parentShell, String statusFieldText, boolean resizable)`
Creates an abstract information control with the given shell as parent.
`AbstractInformationControl(Shell parentShell, ToolBarManager toolBarManager)`
Creates an abstract information control with the given shell as parent.

## Method Summary

Modifier and Type
Method
Description
`void`
`addDisposeListener(DisposeListener listener)`
Adds the given listener to the list of dispose listeners.
`void`
`addFocusListener(FocusListener listener)`
Adds the given listener to the list of focus listeners.
`Point`
`computeSizeConstraints(int widthInChars, int heightInChars)`
Computes the size constraints based on the `dialog font`.
`Point`
`computeSizeHint()`
Computes and returns a proposal for the size of this information control depending on the information to present.
`Rectangle`
`computeTrim()`
Computes the trim (status text and tool bar are considered as trim).
`boolean`
`containsControl(Control control)`
Tests whether the given control is this information control or a child of this information control.
`protected final void`
`create()`
Creates the content of this information control.
`protected abstract void`
`createContent(Composite parent)`
Creates the content of the popup window.
`void`
`dispose()`
Disposes this information control.
`Rectangle`
`getBounds()`
Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null).
`IInformationControlCreator`
`getInformationPresenterControlCreator()`
Returns the rich information control creator for this information control.
`final Shell`
`getShell()`
The shell of the popup window.
`protected final Point`
`getSizeConstraints()`
Returns the size constraints.
`protected final ToolBarManager`
`getToolBarManager()`
The toolbar manager used to manage the toolbar, or `null` if no toolbar is shown.
`protected void`
`handleDispose()`
Frees all resources allocated by this information control.
`boolean`
`isFocusControl()`
Returns whether this information control (or one of its children) has the focus.
`boolean`
`isResizable()`
Returns whether the information control is resizable.
`boolean`
`isVisible()`
`void`
`removeDisposeListener(DisposeListener listener)`
Removes the given listeners from the list of dispose listeners.
`void`
`removeFocusListener(FocusListener listener)`
Removes the given listeners from the list of focus listeners.
`boolean`
`restoresLocation()`
Tells whether this control allows to restore the previously used location.
`boolean`
`restoresSize()`
Tells whether this control allows to restore the previously used size.
`void`
`setBackgroundColor(Color background)`
Sets the background color of this information control.
`void`
`setFocus()`
This default implementation sets the focus on the popup shell.
`void`
`setForegroundColor(Color foreground)`
Sets the foreground color of this information control.
`void`
`setInformation(String information)`
Sets the information to be presented by this information control.
`void`
`setLocation(Point location)`
Sets the location of this information control.
`void`
`setSize(int width, int height)`
Sets the size of this information control.
`void`
`setSizeConstraints(int maxWidth, int maxHeight)`
Sets the information control's size constraints.
`void`
`setStatusText(String statusFieldText)`
Sets the text of the status field.
`void`
`setVisible(boolean visible)`
Controls the visibility of this information control.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.eclipse.jface.text.IInformationControlExtension

`hasContents`

## Constructor Details

### AbstractInformationControl

public AbstractInformationControl(Shell parentShell, String statusFieldText, boolean resizable)
Creates an abstract information control with the given shell as parent. The control will 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
  `resizable` - whether to make the control resizable
Since:
  3.24

### 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 Details

### 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

### setInformation

public void setInformation(String information)
Sets the information to be presented by this information control.

The default implementation does nothing. Subclasses must either override this method or implement `IInformationControlExtension2`.

Specified by:
  `setInformation` in interface `IInformationControl`
Parameters:
  `information` - the information to be presented
See Also:
  - `IInformationControl.setInformation(java.lang.String)`

### 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

### dispose

public void dispose()
Description copied from interface: `IInformationControl`
Disposes this information control.

Specified by:
  `dispose` in interface `IInformationControl`

### 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

### setLocation

public void setLocation(Point location)
Description copied from interface: `IInformationControl`
Sets the location of this information control.

Specified by:
  `setLocation` in interface `IInformationControl`
Parameters:
  `location` - the location

### 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

### restoresLocation

public boolean restoresLocation()
Tells whether this control allows to restore the previously used location.

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

The default implementation always returns `false`.

Specified by:
  `restoresLocation` in interface `IInformationControlExtension3`
Returns:
  `true` if restoring location is supported
See Also:
  - `IInformationControlExtension3.restoresLocation()`

### 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`

### setFocus

public void setFocus()
This default implementation sets the focus on the popup shell. Subclasses can override or extend.

Specified by:
  `setFocus` in interface `IInformationControl`
See Also:
  - `IInformationControl.setFocus()`

### 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

### isVisible

public boolean isVisible()

Specified by:
  `isVisible` in interface `IInformationControlExtension5`
Returns:
  `true` iff the information control is currently visible

### 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

### computeSizeConstraints

public Point computeSizeConstraints(int widthInChars, int heightInChars)
Computes the size constraints based on the `dialog font`. Subclasses can override or extend.

Specified by:
  `computeSizeConstraints` in interface `IInformationControlExtension5`
Parameters:
  `widthInChars` - the width constraint in number of characters
  `heightInChars` - the height constraint in number of characters
Returns:
  a point with width and height in pixels, or `null` to use the subject control's font to calculate the size
See Also:
  - `IInformationControlExtension5.computeSizeConstraints(int, int)`