Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.ui.menus
Class AbstractContributionFactory


java.lang.Object
  extended by 
org.eclipse.ui.menus.AbstractContributionFactory
Direct Known Subclasses:
ExtensionContributionFactory

public abstract class AbstractContributionFactory
extends Object

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:
IMenuService, MenuManager, ToolBarManager

Constructor Summary
AbstractContributionFactory ( String location, String namespace)
          The contribution factories must be instantiated with their location, which which specifies the contributions insertion location.
 
Method Summary
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.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractContributionFactory

public AbstractContributionFactory(
String location,
                                   
String namespace)
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 be null.
namespace - the namespace for this contribution. May be null.
See Also:
getNamespace()
Method Detail

getLocation

public 
String getLocation()
Return the location as a String.

Returns:
the location - never null.

createContributionItems

public 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. The menu service will call this method at the appropriate time. It should always return new instances of its contributions in the additions list.

This method is not meant to be called by clients. It will be called by the menu service at the appropriate time.

Parameters:
serviceLocator - a service locator that may be used in the construction of items created by this factory
additions - A IContributionRoot supplied by the framework. It will never be null.
See Also:
CommandContributionItem, MenuManager

getNamespace

public 
String 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

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire