Class CoolBarManager

All Implemented Interfaces:
IContributionManager, ICoolBarManager

public class CoolBarManager extends ContributionManager implements ICoolBarManager
A cool bar manager is a contribution manager which realizes itself and its items in a cool bar control.

This class may be instantiated; it may also be subclassed.

  • Field Details

  • Constructor Details

    • CoolBarManager

      public CoolBarManager()
      Creates a new cool bar manager with the default style. Equivalent to CoolBarManager(SWT.NONE).
    • CoolBarManager

      public CoolBarManager(CoolBar coolBar)
      Creates a cool bar manager for an existing cool bar control. This manager becomes responsible for the control, and will dispose of it when the manager is disposed.
      coolBar - the cool bar control
    • CoolBarManager

      public CoolBarManager(int style)
      Creates a cool bar manager with the given SWT style. Calling createControl will create the cool bar control.
      style - the cool bar item style; see CoolBarfor for valid style bits
  • Method Details

    • add

      public void add(IToolBarManager toolBarManager)
      Description copied from interface: ICoolBarManager
      A convenience method to add a tool bar as a contribution item to this cool bar manager. Equivalent to add(new ToolBarContributionManager(toolBarManager)).
      Specified by:
      add in interface ICoolBarManager
      toolBarManager - the tool bar manager to be added
      See Also:
    • allowItem

      protected boolean allowItem(IContributionItem itemToAdd)
      Description copied from class: ContributionManager
      This method allows subclasses of ContributionManager to prevent certain items in the contributions list. ContributionManager will either block or allow an addition based on the result of this method call. This can be used to prevent duplication, for example.
      allowItem in class ContributionManager
      itemToAdd - The contribution item to be added; may be null.
      true if the addition should be allowed; false otherwise. The default implementation allows all items.
    • createControl

      public CoolBar createControl(Composite parent)
      Creates and returns this manager's cool bar control. Does not create a new control if one already exists.
      parent - the parent control
      the cool bar control
    • dispose

      public void dispose()
      Disposes of this cool 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 cool bar manager and its associated contribution items. Use removeAll for that purpose.
    • getContextMenuManager

      public IMenuManager getContextMenuManager()
      Description copied from interface: ICoolBarManager
      Returns the context menu manager used by this cool bar manager. This context menu manager is used by the cool bar manager except for cool items that provide their own.
      Specified by:
      getContextMenuManager in interface ICoolBarManager
      the context menu manager, or null if none
      See Also:
    • getControl

      public CoolBar getControl()
      Returns the cool bar control for this manager.
      the cool bar control, or null if none
    • getLockLayout

      public boolean getLockLayout()
      Description copied from interface: ICoolBarManager
      Returns whether the layout of the underlying cool bar widget is locked.
      Specified by:
      getLockLayout in interface ICoolBarManager
      true if cool bar layout is locked, false otherwise
    • getStyle

      public int getStyle()
      Description copied from interface: ICoolBarManager
      Returns the style of the underlying cool bar widget.
      Specified by:
      getStyle in interface ICoolBarManager
      the style of the cool bar
    • itemAdded

      protected void itemAdded(IContributionItem item)
      Subclasses may extend this ContributionManager method, but must call super.itemAdded.
      itemAdded in class ContributionManager
      item - the item to be added
      See Also:
    • itemRemoved

      protected void itemRemoved(IContributionItem item)
      Subclasses may extend this ContributionManager method, but must call super.itemRemoved.
      itemRemoved in class ContributionManager
      item - remove given parent from list of contributions
      See Also:
    • refresh

      public void refresh()
      Synchronizes the visual order of the cool items in the control with this manager's internal data structures. This method should be called before requesting the order of the contribution items to ensure that the order is accurate.

      Note that update() and refresh() are converses: update() changes the visual order to match the internal structures, and refresh changes the internal structures to match the visual order.

    • resetItemOrder

      public void resetItemOrder()
      Restores the canonical order of this cool bar manager. The canonical order is the order in which the contribution items where added.
    • setContextMenuManager

      public void setContextMenuManager(IMenuManager contextMenuManager)
      Description copied from interface: ICoolBarManager
      Sets the context menu of this cool bar manager to the given menu manager.
      Specified by:
      setContextMenuManager in interface ICoolBarManager
      contextMenuManager - the context menu manager, or null if none
      See Also:
    • setItems

      public void setItems(IContributionItem[] newItems)
      Replaces the current items with the given items. Forces an update.
      newItems - the items with which to replace the current items
    • setLockLayout

      public void setLockLayout(boolean value)
      Description copied from interface: ICoolBarManager
      Locks or unlocks the layout of the underlying cool bar widget. Once the cool bar is locked, cool items cannot be repositioned by the user.

      Note that items can be added or removed programmatically even while the cool bar is locked.

      Specified by:
      setLockLayout in interface ICoolBarManager
      value - true to lock the cool bar, false to unlock
    • update

      public void update(boolean force)
      Subclasses may extend this IContributionManager method, but must call super.update.
      Specified by:
      update in interface IContributionManager
      force - true means update even if not dirty, and false for normal incremental updating
      See Also: