Package org.eclipse.jface.action
Class ToolBarManager
- java.lang.Object
-
- org.eclipse.jface.action.ContributionManager
-
- org.eclipse.jface.action.ToolBarManager
-
- All Implemented Interfaces:
IContributionManager,IToolBarManager
public class ToolBarManager extends ContributionManager implements IToolBarManager
A tool bar manager is a contribution manager which realizes itself and its items in a tool bar control.This class may be instantiated; it may also be subclassed if a more sophisticated layout is required.
-
-
Constructor Summary
Constructors Constructor Description ToolBarManager()Creates a new tool bar manager with the default SWT button style.ToolBarManager(int style)Creates a tool bar manager with the given SWT button style.ToolBarManager(ToolBar toolbar)Creates a tool bar manager for an existing tool bar control.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ToolBarcreateControl(Composite parent)Creates and returns this manager's tool bar control.voiddispose()Disposes of this tool bar manager and frees all allocated SWT resources.MenuManagergetContextMenuManager()Returns the context menu manager for this tool bar manager.ToolBargetControl()Returns the tool bar control for this manager.protected voidrelayout(ToolBar layoutBar, int oldCount, int newCount)Re-lays out the tool bar.voidsetContextMenuManager(MenuManager contextMenuManager)Sets the context menu manager for this tool bar manager to the given menu manager.voidsetStyle(int style)Sets SWT button style for new tool bar controls created in thecreateControl(Composite)method.voidupdate(boolean force)Updates this manager's underlying widget(s) with any changes which have been made to it or its items.-
Methods inherited from class org.eclipse.jface.action.ContributionManager
add, add, allowItem, appendToGroup, appendToGroup, dumpStatistics, find, getItems, getOverrides, getSize, hasDynamicItems, indexOf, indexOf, insert, insertAfter, insertAfter, insertBefore, insertBefore, internalSetItems, isDirty, isEmpty, itemAdded, itemRemoved, markDirty, prependToGroup, prependToGroup, remove, remove, removeAll, replaceItem, setDirty, setOverrides
-
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.action.IContributionManager
add, add, appendToGroup, appendToGroup, find, getItems, getOverrides, insertAfter, insertAfter, insertBefore, insertBefore, isDirty, isEmpty, markDirty, prependToGroup, prependToGroup, remove, remove, removeAll
-
-
-
-
Constructor Detail
-
ToolBarManager
public ToolBarManager()
Creates a new tool bar manager with the default SWT button style. Use thecreateControl(Composite)method to create the tool bar control.
-
ToolBarManager
public ToolBarManager(int style)
Creates a tool bar manager with the given SWT button style. Use thecreateControlmethod to create the tool bar control.- Parameters:
style- the tool bar item style- See Also:
for valid style bits
-
ToolBarManager
public ToolBarManager(ToolBar toolbar)
Creates a tool bar manager for an existing tool bar control. This manager becomes responsible for the control, and will dispose of it when the manager is disposed. NOTE When creating a ToolBarManager from an existingToolBaryou will not get the accessible listener provided by JFace.- Parameters:
toolbar- the tool bar control- See Also:
ToolBarManager(),ToolBarManager(int)
-
-
Method Detail
-
setStyle
public void setStyle(int style)
Sets SWT button style for new tool bar controls created in thecreateControl(Composite)method. It does not affect already existing tool bar control.- Parameters:
style- the tool bar item style- Since:
- 3.10
-
createControl
public ToolBar createControl(Composite parent)
Creates and returns this manager's tool bar control. Does not create a new control if one already exists and is not disposed. Also create anAccessibleListenerfor theToolBar.- Parameters:
parent- the parent control- Returns:
- the tool bar control
-
dispose
public void dispose()
Disposes of this tool bar manager and frees all allocated SWT resources. Notifies all contribution items of the dispose. Note that this method does not clean up references between this tool bar manager and its associated contribution items. UseremoveAllfor that purpose.
-
getControl
public ToolBar getControl()
Returns the tool bar control for this manager.- Returns:
- the tool bar control, or
nullif none (before creating or after disposal)
-
relayout
protected void relayout(ToolBar layoutBar, int oldCount, int newCount)
Re-lays out the tool bar.The default implementation of this framework method re-lays out the parent when the number of items are different and the new count != 0
- Parameters:
layoutBar- the tool bar controloldCount- the old number of itemsnewCount- the new number of items
-
update
public void update(boolean force)
Description copied from interface:IContributionManagerUpdates this manager's underlying widget(s) with any changes which have been made to it or its items. Normally changes to a contribution manager merely mark it as dirty, without updating the underlying widgets. This brings the underlying widgets up to date with any changes.- Specified by:
updatein interfaceIContributionManager- Parameters:
force-truemeans update even if not dirty, andfalsefor normal incremental updating
-
getContextMenuManager
public MenuManager getContextMenuManager()
Returns the context menu manager for this tool bar manager.- Returns:
- the context menu manager, or
nullif none - Since:
- 3.0
-
setContextMenuManager
public void setContextMenuManager(MenuManager contextMenuManager)
Sets the context menu manager for this tool bar manager to the given menu manager. If the tool bar control exists, it also adds the menu control to the tool bar.- Parameters:
contextMenuManager- the context menu manager, ornullif none- Since:
- 3.0
-
-