Package org.eclipse.ui.menus
Class AbstractContributionFactory
java.lang.Object
org.eclipse.ui.menus.AbstractContributionFactory
- Direct Known Subclasses:
ExtensionContributionFactory
ContributionFactories are used by the IMenuService to populate
ContributionManagers. In
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.
- Since:
- 3.3
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractContributionFactory(String location, String namespace) The contribution factories must be instantiated with their location, which which specifies the contributions insertion location. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidcreateContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) This factory should create the IContributionItems that it wants to contribute, and add them to the additions list.Return the location as a String.Return the namespace for this cache.
-
Constructor Details
-
AbstractContributionFactory
The contribution factories must be instantiated with their location, which which specifies the contributions insertion location.- Parameters:
location- the addition location in Menu API URI format. It must not benull.namespace- the namespace for this contribution. May benull.- See Also:
-
-
Method Details
-
getLocation
Return the location as a String.- Returns:
- the location - never
null.
-
getNamespace
Return the namespace for this cache. This corresponds to the plug-in that is contributing this factory.- Returns:
- the namespace the namespace of this factory
-