org.eclipse.ecf.presence.ui.menu
Class AbstractRosterMenuContributionItem

java.lang.Object
  extended by org.eclipse.jface.action.ContributionItem
      extended by org.eclipse.ui.actions.CompoundContributionItem
          extended by org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem
All Implemented Interfaces:
org.eclipse.jface.action.IContributionItem
Direct Known Subclasses:
ConsoleRosterMenuContributionItem, DocShareRosterMenuContributionItem, NoopRosterMenuContributionItem

public abstract class AbstractRosterMenuContributionItem
extends org.eclipse.ui.actions.CompoundContributionItem

A contribution that dynamically constructs a menu for the currently connected rosters. This class may be subclassed in order to create a AbstractRosterMenuHandler for handling selection of a given IRosterEntry from the menu.


Field Summary
protected static org.eclipse.jface.action.IContributionItem[] NO_CONTRIBUTIONS
           
 
Constructor Summary
AbstractRosterMenuContributionItem()
           
AbstractRosterMenuContributionItem(java.lang.String id)
           
 
Method Summary
protected  boolean addEntry(IRosterEntry entry)
          Determines whether given entry should be added for IContribution.
protected  org.eclipse.ui.menus.CommandContributionItem createCommandContributionItemForEntry(java.lang.String commandId, IRosterEntry rosterEntry)
          Create a command contribution item for the given entry with the given commandId.
protected  org.eclipse.jface.action.IContributionItem[] createContributionItemsForEntry(IRosterEntry entry)
          Create contribution items for a given roster entry.
protected  org.eclipse.jface.action.IContributionItem[] createContributionItemsForGroup(IRosterGroup group)
          Create contribution items for a given roster.
protected  org.eclipse.jface.action.IContributionItem[] createContributionItemsForPresenceContainer(IPresenceContainerAdapter presenceContainerAdapter)
          Create contribution items for a given presence container adapter.
protected  org.eclipse.jface.action.IContributionItem[] createContributionItemsForRoster(IRoster roster)
          Create contribution items for a given roster.
protected  org.eclipse.jface.action.MenuManager createMenuManagerForGroup(IRosterGroup group)
          Create a MenuManager for the given IRosterGroup.
protected  org.eclipse.jface.action.MenuManager createMenuManagerForRoster(IRoster roster)
          Create a MenuManager for the given IRosterGroup.
protected  org.eclipse.jface.action.MenuManager createMenuManagerForTop()
          Create a MenuManager for the top level menu.
protected abstract  AbstractRosterMenuHandler createRosterEntryHandler(IRosterEntry rosterEntry)
          Create a AbstractRosterMenuHandler for a given IRosterEntry instance.
 void dispose()
           
protected  org.eclipse.jface.action.IContributionItem[] getContributionItems()
           
protected  java.util.List getPresenceContainerAdapters()
           
protected  org.eclipse.jface.resource.ImageDescriptor getRosterEntryImageDescriptor(IRosterEntry entry)
           
protected  org.eclipse.jface.resource.ImageDescriptor getTopMenuImageDescriptor()
           
 void setTopMenuImageDescriptor(org.eclipse.jface.resource.ImageDescriptor image)
           
protected  void setTopMenuName(java.lang.String name)
           
 
Methods inherited from class org.eclipse.ui.actions.CompoundContributionItem
fill, isDirty, isDynamic, setParent
 
Methods inherited from class org.eclipse.jface.action.ContributionItem
fill, fill, fill, getId, getParent, isEnabled, isGroupMarker, isSeparator, isVisible, saveWidgetState, setId, setVisible, toString, update, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_CONTRIBUTIONS

protected static final org.eclipse.jface.action.IContributionItem[] NO_CONTRIBUTIONS
Constructor Detail

AbstractRosterMenuContributionItem

public AbstractRosterMenuContributionItem()

AbstractRosterMenuContributionItem

public AbstractRosterMenuContributionItem(java.lang.String id)
Method Detail

setTopMenuName

protected void setTopMenuName(java.lang.String name)

setTopMenuImageDescriptor

public void setTopMenuImageDescriptor(org.eclipse.jface.resource.ImageDescriptor image)

getTopMenuImageDescriptor

protected org.eclipse.jface.resource.ImageDescriptor getTopMenuImageDescriptor()

createContributionItemsForRoster

protected org.eclipse.jface.action.IContributionItem[] createContributionItemsForRoster(IRoster roster)
Create contribution items for a given roster. Subclasses may override as appropriate to customize the creation of contributions with an alternative strategy.

