Class SynchronizePageActionGroup

java.lang.Object
org.eclipse.ui.actions.ActionGroup
org.eclipse.team.ui.synchronize.SynchronizePageActionGroup
Direct Known Subclasses:
ModelSynchronizeParticipantActionGroup

public abstract class SynchronizePageActionGroup extends ActionGroup
Used to add one or more actions to the context menu, toolbar or view menu of an ISynchronizePage. An action group is added to a synchronize page by adding the group to the ISynchronizePageConfiguration after configuration has been created by the page but before the page is created.

The life cycle of an action group is:

  • the initialize(ISynchronizePageConfiguration} method is invoked before the methods to populate menus. This is done to give clients a change to create and initialize the actions of the action group.
  • The fillActionBars(IActionBars) method is invoked to populate the page's action bars (view menu and toolbar). It is possible for the action bars to be missing one or more components so clients are expected to check for null when accessing the menus from the action bars.
  • The fillContextMenu(IMenuManager) method is invoked each time the context menu is shown. Before this method is called, the action group will be provided with an ActionContext containing the view selection. Clients can access the context using getContext().
  • The updateActionBars() method is invoked whenever the page's selection changes. Before this method is called, the action group will be provided with an ActionContext containing the view selection. Clients can access the context using getContext().
  • The modelChanged(ISynchronizeModelElement) method is invoked whenever the model being displayed is changed. This gives clients a chance to adjust the input to actions that operate on all visible elements.
  • The dispose() method is called when the page is disposed.
Since:
3.0
  • Constructor Details

    • SynchronizePageActionGroup

      public SynchronizePageActionGroup()
  • Method Details

    • initialize

      public void initialize(ISynchronizePageConfiguration configuration)
      Initialize the actions of this contribution. This method will be invoked once before any calls are made to filleContextMenu or setActionBars but after the control for the page has been created. As a result of this, the site of the configuration can be accessed. Subclasses may override this method but must invoke the overridden method.
      Parameters:
      configuration - the configuration for the part to which the contribution is associated
    • modelChanged

      public void modelChanged(ISynchronizeModelElement root)
      This method is invoked whenever the model being displayed in the view changes. This includes when the input to the view changes and when the children of the input change. The default implementation of this method does nothing. Subclasses may override.
      Parameters:
      root - the root of the model being viewed
    • dispose

      public void dispose()
      Dispose of the action group. Subclasses may override but must invoke the overridden method.
      Overrides:
      dispose in class ActionGroup
    • findGroup

      protected IContributionItem findGroup(IContributionManager menu, String groupId)
      Helper method to find the group of the given id for the page associated with the configuration of this action group. The id of the returned group will not match that of the provided id since the group must be modified to ensure that groups are unique across pages.
      Parameters:
      menu - the menu
      groupId - the id of the group being searched for
      Returns:
      the group for the given id or null
    • appendToGroup

      protected boolean appendToGroup(IContributionManager manager, String groupId, IAction action)
      Helper method to add an action to a group in a menu. The action is only added to the menu if the group exists in the menu. Calling this method also has no effect if either the menu or action are null.
      Parameters:
      manager - the menu manager
      groupId - the group to append the action to
      action - the action to add
      Returns:
      true if the group exists and the action was added and false if the action was not added
    • appendToGroup

      protected boolean appendToGroup(IContributionManager manager, String groupId, IContributionItem item)
      Helper method to add a contribution item to a group in a menu. The item is only added to the menu if the group exists in the menu. Calling this method also has no effect if either the menu or item are null.
      Parameters:
      manager - the menu manager
      groupId - the group to append the action to
      item - the item to add
      Returns:
      true if the group exists and the action was added and false if the action was not added
    • appendToGroup

      protected void appendToGroup(String menuId, String groupId, IAction action)
      Helper method that can be invoked during initialization to add an action to a particular menu (one of P_TOOLBAR_MENU, P_VIEW_MENU, P_CONTEXT_MENU from ISynchronizePageConfiguration). The action is added to the given group if it is present. Otherwise the action is not added to the menu.
      Parameters:
      menuId - the menu id (one of P_TOOLBAR_MENU, P_VIEW_MENU, P_CONTEXT_MENU from ISynchronizePageConfiguration)
      groupId - the group id in the menu to which the action is to be added
      action - the action to be added
    • appendToGroup

      protected void appendToGroup(String menuId, String groupId, IContributionItem item)
      Helper method that can be invoked during initialization to add an item to a particular menu (one of P_TOOLBAR_MENU, P_VIEW_MENU, P_CONTEXT_MENU from ISynchronizePageConfiguration). The item is added to the given group if it is present. Otherwise the item is not added to the menu.
      Parameters:
      menuId - the menu id (one of P_TOOLBAR_MENU, P_VIEW_MENU, P_CONTEXT_MENU from ISynchronizePageConfiguration)
      groupId - the group id in the menu to which the item is to be added
      item - the item to be added
    • getVisibleRootsSelectionProvider

      protected ISelectionProvider getVisibleRootsSelectionProvider()
      Return a selection provider whose selection includes all roots of the elements visible in the page. Selection change events are fired when the elements visible in the view change.
      Returns:
      a selection provider whose selection is the roots of all elements visible in the page
    • fillContextMenu

      public void fillContextMenu(IMenuManager menu)
      Description copied from class: ActionGroup
      Adds the applicable actions to a context menu, based on the state of the ActionContext.

      The default implementation does nothing. Subclasses may override or extend this method.

      Overrides:
      fillContextMenu in class ActionGroup
      Parameters:
      menu - the context menu manager
    • fillActionBars

      public void fillActionBars(IActionBars actionBars)
      Description copied from class: ActionGroup
      Adds the applicable actions to a part's action bars, including setting any global action handlers.

      The default implementation does nothing. Subclasses may override or extend this method.

      Overrides:
      fillActionBars in class ActionGroup
      Parameters:
      actionBars - the part's action bars
    • getConfiguration

      public ISynchronizePageConfiguration getConfiguration()
      Return the configuration for the page to which the action group is associated.
      Returns:
      the configuration for the page to which the action group is associated
      Since:
      3.1