public abstract class AbstractInformationControl extends Object implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension4, IInformationControlExtension5
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()
.
Constructor and 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.
|
Modifier and Type | Method and 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 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.
|
protected Shell |
getShell()
The shell of the popup window.
|
protected Point |
getSizeConstraints()
Returns the size constraints.
|
protected 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hasContents
public AbstractInformationControl(Shell parentShell, String statusFieldText)
Important: Subclasses are required to call create()
at the end of their constructor.
parentShell
- the parent of this control's shellstatusFieldText
- the text to be used in the status field or null
to hide the status fieldpublic AbstractInformationControl(Shell parentShell, ToolBarManager toolBarManager)
Important: Subclasses are required to call create()
at the end of their constructor.
parentShell
- the parent of this control's shelltoolBarManager
- the manager or null
if toolbar is not desiredpublic AbstractInformationControl(Shell parentShell, boolean isResizable)
Important: Subclasses are required to call create()
at the end of their constructor.
parentShell
- the parent of this control's shellisResizable
- true
if the control should be resizableprotected final Shell getShell()
protected final ToolBarManager getToolBarManager()
null
if
no toolbar is shown.null
protected final void create()
protected abstract void createContent(Composite parent)
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.
parent
- the container of the contentpublic void setInformation(String information)
The default implementation does nothing. Subclasses must either override this method
or implement IInformationControlExtension2
.
setInformation
in interface IInformationControl
information
- the information to be presentedIInformationControl.setInformation(java.lang.String)
public boolean isResizable()
true
if the information control is resizable,
false
if it is not resizable.public void setVisible(boolean visible)
IInformationControl
Note: The information control must not grab focus when made visible.
setVisible
in interface IInformationControl
visible
- true
if the control should be visiblepublic void dispose()
IInformationControl
dispose
in interface IInformationControl
protected void handleDispose()
public void setSize(int width, int height)
IInformationControl
setSize
in interface IInformationControl
width
- the width of the controlheight
- the height of the controlpublic void setLocation(Point location)
IInformationControl
setLocation
in interface IInformationControl
location
- the locationpublic void setSizeConstraints(int maxWidth, int maxHeight)
IInformationControl
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.
setSizeConstraints
in interface IInformationControl
maxWidth
- the maximal width of the control to present the information, or SWT.DEFAULT
for not constraintmaxHeight
- the maximal height of the control to present the information, or SWT.DEFAULT
for not constraintprotected final Point getSizeConstraints()
null
if not setsetSizeConstraints(int, int)
public Point computeSizeHint()
IInformationControl
computeSizeHint
in interface IInformationControl
public Rectangle computeTrim()
computeTrim
in interface IInformationControlExtension3
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).IInformationControlExtension3.computeTrim()
public Rectangle getBounds()
IInformationControlExtension3
Note: If the receiver is already disposed then this methods must return the last valid location and size.
getBounds
in interface IInformationControlExtension3
public boolean restoresLocation()
Note: This is not a static property - it can change during the lifetime of this control.
The default implementation always returns false
.
restoresLocation
in interface IInformationControlExtension3
true
if restoring location is supportedIInformationControlExtension3.restoresLocation()
public boolean restoresSize()
Note: This is not a static property - it can change during the lifetime of this control.
The default implementation always returns false
.
restoresSize
in interface IInformationControlExtension3
true
if restoring size is supportedIInformationControlExtension3.restoresSize()
public void addDisposeListener(DisposeListener listener)
IInformationControl
addDisposeListener
in interface IInformationControl
listener
- the listener to be addedpublic void removeDisposeListener(DisposeListener listener)
IInformationControl
removeDisposeListener
in interface IInformationControl
listener
- the listener to be removedpublic void setForegroundColor(Color foreground)
IInformationControl
setForegroundColor
in interface IInformationControl
foreground
- the foreground color of this information controlpublic void setBackgroundColor(Color background)
IInformationControl
setBackgroundColor
in interface IInformationControl
background
- the background color of this information controlpublic boolean isFocusControl()
fShell
is this information control's shell):
return fShell.getDisplay().getActiveShell() == fShellThis method is not intended to be overridden by subclasses.
isFocusControl
in interface IInformationControl
true
when the information control has the focus, otherwise false
public void setFocus()
setFocus
in interface IInformationControl
IInformationControl.setFocus()
public void addFocusListener(FocusListener listener)
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.
addFocusListener
in interface IInformationControl
listener
- the listener to be addedpublic void removeFocusListener(FocusListener listener)
removeFocusListener
in interface IInformationControl
listener
- the listener to be removedpublic void setStatusText(String statusFieldText)
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.
setStatusText
in interface IInformationControlExtension4
statusFieldText
- the text to be used in the optional status field
or null
if the status field should be hiddenIInformationControlExtension4.setStatusText(java.lang.String)
public boolean containsControl(Control control)
IInformationControlExtension5
containsControl
in interface IInformationControlExtension5
control
- the control to testtrue
iff the given control is this information control
or a child of this information controlpublic boolean isVisible()
isVisible
in interface IInformationControlExtension5
true
iff the information control is currently visiblepublic IInformationControlCreator getInformationPresenterControlCreator()
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 returnsnull
. Subclasses may override.getInformationPresenterControlCreator
in interface IInformationControlExtension5
null
to disable enrichingpublic Point computeSizeConstraints(int widthInChars, int heightInChars)
dialog font
. Subclasses can
override or extend.computeSizeConstraints
in interface IInformationControlExtension5
widthInChars
- the width constraint in number of charactersheightInChars
- the height constraint in number of charactersnull
to use the subject control's font to calculate the sizeIInformationControlExtension5.computeSizeConstraints(int, int)
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.