Package org.eclipse.team.ui.synchronize
Class SynchronizePageActionGroup
java.lang.Object
org.eclipse.ui.actions.ActionGroup
org.eclipse.team.ui.synchronize.SynchronizePageActionGroup
- Direct Known Subclasses:
ModelSynchronizeParticipantActionGroup
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 fornull
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 anActionContext
containing the view selection. Clients can access the context usinggetContext()
. - The
updateActionBars()
method is invoked whenever the page's selection changes. Before this method is called, the action group will be provided with anActionContext
containing the view selection. Clients can access the context usinggetContext()
. - 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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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).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).protected boolean
appendToGroup
(IContributionManager manager, String groupId, IAction action) Helper method to add an action to a group in a menu.protected boolean
appendToGroup
(IContributionManager manager, String groupId, IContributionItem item) Helper method to add a contribution item to a group in a menu.void
dispose()
Dispose of the action group.void
fillActionBars
(IActionBars actionBars) Adds the applicable actions to a part's action bars, including setting any global action handlers.void
fillContextMenu
(IMenuManager menu) Adds the applicable actions to a context menu, based on the state of theActionContext
.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.Return the configuration for the page to which the action group is associated.protected ISelectionProvider
Return a selection provider whose selection includes all roots of the elements visible in the page.void
initialize
(ISynchronizePageConfiguration configuration) Initialize the actions of this contribution.void
This method is invoked whenever the model being displayed in the view changes.Methods inherited from class org.eclipse.ui.actions.ActionGroup
getContext, setContext, updateActionBars
-
Constructor Details
-
SynchronizePageActionGroup
public SynchronizePageActionGroup()
-
-
Method Details
-
initialize
Initialize the actions of this contribution. This method will be invoked once before any calls are made tofilleContextMenu
orsetActionBars
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
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 classActionGroup
-
findGroup
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 menugroupId
- the id of the group being searched for- Returns:
- the group for the given id or
null
-
appendToGroup
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 arenull
.- Parameters:
manager
- the menu managergroupId
- the group to append the action toaction
- the action to add- Returns:
true
if the group exists and the action was added andfalse
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 arenull
.- Parameters:
manager
- the menu managergroupId
- the group to append the action toitem
- the item to add- Returns:
true
if the group exists and the action was added andfalse
if the action was not added
-
appendToGroup
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 addedaction
- the action to be added
-
appendToGroup
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 addeditem
- the item to be added
-
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
Description copied from class:ActionGroup
Adds the applicable actions to a context menu, based on the state of theActionContext
.The default implementation does nothing. Subclasses may override or extend this method.
- Overrides:
fillContextMenu
in classActionGroup
- Parameters:
menu
- the context menu manager
-
fillActionBars
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 classActionGroup
- Parameters:
actionBars
- the part's action bars
-
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
-