Package org.eclipse.jface.action
Class ControlContribution
java.lang.Object
org.eclipse.jface.action.ContributionItem
org.eclipse.jface.action.ControlContribution
- All Implemented Interfaces:
IContributionItem
- Direct Known Subclasses:
org.eclipse.ui.internal.menus.InternalControlContribution
,LabelContributionItem
,ToolControlContribution
An abstract contribution item implementation for adding an arbitrary
SWT control to a tool bar.
Note, however, that these items cannot be contributed to menu bars.
The createControl
framework method must be implemented
by concrete subclasses.
-
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a control contribution item with the given id. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
computeWidth
(Control control) Computes the width of the given control which is being added to a tool bar.protected abstract Control
createControl
(Composite parent) Creates and returns the control for this contribution item under the given parent composite.final void
The control item implementation of thisIContributionItem
method calls thecreateControl
framework method.final void
The control item implementation of thisIContributionItem
method throws an exception since controls cannot be added to menus.final void
The control item implementation of thisIContributionItem
method calls thecreateControl
framework method to create a control under the given parent, and then creates a new tool item to hold it.void
setVisible
(boolean visible) The default implementation of thisIContributionItem
method stores the value in an internal state variable, which istrue
by default.void
update()
The default implementation of thisIContributionItem
method does nothing.void
TheContributionItem
implementation of this method declared onIContributionItem
does nothing.Methods inherited from class org.eclipse.jface.action.ContributionItem
dispose, fill, getId, getParent, isDirty, isDynamic, isEnabled, isGroupMarker, isSeparator, isVisible, saveWidgetState, setId, setParent, toString
-
Constructor Details
-
ControlContribution
Creates a control contribution item with the given id.- Parameters:
id
- the contribution item id
-
-
Method Details
-
computeWidth
Computes the width of the given control which is being added to a tool bar. This is needed to determine the width of the tool bar item containing the given control.The default implementation of this framework method returns
control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x
. Subclasses may override if required.- Parameters:
control
- the control being added- Returns:
- the width of the control
-
createControl
Creates and returns the control for this contribution item under the given parent composite.This framework method must be implemented by concrete subclasses.
- Parameters:
parent
- the parent composite- Returns:
- the new control, must not be
null
-
fill
The control item implementation of thisIContributionItem
method calls thecreateControl
framework method. Subclasses must implementcreateControl
rather than overriding this method.- Specified by:
fill
in interfaceIContributionItem
- Overrides:
fill
in classContributionItem
- Parameters:
parent
- the parent control
-
fill
The control item implementation of thisIContributionItem
method throws an exception since controls cannot be added to menus.- Specified by:
fill
in interfaceIContributionItem
- Overrides:
fill
in classContributionItem
- Parameters:
parent
- the parent menuindex
- the index where the controls are inserted, or-1
to insert at the end
-
fill
The control item implementation of thisIContributionItem
method calls thecreateControl
framework method to create a control under the given parent, and then creates a new tool item to hold it. Subclasses must implementcreateControl
rather than overriding this method.- Specified by:
fill
in interfaceIContributionItem
- Overrides:
fill
in classContributionItem
- Parameters:
parent
- the parent tool barindex
- the index where the controls are inserted, or-1
to insert at the end
-
setVisible
public void setVisible(boolean visible) Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method stores the value in an internal state variable, which istrue
by default.- Specified by:
setVisible
in interfaceIContributionItem
- Overrides:
setVisible
in classContributionItem
- Parameters:
visible
-true
if this item should be visible, andfalse
otherwise
-
update
public void update()Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
update
in interfaceIContributionItem
- Overrides:
update
in classContributionItem
-
update
Description copied from class:ContributionItem
TheContributionItem
implementation of this method declared onIContributionItem
does nothing. Subclasses should override to update their state.- Specified by:
update
in interfaceIContributionItem
- Overrides:
update
in classContributionItem
- Parameters:
id
- the id of the changed property
-