1 /******************************************************************************* 2 * Copyright (c) 2000, 2015 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.ui; 15 16 import org.eclipse.jface.action.MenuManager; 17 import org.eclipse.jface.viewers.ISelectionProvider; 18 import org.eclipse.ui.contexts.IContextService; 19 import org.eclipse.ui.handlers.IHandlerService; 20 import org.eclipse.ui.services.IServiceLocator; 21 22 /** 23 * The primary interface between a workbench part and the workbench. 24 * <p> 25 * This interface is not intended to be implemented or extended by clients. 26 * </p> 27 * 28 * @noimplement This interface is not intended to be implemented by clients. 29 */ 30 public interface IWorkbenchPartSite extends IWorkbenchSite { 31 32 /** 33 * Returns the part registry extension id for this workbench site's part. 34 * <p> 35 * The name comes from the <code>id</code> attribute in the configuration 36 * element. 37 * </p> 38 * 39 * @return the registry extension id 40 */ getId()41 String getId(); 42 43 /** 44 * Returns the unique identifier of the plug-in that defines this workbench 45 * site's part. 46 * 47 * @return the unique identifier of the declaring plug-in 48 */ getPluginId()49 String getPluginId(); 50 51 /** 52 * Returns the registered name for this workbench site's part. 53 * <p> 54 * The name comes from the <code>name</code> attribute in the configuration 55 * element. 56 * </p> 57 * 58 * @return the part name 59 */ getRegisteredName()60 String getRegisteredName(); 61 62 /** 63 * Registers a pop-up menu with a particular id for extension. This method 64 * should only be called if the target part has more than one context menu to 65 * register. 66 * <p> 67 * For a detailed description of context menu registration see 68 * <code>registerContextMenu(MenuManager, ISelectionProvider);</code> 69 * </p> 70 * 71 * @param menuId the menu id 72 * @param menuManager the menu manager 73 * @param selectionProvider the selection provider 74 */ registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider)75 void registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider); 76 77 /** 78 * Registers a pop-up menu with the default id for extension. The default id is 79 * defined as the part id. 80 * <p> 81 * Within the workbench one plug-in may extend the pop-up menus for a view or 82 * editor within another plug-in. In order to be eligible for extension, the 83 * target part must publish each menu by calling 84 * <code>registerContextMenu</code>. Once this has been done the workbench will 85 * automatically insert any action extensions which exist. 86 * </p> 87 * <p> 88 * A menu id must be provided for each registered menu. For consistency across 89 * parts the following strategy should be adopted by all part implementors. 90 * </p> 91 * <ol> 92 * <li>If the target part has only one context menu it should be registered with 93 * <code>id == part id</code>. This can be done easily by calling 94 * <code>registerContextMenu(MenuManager, ISelectionProvider)</code>. 95 * <li>If the target part has more than one context menu a unique id should be 96 * defined for each. Prefix each menu id with the part id and publish these ids 97 * within the javadoc for the target part. Register each menu at runtime by 98 * calling <code>registerContextMenu(String, MenuManager, 99 * ISelectionProvider)</code>.</li> 100 * </ol> 101 * <p> 102 * Any pop-up menu which is registered with the workbench should also define a 103 * <code>GroupMarker</code> in the registered menu with id 104 * <code>IWorkbenchActionConstants.MB_ADDITIONS</code>. Other plug-ins will use 105 * this group as a reference point for insertion. The marker should be defined 106 * at an appropriate location within the menu for insertion. 107 * </p> 108 * 109 * @param menuManager the menu manager 110 * @param selectionProvider the selection provider 111 */ registerContextMenu(MenuManager menuManager, ISelectionProvider selectionProvider)112 void registerContextMenu(MenuManager menuManager, ISelectionProvider selectionProvider); 113 114 /** 115 * Returns the key binding service in use. 116 * <p> 117 * The part will access this service to register all of its actions, to set the 118 * active scope. 119 * </p> 120 * 121 * @return the key binding service in use 122 * @since 2.1 123 * @deprecated Use {@link IServiceLocator#getService(Class)} instead. 124 * @see IContextService 125 * @see IHandlerService 126 */ 127 @Deprecated getKeyBindingService()128 IKeyBindingService getKeyBindingService(); 129 130 /** 131 * Returns the part associated with this site 132 * 133 * @since 3.1 134 * 135 * @return the part associated with this site 136 */ getPart()137 IWorkbenchPart getPart(); 138 } 139