01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.part;
11:
12: import org.eclipse.ui.IEditorPart;
13:
14: /**
15: * Abstract base class for managing the installation/deinstallation of global
16: * actions for multi-page editors.
17: * <p>
18: * Subclasses must implement <code>setActivePage</code>, and may reimplement
19: * any of the following methods:
20: * <ul>
21: * <li><code>contributeToMenu</code> - reimplement to contribute to menu</li>
22: * <li><code>contributeToToolBar</code> - reimplement to contribute to tool
23: * bar</li>
24: * <li><code>contributeToStatusLine</code> - reimplement to contribute to
25: * status line</li>
26: * </ul>
27: * </p>
28: */
29: public abstract class MultiPageEditorActionBarContributor extends
30: EditorActionBarContributor {
31: /**
32: * Creates a multi-page editor action contributor.
33: */
34: protected MultiPageEditorActionBarContributor() {
35: super ();
36: }
37:
38: /* (non-JavaDoc)
39: * Method declared on EditorActionBarContributor
40: * Registers the contributor with the multi-page editor for future
41: * editor action redirection when the active page is changed, and sets
42: * the active page.
43: */
44: public void setActiveEditor(IEditorPart part) {
45: IEditorPart activeNestedEditor = null;
46: if (part instanceof MultiPageEditorPart) {
47: activeNestedEditor = ((MultiPageEditorPart) part)
48: .getActiveEditor();
49: }
50: setActivePage(activeNestedEditor);
51: }
52:
53: /**
54: * Sets the active page of the the multi-page editor to be the given editor.
55: * Redirect actions to the given editor if actions are not already being sent to it.
56: * <p>
57: * This method is called whenever the page changes.
58: * Subclasses must implement this method to redirect actions to the given
59: * editor (if not already directed to it).
60: * </p>
61: *
62: * @param activeEditor the new active editor, or <code>null</code> if there is no active page, or if the
63: * active page does not have a corresponding editor
64: */
65: public abstract void setActivePage(IEditorPart activeEditor);
66: }
|