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
public abstract class ControlContribution extends ContributionItem
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
createControlframework method must be implemented by concrete subclasses.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedControlContribution(String id)Creates a control contribution item with the given id.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected intcomputeWidth(Control control)Computes the width of the given control which is being added to a tool bar.protected abstract ControlcreateControl(Composite parent)Creates and returns the control for this contribution item under the given parent composite.voidfill(Composite parent)The control item implementation of thisIContributionItemmethod calls thecreateControlframework method.voidfill(Menu parent, int index)The control item implementation of thisIContributionItemmethod throws an exception since controls cannot be added to menus.voidfill(ToolBar parent, int index)The control item implementation of thisIContributionItemmethod calls thecreateControlframework method to create a control under the given parent, and then creates a new tool item to hold it.voidsetVisible(boolean visible)The default implementation of thisIContributionItemmethod stores the value in an internal state variable, which istrueby default.voidupdate()The default implementation of thisIContributionItemmethod does nothing.voidupdate(String id)TheContributionItemimplementation of this method declared onIContributionItemdoes 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 Detail
-
ControlContribution
protected ControlContribution(String id)
Creates a control contribution item with the given id.- Parameters:
id- the contribution item id
-
-
Method Detail
-
computeWidth
protected int computeWidth(Control control)
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
protected abstract Control createControl(Composite parent)
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
public final void fill(Composite parent)
The control item implementation of thisIContributionItemmethod calls thecreateControlframework method. Subclasses must implementcreateControlrather than overriding this method.- Specified by:
fillin interfaceIContributionItem- Overrides:
fillin classContributionItem- Parameters:
parent- the parent control
-
fill
public final void fill(Menu parent, int index)
The control item implementation of thisIContributionItemmethod throws an exception since controls cannot be added to menus.- Specified by:
fillin interfaceIContributionItem- Overrides:
fillin classContributionItem- Parameters:
parent- the parent menuindex- the index where the controls are inserted, or-1to insert at the end
-
fill
public final void fill(ToolBar parent, int index)
The control item implementation of thisIContributionItemmethod calls thecreateControlframework method to create a control under the given parent, and then creates a new tool item to hold it. Subclasses must implementcreateControlrather than overriding this method.- Specified by:
fillin interfaceIContributionItem- Overrides:
fillin classContributionItem- Parameters:
parent- the parent tool barindex- the index where the controls are inserted, or-1to insert at the end
-
setVisible
public void setVisible(boolean visible)
Description copied from class:ContributionItemThe default implementation of thisIContributionItemmethod stores the value in an internal state variable, which istrueby default.- Specified by:
setVisiblein interfaceIContributionItem- Overrides:
setVisiblein classContributionItem- Parameters:
visible-trueif this item should be visible, andfalseotherwise
-
update
public void update()
Description copied from class:ContributionItemThe default implementation of thisIContributionItemmethod does nothing. Subclasses may override.- Specified by:
updatein interfaceIContributionItem- Overrides:
updatein classContributionItem
-
update
public void update(String id)
Description copied from class:ContributionItemTheContributionItemimplementation of this method declared onIContributionItemdoes nothing. Subclasses should override to update their state.- Specified by:
updatein interfaceIContributionItem- Overrides:
updatein classContributionItem- Parameters:
id- the id of the changed property
-
-