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
Subclasses must either override
IInformationControl.setInformation(String)or implementIInformationControlExtension2. They should also extendcomputeTrim()if they create a content area with additional trim (e.g. scrollbars) and overridegetInformationPresenterControlCreator().- 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, ToolBarManager toolBarManager)Creates an abstract information control with the given shell as parent.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDisposeListener(DisposeListener listener)Adds the given listener to the list of dispose listeners.voidaddFocusListener(FocusListener listener)Adds the given listener to the list of focus listeners.PointcomputeSizeConstraints(int widthInChars, int heightInChars)Computes the size constraints based on thedialog font.PointcomputeSizeHint()Computes and returns a proposal for the size of this information control depending on the information to present.RectanglecomputeTrim()Computes the trim (status text and tool bar are considered as trim).booleancontainsControl(Control control)Tests whether the given control is this information control or a child of this information control.protected voidcreate()Creates the content of this information control.protected abstract voidcreateContent(Composite parent)Creates the content of the popup window.voiddispose()Disposes this information control.RectanglegetBounds()Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null).IInformationControlCreatorgetInformationPresenterControlCreator()Returns the rich information control creator for this information control.ShellgetShell()The shell of the popup window.protected PointgetSizeConstraints()Returns the size constraints.protected ToolBarManagergetToolBarManager()The toolbar manager used to manage the toolbar, ornullif no toolbar is shown.protected voidhandleDispose()Frees all resources allocated by this information control.booleanisFocusControl()Returns whether this information control (or one of its children) has the focus.booleanisResizable()Returns whether the information control is resizable.booleanisVisible()voidremoveDisposeListener(DisposeListener listener)Removes the given listeners from the list of dispose listeners.voidremoveFocusListener(FocusListener listener)Removes the given listeners from the list of focus listeners.booleanrestoresLocation()Tells whether this control allows to restore the previously used location.booleanrestoresSize()Tells whether this control allows to restore the previously used size.voidsetBackgroundColor(Color background)Sets the background color of this information control.voidsetFocus()This default implementation sets the focus on the popup shell.voidsetForegroundColor(Color foreground)Sets the foreground color of this information control.voidsetInformation(String information)Sets the information to be presented by this information control.voidsetLocation(Point location)Sets the location of this information control.voidsetSize(int width, int height)Sets the size of this information control.voidsetSizeConstraints(int maxWidth, int maxHeight)Sets the information control's size constraints.voidsetStatusText(String statusFieldText)Sets the text of the status field.voidsetVisible(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 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 shellstatusFieldText- the text to be used in the status field ornullto 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 shelltoolBarManager- the manager ornullif 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 shellisResizable-trueif 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, ornullif 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()andControl.getForeground()fromparent.Implementors must either use the dialog font or override
computeSizeConstraints(int, int).Implementors are expected to consider
isResizable(): Iftrue, they should show scrollbars if their content may exceed the size of the information control. Iffalse, they should never show scrollbars.The given
parentcomes with aFillLayout. 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:
setInformationin interfaceIInformationControl- 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:
trueif the information control is resizable,falseif it is not resizable.
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:IInformationControlControls the visibility of this information control.Note: The information control must not grab focus when made visible.
- Specified by:
setVisiblein interfaceIInformationControl- Parameters:
visible-trueif the control should be visible
-
dispose
public void dispose()
Description copied from interface:IInformationControlDisposes this information control.- Specified by:
disposein interfaceIInformationControl
-
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:IInformationControlSets the size of this information control.- Specified by:
setSizein interfaceIInformationControl- Parameters:
width- the width of the controlheight- the height of the control
-
setLocation
public void setLocation(Point location)
Description copied from interface:IInformationControlSets the location of this information control.- Specified by:
setLocationin interfaceIInformationControl- Parameters:
location- the location
-
setSizeConstraints
public void setSizeConstraints(int maxWidth, int maxHeight)Description copied from interface:IInformationControlSets the information control's size constraints. A constraint value ofSWT.DEFAULTindicates no constraint. This method must be called beforeIInformationControl.computeSizeHint()is called.Note: An information control which implements
IInformationControlExtension3may ignore this method or use it as hint for its very first appearance.- Specified by:
setSizeConstraintsin interfaceIInformationControl- Parameters:
maxWidth- the maximal width of the control to present the information, orSWT.DEFAULTfor not constraintmaxHeight- the maximal height of the control to present the information, orSWT.DEFAULTfor not constraint
-
getSizeConstraints
protected final Point getSizeConstraints()
Returns the size constraints.- Returns:
- the size constraints or
nullif not set - See Also:
setSizeConstraints(int, int)
-
computeSizeHint
public Point computeSizeHint()
Description copied from interface:IInformationControlComputes 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:
computeSizeHintin interfaceIInformationControl- 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:
computeTrimin interfaceIInformationControlExtension3- Returns:
- The receiver's trim.
xandydenote the upper left corner of the trimming relative to this control's location i.e. this will most likely be negative values.widthandheightrepresent the border sizes (the sum of the horizontal and vertical trimmings, respectively). - See Also:
IInformationControlExtension3.computeTrim()
-
getBounds
public Rectangle getBounds()
Description copied from interface:IInformationControlExtension3Returns 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:
getBoundsin interfaceIInformationControlExtension3- 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:
restoresLocationin interfaceIInformationControlExtension3- Returns:
trueif 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:
restoresSizein interfaceIInformationControlExtension3- Returns:
trueif restoring size is supported- See Also:
IInformationControlExtension3.restoresSize()
-
addDisposeListener
public void addDisposeListener(DisposeListener listener)
Description copied from interface:IInformationControlAdds the given listener to the list of dispose listeners. If the listener is already registered it is not registered again.- Specified by:
addDisposeListenerin interfaceIInformationControl- Parameters:
listener- the listener to be added
-
removeDisposeListener
public void removeDisposeListener(DisposeListener listener)
Description copied from interface:IInformationControlRemoves the given listeners from the list of dispose listeners. If the listener is not registered this call has no effect.- Specified by:
removeDisposeListenerin interfaceIInformationControl- Parameters:
listener- the listener to be removed
-
setForegroundColor
public void setForegroundColor(Color foreground)
Description copied from interface:IInformationControlSets the foreground color of this information control.- Specified by:
setForegroundColorin interfaceIInformationControl- Parameters:
foreground- the foreground color of this information control
-
setBackgroundColor
public void setBackgroundColor(Color background)
Description copied from interface:IInformationControlSets the background color of this information control.- Specified by:
setBackgroundColorin interfaceIInformationControl- 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 (fShellis this information control's shell):return fShell.getDisplay().getActiveShell() == fShell
Note that implementations of
This method is not intended to be overridden by subclasses.IInformationControlExtension5are required to use this suggested implementation.- Specified by:
isFocusControlin interfaceIInformationControl- Returns:
truewhen the information control has the focus, otherwisefalse
-
setFocus
public void setFocus()
This default implementation sets the focus on the popup shell. Subclasses can override or extend.- Specified by:
setFocusin interfaceIInformationControl- 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
This method is not intended to be overridden by subclasses.SWT.ActivateandSWT.Deactivateon the shell and forward events to the focus listeners. Clients are encouraged to subclassAbstractInformationControl, which does this for free.- Specified by:
addFocusListenerin interfaceIInformationControl- 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:
removeFocusListenerin interfaceIInformationControl- 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:
setStatusTextin interfaceIInformationControlExtension4- Parameters:
statusFieldText- the text to be used in the optional status field ornullif the status field should be hidden- See Also:
IInformationControlExtension4.setStatusText(java.lang.String)
-
containsControl
public boolean containsControl(Control control)
Description copied from interface:IInformationControlExtension5Tests whether the given control is this information control or a child of this information control.- Specified by:
containsControlin interfaceIInformationControlExtension5- Parameters:
control- the control to test- Returns:
trueiff the given control is this information control or a child of this information control
-
isVisible
public boolean isVisible()
- Specified by:
isVisiblein interfaceIInformationControlExtension5- Returns:
trueiff 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
enrichedor when it needs to be made sticky for other reasons.The returned information control creator must create information controls that implement
IInformationControlExtension3andIInformationControlExtension2, and whoseIInformationControlExtension2.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 returnsnull. Subclasses may override.- Specified by:
getInformationPresenterControlCreatorin interfaceIInformationControlExtension5- Returns:
- the information presenter control creator or
nullto disable enriching
-
computeSizeConstraints
public Point computeSizeConstraints(int widthInChars, int heightInChars)
Computes the size constraints based on thedialog font. Subclasses can override or extend.- Specified by:
computeSizeConstraintsin interfaceIInformationControlExtension5- Parameters:
widthInChars- the width constraint in number of charactersheightInChars- the height constraint in number of characters- Returns:
- a point with width and height in pixels, or
nullto use the subject control's font to calculate the size - See Also:
IInformationControlExtension5.computeSizeConstraints(int, int)
-
-