Parameters:
roster - the roster to create contribution items for. Must not be null.
Returns:
IContributionItem[] for given IRoster. Will not return null.

createContributionItemsForGroup

protected org.eclipse.jface.action.IContributionItem[] createContributionItemsForGroup(IRosterGroup group)
Create contribution items for a given roster. Subclasses may override as appropriate to customize the creation of contributions with an alternative strategy.

Parameters:
group - the IRosterGroup to create contribution items for. Must not be null.
Returns:
IContributionItem[] for given IRosterGroup. Will not return null.

createMenuManagerForGroup

protected org.eclipse.jface.action.MenuManager createMenuManagerForGroup(IRosterGroup group)
Create a MenuManager for the given IRosterGroup.

Parameters:
group - the IRosterGroup to create the menu manager for. Will not be null.
Returns:
the menu manager. Should not be null.

createContributionItemsForPresenceContainer

protected org.eclipse.jface.action.IContributionItem[] createContributionItemsForPresenceContainer(IPresenceContainerAdapter presenceContainerAdapter)
Create contribution items for a given presence container adapter. Subclasses may override as appropriate to customize the creation of contributions with an alternative strategy.

Parameters:
presenceContainerAdapter - the IPresenceContainerAdapter to create contribution items for. Must not be null.
Returns:
IContributionItem[] for given IPresenceContainerAdapter. Will not return null.

createMenuManagerForRoster

protected org.eclipse.jface.action.MenuManager createMenuManagerForRoster(IRoster roster)
Create a MenuManager for the given IRosterGroup.

Parameters:
roster - the IRosterGroup to create the menu manager for. Will not be null.
Returns:
the menu manager. Should not be null.

createRosterEntryHandler

protected abstract AbstractRosterMenuHandler createRosterEntryHandler(IRosterEntry rosterEntry)
Create a AbstractRosterMenuHandler for a given IRosterEntry instance. Implementers of this method should construct and return a new AbstractRosterMenuHandler. When a menu selection is made for a given IRosterEntry menu item, the associated AbstractRosterMenuHandler instance will have its AbstractRosterMenuHandler.execute(org.eclipse.core.commands.ExecutionEvent) method will be called. This way, subclasses may define arbitrary behavior for the dynamic menu item selection.

Parameters:
rosterEntry - the IRosterEntry for the AbstractRosterMenuHandler. Will not be null.
Returns:
AbstractRosterMenuHandler instance. Must not be null.

addEntry

protected boolean addEntry(IRosterEntry entry)
Determines whether given entry should be added for IContribution. This implementation only returns true if the given IRosterEntry.getPresence() IPresence.Type is AVAILABLE, and IPresence.Mode is AVAILABLE. Subclasses may override as appropriate to customize the behavior of this contribution item.

Parameters:
entry - the IRosterEntry to check. Must not be null.
Returns:
true if the given IRosterEntry should be added, false otherwise.

createContributionItemsForEntry

protected org.eclipse.jface.action.IContributionItem[] createContributionItemsForEntry(IRosterEntry entry)
Create contribution items for a given roster entry. Subclasses may override as appropriate to customize the creation of contributions with an alternative strategy.

Parameters:
entry - the IRosterEntry to create contribution items for. Must not be null.
Returns:
IContributionItem[] for given IPresenceContainerAdapter. Will not return null.

getRosterEntryImageDescriptor

protected org.eclipse.jface.resource.ImageDescriptor getRosterEntryImageDescriptor(IRosterEntry entry)

createCommandContributionItemForEntry

protected org.eclipse.ui.menus.CommandContributionItem createCommandContributionItemForEntry(java.lang.String commandId,
                                                                                             IRosterEntry rosterEntry)
Create a command contribution item for the given entry with the given commandId.

Parameters:
commandId - the commandId for the new CommandContributionItem. Must not be null.
rosterEntry - the IRosterEntry for the new CommandContributionItem. Must not be null.
Returns:
CommandContributionItem created. Must not return null.

dispose

public void dispose()
Specified by:
dispose in interface org.eclipse.jface.action.IContributionItem
Overrides:
dispose in class org.eclipse.ui.actions.CompoundContributionItem

getPresenceContainerAdapters

protected java.util.List getPresenceContainerAdapters()

getContributionItems

protected org.eclipse.jface.action.IContributionItem[] getContributionItems()
Specified by:
getContributionItems in class org.eclipse.ui.actions.CompoundContributionItem

createMenuManagerForTop

protected org.eclipse.jface.action.MenuManager createMenuManagerForTop()
Create a MenuManager for the top level menu.

Returns:
the menu manager. Should not be null.