public abstract class AbstractContributionFactory extends Object
createContributionItems(IServiceLocator, IContributionRoot)
you fill in the additions List with IContributionItem
to be inserted at this
factory's location. For example:
AbstractContributionFactory contributions = new AbstractContributionFactory( "menu:org.eclipse.ui.tests.api.MenuTestHarness?after=additions") { public void createContributionItems(IMenuService menuService, List additions) { CommandContributionItem item = new CommandContributionItem( "org.eclipse.ui.tests.menus.helloWorld", "org.eclipse.ui.tests.commands.enabledHelloWorld", null, null, "Say Hello", null); additions.add(item); item = new CommandContributionItem( "org.eclipse.ui.tests.menus.refresh", "org.eclipse.ui.tests.commands.refreshView", null, null, "Refresh", null); menuService.registerVisibleWhen(item, new MyActiveContextExpression( "org.eclipse.ui.tests.myview.context")); additions.add(item); } public void releaseContributionItems(IMenuService menuService, List items) { // we have nothing to do } }; IMenuService service = (IMenuService) PlatformUI.getWorkbench().getService( IMenuService.class); service.addContributionFactory(contributions);
Clients who are providing factories via the org.eclipse.ui.menus
extension point should subclass ExtensionContributionFactory
instead.
Only the abstract methods may be implemented.
IMenuService
,
MenuManager
,
ToolBarManager
Constructor and Description |
---|
AbstractContributionFactory(String location,
String namespace)
The contribution factories must be instantiated with their location,
which which specifies the contributions insertion location.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
createContributionItems(IServiceLocator serviceLocator,
IContributionRoot additions)
This factory should create the IContributionItems that it wants to
contribute, and add them to the additions list.
|
String |
getLocation()
Return the location as a String.
|
String |
getNamespace()
Return the namespace for this cache.
|
public AbstractContributionFactory(String location, String namespace)
location
- the addition location in Menu API URI format. It must not be
null
.namespace
- the namespace for this contribution. May be null
.getNamespace()
public String getLocation()
null
.public abstract void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions)
This method is not meant to be called by clients. It will be called by the menu service at the appropriate time.
serviceLocator
- a service locator that may be used in the construction of
items created by this factoryadditions
- A IContributionRoot
supplied by the framework. It will
never be null
.CommandContributionItem
,
MenuManager
public String getNamespace()
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.