KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > part > MultiPageEditorActionBarContributor


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.part;
12
13 import org.eclipse.ui.IEditorPart;
14
15 /**
16  * Abstract base class for managing the installation/deinstallation of global
17  * actions for multi-page editors.
18  * <p>
19  * Subclasses must implement <code>setActivePage</code>, and may reimplement
20  * any of the following methods:
21  * <ul>
22  * <li><code>contributeToMenu</code> - reimplement to contribute to menu</li>
23  * <li><code>contributeToToolBar</code> - reimplement to contribute to tool
24  * bar</li>
25  * <li><code>contributeToStatusLine</code> - reimplement to contribute to
26  * status line</li>
27  * </ul>
28  * </p>
29  */

30 public abstract class MultiPageEditorActionBarContributor extends
31         EditorActionBarContributor {
32     /**
33      * Creates a multi-page editor action contributor.
34      */

35     protected MultiPageEditorActionBarContributor() {
36         super();
37     }
38
39     /* (non-JavaDoc)
40      * Method declared on EditorActionBarContributor
41      * Registers the contributor with the multi-page editor for future
42      * editor action redirection when the active page is changed, and sets
43      * the active page.
44      */

45     public void setActiveEditor(IEditorPart part) {
46         IEditorPart activeNestedEditor = null;
47         if (part instanceof MultiPageEditorPart) {
48             activeNestedEditor = ((MultiPageEditorPart) part).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 }
67
Popular Tags