FileDocCategorySizeDatePackage
MultiPageEditorContributor.javaAPI DocExample4202Tue Dec 09 14:04:32 GMT 2003org.eclipsebook.ch12.Ch1201.editors

MultiPageEditorContributor

public class MultiPageEditorContributor extends org.eclipse.ui.part.MultiPageEditorActionBarContributor
Manages the installation/deinstallation of global actions for multi-page editors. Responsible for the redirection of global actions to the active editor. Multi-page contributor replaces the contributors for the individual editors in the multi-page editor.

Fields Summary
private org.eclipse.ui.IEditorPart
activeEditorPart
private Action
sampleAction
Constructors Summary
public MultiPageEditorContributor()
Creates a multi-page contributor.

		super();
		createActions();
	
Methods Summary
public voidcontributeToMenu(IMenuManager manager)

		IMenuManager menu = new MenuManager("Editor &Menu");
		manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, menu);
		menu.add(sampleAction);
	
public voidcontributeToToolBar(IToolBarManager manager)

		manager.add(new Separator());
		manager.add(sampleAction);
	
private voidcreateActions()

		sampleAction = new Action() {
			public void run() {
				MessageDialog.openInformation(null, "Ch12_03 Plug-in", "Sample Action Executed");
			}
		};
		sampleAction.setText("Sample Action");
		sampleAction.setToolTipText("Sample Action tool tip");
		sampleAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
				getImageDescriptor(ISharedImages.IMG_OBJS_TASK_TSK));
	
protected IActiongetAction(org.eclipse.ui.texteditor.ITextEditor editor, java.lang.String actionID)
Returns the action registed with the given text editor.

return
IAction or null if editor is null.

		return (editor == null ? null : editor.getAction(actionID));
	
public voidsetActivePage(org.eclipse.ui.IEditorPart part)

		if (activeEditorPart == part)
			return;

		activeEditorPart = part;

		IActionBars actionBars = getActionBars();
		if (actionBars != null) {

			ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;

			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.DELETE,
				getAction(editor, ITextEditorActionConstants.DELETE));
			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.UNDO,
				getAction(editor, ITextEditorActionConstants.UNDO));
			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.REDO,
				getAction(editor, ITextEditorActionConstants.REDO));
			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.CUT,
				getAction(editor, ITextEditorActionConstants.CUT));
			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.COPY,
				getAction(editor, ITextEditorActionConstants.COPY));
			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.PASTE,
				getAction(editor, ITextEditorActionConstants.PASTE));
			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.SELECT_ALL,
				getAction(editor, ITextEditorActionConstants.SELECT_ALL));
			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.FIND,
				getAction(editor, ITextEditorActionConstants.FIND));
			actionBars.setGlobalActionHandler(
				IWorkbenchActionConstants.BOOKMARK,
				getAction(editor, ITextEditorActionConstants.BOOKMARK));
			actionBars.updateActionBars();
		}