Skip to main content
Jump to: navigation, search

Difference between revisions of "Roster Menus"

(Customizing the Roster Menu)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
It's now possible to create a '''Roster Menu'''...i.e. a dynamically created menu from the ECF contacts list/roster.
 
It's now possible to create a '''Roster Menu'''...i.e. a dynamically created menu from the ECF contacts list/roster.
  
So, for example, here's my current contacts list:
+
For example, here's my current contacts list:
  
 
[[Image:contacts.png]]
 
[[Image:contacts.png]]
  
Here's a new roster menu, that shows as a menu the active roster entries (buddies)
+
Here's a new '''roster menu''', that shows the current roster as a dynamically-constructed menu
  
 
[[Image:contactsmenu.png]]
 
[[Image:contactsmenu.png]]
  
 
Note that this menu can be added to '''any''' existing menu using the platform UI [[Menu Contributions]] mechanisms.  So this roster menu can be used to interact with roster entry items in any appropriate context (e.g. an editor, a view, workbench, etc).
 
Note that this menu can be added to '''any''' existing menu using the platform UI [[Menu Contributions]] mechanisms.  So this roster menu can be used to interact with roster entry items in any appropriate context (e.g. an editor, a view, workbench, etc).
 +
 +
Note also that only the active participants (in this case, Ted Kubaska) and not the 'away' participants appear in the roster menu.  This is a default, which can be customized if desired so that away or dnd participants can also be added.
 +
 +
===How is a roster menu added to an existing menu?===
  
 
The way this works is that a plugin can add markup similar to the following to specify a new roster menu contribution:
 
The way this works is that a plugin can add markup similar to the following to specify a new roster menu contribution:
Line 28: Line 32:
 
Notice the class '''org.eclipse.ecf.presence.ui.menu.NoopRosterMenuContributionItem'''.  This is a new class that creates a roster menu contribution that does nothing (performs a noop).  The way this works is that the command handler associated with this contribution item does nothing, so that when the Ted Kubaska menu item is chosen, nothing happens.  
 
Notice the class '''org.eclipse.ecf.presence.ui.menu.NoopRosterMenuContributionItem'''.  This is a new class that creates a roster menu contribution that does nothing (performs a noop).  The way this works is that the command handler associated with this contribution item does nothing, so that when the Ted Kubaska menu item is chosen, nothing happens.  
  
It's easy, however to create a subclass of '''[org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem''' and customize the roster menu behavior.  The following is the implementation of '''org.eclipse.ecf.presence.ui.menu.NoopRosterMenuContributionItem''':
+
===Customizing the Roster Menu===
 +
 
 +
It's easy to create a subclass of [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/presence/ui/menu/AbstractRosterMenuContributionItem.html org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem] and customize the roster menu behavior.  As an example, the following is the implementation of '''org.eclipse.ecf.presence.ui.menu.NoopRosterMenuContributionItem''':
  
 
<pre>
 
<pre>
Line 45: Line 51:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
When a roster menu item is selected, the [http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/presence/ui/menu/AbstractRosterMenuHandler.html#execute(org.eclipse.core.commands.ExecutionEvent) AbstractRosterMenuHandler.execute(ExecutionEvent arg0)] method is called, and arbitrary code may then be executed.
 +
 +
Plugins can define their own subclasses of AbstractRosterMenuContributionItem, customize the what is returned from createRosterEntryHandler, and provide their own implementation of AbstractRosterMenuHandler.execute.  In this way, they can (e.g.) invoke code to start an editor sharing session with a given target user (represented by the IRosterEntry).
 +
 +
Further, subclasses of '''org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem''' may also customize the look or contents of the menu, as well as determine the resulting command handler for the dynamically constructed roster menu.

Latest revision as of 13:54, 31 October 2007

It's now possible to create a Roster Menu...i.e. a dynamically created menu from the ECF contacts list/roster.

For example, here's my current contacts list:

Contacts.png

Here's a new roster menu, that shows the current roster as a dynamically-constructed menu

Contactsmenu.png

Note that this menu can be added to any existing menu using the platform UI Menu Contributions mechanisms. So this roster menu can be used to interact with roster entry items in any appropriate context (e.g. an editor, a view, workbench, etc).

Note also that only the active participants (in this case, Ted Kubaska) and not the 'away' participants appear in the roster menu. This is a default, which can be customized if desired so that away or dnd participants can also be added.

How is a roster menu added to an existing menu?

The way this works is that a plugin can add markup similar to the following to specify a new roster menu contribution:

   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="popup:org.eclipse.ecf.presence.ui.MultiRosterView?before=additions">
         <dynamic
               class="org.eclipse.ecf.presence.ui.menu.NoopRosterMenuContributionItem"
               id="org.eclipse.ecf.presence.collab.ui.dynamic5">
         </dynamic>
      </menuContribution>
   </extension>

Notice the class org.eclipse.ecf.presence.ui.menu.NoopRosterMenuContributionItem. This is a new class that creates a roster menu contribution that does nothing (performs a noop). The way this works is that the command handler associated with this contribution item does nothing, so that when the Ted Kubaska menu item is chosen, nothing happens.

Customizing the Roster Menu

It's easy to create a subclass of org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem and customize the roster menu behavior. As an example, the following is the implementation of org.eclipse.ecf.presence.ui.menu.NoopRosterMenuContributionItem:

public class NoopRosterMenuContributionItem extends AbstractRosterMenuContributionItem {

	protected AbstractRosterMenuHandler createRosterEntryHandler(IRosterEntry rosterEntry) {
		return new AbstractRosterMenuHandler(rosterEntry) {
			public Object execute(ExecutionEvent arg0) throws ExecutionException {
				System.out.println("execute(" + arg0 + ") on rosterEntry=" + getRosterEntry()); 
				return null;
			}

		};
	}

}

When a roster menu item is selected, the AbstractRosterMenuHandler.execute(ExecutionEvent arg0) method is called, and arbitrary code may then be executed.

Plugins can define their own subclasses of AbstractRosterMenuContributionItem, customize the what is returned from createRosterEntryHandler, and provide their own implementation of AbstractRosterMenuHandler.execute. In this way, they can (e.g.) invoke code to start an editor sharing session with a given target user (represented by the IRosterEntry).

Further, subclasses of org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem may also customize the look or contents of the menu, as well as determine the resulting command handler for the dynamically constructed roster menu.

Back to the top