com.ibm.mashups.builder.model
Interface ContextMenu


public ContextMenu

This interface defines Context Menu operations.


Method Summary
 Boolean registerContextMenu(String contextMenuId, ContextMenuLoader contextMenuLoader)
           Register a context menu loader at a particular id that will be used to load items when requested by the getContextMenu or getContextMenuDeferred functions using the registered id.
 String addContribution(String contextMenuId, ContextMenuLoader contributionLoader, Number ordinal)
           Adds a contribution to a context menu with the given contextMenuId.
 ContextMenuLoader removeContribution(String contextMenuId, String id)
           Removes a contribution from a context menu with the given contextMenuId by the id that uniquely identifies that contribution within the particular context menu.
 ContextMenuLoader[] getContributions(String contextMenuId)
           Gets an array of all the contributions that have been added to a context menu with the given contextMenuId.
 Object registerListener(String contextMenuId, Object scope, Function func)
           Register a listener function which will be fired whenever a particular context menu identified by the contextMenuId is updated.
 Object registerListener(String contextMenuId, Function func)
           Register a listener function which will be fired whenever a particular context menu identified by the contextMenuId is updated.
 void unregisterListener(Object handle)
           Unregisters a previously registered listener to a context menu's onChange event.
 

Method Detail

registerContextMenu

Boolean registerContextMenu(String contextMenuId,
                            ContextMenuLoader contextMenuLoader)
Register a context menu loader at a particular id that will be used to load items when requested by the getContextMenu or getContextMenuDeferred functions using the registered id. A default loader will be used if nothing has been registered with a particular contextMenuId when requested. This function replaces any existing context menu loader that was registered to the same contextMenuId. Registering a null context menu loader will effectively remove any existing loader that is already registered to the same contextMenuId.

Parameters:
contextMenuId - id of menu to retrieve contributions from. Must not be null.
contextMenuLoader - contextMenuLoader to be register to a particular id. May be null.
Returns:
boolean indicating if the registration was successful

addContribution

String addContribution(String contextMenuId,
                       ContextMenuLoader contributionLoader,
                       Number ordinal)
Adds a contribution to a context menu with the given contextMenuId. The contribution defines a set of menu items to be inserted in a group into the given context menu. When the context menu is requested, its base contents as well as any contributions that have been added to it will be merged such that contribution items are kept together and are ordered relative to their contribution, then merged together into a flat list of items.

Parameters:
contextMenuId - id of menu to contribute to. Must not be null.
contributionLoader - contribution to add to the menu.
ordinal - Optional value used for relative ordering with the base items and other contributions.
Returns:
the id of the contribution that was added, or null if the contribution was null. This id may be used to remove the contribution later via the removeContribution function.

removeContribution

ContextMenuLoader removeContribution(String contextMenuId,
                                     String id)
Removes a contribution from a context menu with the given contextMenuId by the id that uniquely identifies that contribution within the particular context menu. The id is what the system returns when the contribution is added via the addContribution function.

Parameters:
contextMenuId - id of menu remove the contribution from. Must not be null.
id - id of contribution to remove from the menu.
Returns:
the contribution that was removed, or null if no match was found

getContributions

ContextMenuLoader[] getContributions(String contextMenuId)
Gets an array of all the contributions that have been added to a context menu with the given contextMenuId.

Parameters:
contextMenuId - id of menu to retrieve contributions from. Must not be null.
Returns:
an array of contributions; may be an empty array, but is never null.

registerListener

Object registerListener(String contextMenuId,
                        Object scope,
                        Function func)
Register a listener function which will be fired whenever a particular context menu identified by the contextMenuId is updated. This may occur any of the following circumstances:
1) A contribution is added
2) A contribution is removed
3) A contribution ContextMenuLoader is updated via its onChange event
4) The base context menu ContextMenuLoader is updated via its onChange event

Listeners may choose to respond to this event however desired, such as by requesting the context menu again in order to receive an updated set of items.

Parameters:
contextMenuId - id of the context menu to which to register the listener. Must not be null.
scope - scope in which the function will be invoked when the event is fired. May be null to default to global scope.
func - function to be called whenever the context menu is changed. May be the function reference itself, or the String name of the function on the scope object. Must not be null.
The function signature is: function(contextMenuId) { }
    String contextMenuId id of the context menu that was updated
Returns:
a connection handle that can be used to unregister the listener.

registerListener

Object registerListener(String contextMenuId,
                        Function func)
Register a listener function which will be fired whenever a particular context menu identified by the contextMenuId is updated. This may occur any of the following circumstances:
1) A contribution is added
2) A contribution is removed
3) A contribution ContextMenuLoader is updated via its onChange event
4) The base context menu ContextMenuLoader is updated via its onChange event

Listeners can choose to respond to this event however desired, such as by requesting the context menu again in order to receive an updated set of items.

Parameters:
contextMenuId - id of the context menu to which to register the listener. Must not be null.
func - function to be called whenever the context menu is changed. May be the function reference itself, or the String name of the function in the global scope. Must not be null.
The function signature is: function(contextMenuId) { }
    String contextMenuId id of the context menu that was updated
Returns:
a connection handle that can be used to unregister the listener.

unregisterListener

void unregisterListener(Object handle)
Unregisters a previously registered listener to a context menu's onChange event.

Parameters:
handle - connection handle that was returned by a call to registerListener. Must not be null.


Copyright IBM Corp. 2010 All Rights Reserved.