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; 12 13 /** 14 * A editor action bar contributor defines the actions for 15 * one or more editors. 16 * <p> 17 * Within the workbench there may be more than one open editor of a particular 18 * type. For instance, there may be 1 or more open Java Editors. To avoid the 19 * creation of duplicate actions and action images the editor concept has been 20 * split into two. An action contributor is responsable for the creation of 21 * actions. The editor is responsible for action implementation. Furthermore, 22 * the contributor is shared by each open editor. As a result of this design 23 * there is only 1 set of actions for 1 or more open editors. 24 * </p><p> 25 * The relationship between editor and contributor is defined by 26 * the <code>org.eclipse.ui.editors</code> extension point in the plugin registry. 27 * For each extension an editor class and a contributor class must be defined. 28 * </p><p> 29 * This interface should not be implemented directly. An implementation of this 30 * interface has been created in <code>EditorActionBarContributor</code>. 31 * Implementors should subclass this and specialize as required. 32 * </p> 33 * 34 * @see IEditorActionBarContributor 35 */ 36 public interface IEditorActionBarContributor { 37 /** 38 * Initializes this contributor, which is expected to add contributions as 39 * required to the given action bars and global action handlers. 40 * <p> 41 * The page is passed to support the use of <code>RetargetAction</code> by 42 * the contributor. In this case the init method implementors should: 43 * </p> 44 * <p><ul> 45 * <li>1) set retarget actions as global action handlers</li> 46 * <li>2) add the retarget actions as part listeners</li> 47 * <li>3) get the active part and if not <code>null</code> 48 * call partActivated on the retarget actions</li> 49 * </ul></p> 50 * <p> 51 * And in the dispose method the retarget actions should be removed as part listeners. 52 * </p> 53 * 54 * @param bars the action bars 55 * @param page the workbench page for this contributor 56 * @since 2.0 57 */ 58 public void init(IActionBars bars, IWorkbenchPage page); 59 60 /** 61 * Sets the active editor for the contributor. 62 * Implementors should disconnect from the old editor, connect to the 63 * new editor, and update the actions to reflect the new editor. 64 * 65 * @param targetEditor the new editor target 66 */ 67 public void setActiveEditor(IEditorPart targetEditor); 68 69 /** 70 * Disposes this contributor. 71 * 72 * @since 2.0 73 */ 74 public void dispose(); 75 } 76