
org.eclipse.ui.part.EditorActionBarContributor Maven / Gradle / Ivy
package org.eclipse.ui.part;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IActionBars2;
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
/**
* Standard implementation of IEditorActionBarContributor
.
*
* If instantiated and used as-is, nothing is contribututed. Clients should
* subclass in order to contribute to some or all of the action bars.
*
* Subclasses may reimplement the following methods:
*
* contributeToMenu
- reimplement to contribute to menu
* contributeToToolBar
- reimplement to contribute to tool bar
* contributeToStatusLine
- reimplement to contribute to status
* line
* setActiveEditor
- reimplement to react to editor changes
*
*
*/
public class EditorActionBarContributor implements IEditorActionBarContributor {
/**
* The action bars; null
until init
is called.
*/
private IActionBars bars;
/**
* The workbench page; null
until init
is called.
*/
private IWorkbenchPage page;
/**
* Creates an empty editor action bar contributor. The action bars are
* furnished later via the init
method.
*/
public EditorActionBarContributor() {
}
/**
* Contributes to the given menu.
*
* The EditorActionBarContributor
implementation of this method
* does nothing. Subclasses may reimplement to add to the menu portion of
* this contribution.
*
*
* @param menuManager
* the manager that controls the menu
*/
public void contributeToMenu(IMenuManager menuManager) {
}
/**
* Contributes to the given status line.
*
* The EditorActionBarContributor
implementation of this method
* does nothing. Subclasses may reimplement to add to the status line
* portion of this contribution.
*
*
* @param statusLineManager
* the manager of the status line
*/
public void contributeToStatusLine(IStatusLineManager statusLineManager) {
}
/**
* Contributes to the given tool bar.
*
* The EditorActionBarContributor
implementation of this method
* does nothing. Subclasses may reimplement to add to the tool bar portion
* of this contribution.
*
*
* @param toolBarManager
* the manager that controls the workbench tool bar
*/
public void contributeToToolBar(IToolBarManager toolBarManager) {
}
/**
* Contributes to the given cool bar.
*
* The EditorActionBarContributor
implementation of this method
* does nothing. Subclasses may reimplement to add to the cool bar portion
* of this contribution. There can only be contributions from a cool bar or
* a tool bar.
*
*
* @param coolBarManager
* the manager that controls the workbench cool bar.
*
* @since 3.0
*/
public void contributeToCoolBar(ICoolBarManager coolBarManager) {
}
/**
* Returns this contributor's action bars.
*
* @return the action bars
*/
public IActionBars getActionBars() {
return bars;
}
/**
* Returns this contributor's workbench page.
*
* @return the workbench page
*/
public IWorkbenchPage getPage() {
return page;
}
/**
* The EditorActionBarContributor
implementation of this
* IEditorActionBarContributor
method does nothing, subclasses
* may override.
*/
public void dispose() {
}
/**
* The EditorActionBarContributor
implementation of this
* IEditorActionBarContributor
method remembers the page then
* forwards the call to init(IActionBars)
for backward
* compatibility
*/
public void init(IActionBars bars, IWorkbenchPage page) {
this.page = page;
init(bars);
}
/**
* This method calls:
*
* contributeToMenu
with bars
' menu manager
* contributeToToolBar
with bars
' tool bar
* manager
* contributeToCoolBar
with bars
' cool bar
* manager if IActionBars
is of extended type
* IActionBars2
* contributeToStatusLine
with bars
' status
* line manager
*
* The given action bars are also remembered and made accessible via
* getActionBars
.
*
* @param bars
* the action bars
*/
public void init(IActionBars bars) {
this.bars = bars;
contributeToMenu(bars.getMenuManager());
contributeToToolBar(bars.getToolBarManager());
if (bars instanceof IActionBars2) {
contributeToCoolBar(((IActionBars2) bars).getCoolBarManager());
}
contributeToStatusLine(bars.getStatusLineManager());
}
/**
* Sets the active editor for the contributor.
*
* The EditorActionBarContributor
implementation of this method
* does nothing. Subclasses may reimplement. This generally entails
* disconnecting from the old editor, connecting to the new editor, and
* updating the actions to reflect the new editor.
*
*
* @param targetEditor
* the new target editor
*/
public void setActiveEditor(IEditorPart targetEditor) {
}
}