[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Menu Contribution Conflicts...

Remy Chi Jian Suen wrote:
Hi everyone,

On this week's call, Scott talked briefly about how one would
contribute directly to a view via its ID without having to set a
Require-Bundle on said view's ID. In the context at hand, it would
allow us to add a 'Send File' action to the MultiRosterView's context
menu via writing the code in a provider's ui.

This looks great on paper but actually presents a flaw in the design
once you "scale up" in the number of supported protocols.

The idea here is that you would subclass CompoundContributionItem,
check the workbench's current selection, and pop it up.

In a scenario in which one protocol supports file transfer and the
other doesn't (like the current scenario of XMPP and MSN, yes, MSN
does support file transfers, I just haven't written the implementation
code), the popup menu will appear in either case even though MSN does
not support this. Thus, the standard sanity check of IRosterEntry
would not work, you would instead have to check its
implementation.This currently would still fail since XMPP actually
just uses the convenient implementation of RosterEntry, so if future
implementors uses it too, that will fail. Worse, if all protocols
supported file transfers, you would get an n number of menu items that
stated 'Send File'!

Here's what I do as a sanity check with the Skype ui contribution (in SkypeActionContributionItems)...I'm not saying this is the best/only approach, but it does work.


if (selectedModel != null && selectedModel instanceof IRosterEntry) {
IRosterEntry rosterEntry = (IRosterEntry) selectedModel;
IContainer container = (IContainer) rosterEntry.getRoster()
.getPresenceContainerAdapter().getAdapter(IContainer.class);
IAction[] actions = new IAction[1];
// Here's what limits it to adding menu entries only for Skype
// this is kind of ugly though...admittedly
if (container instanceof SkypeContainer) {
actions[0] = new SkypeCallAction(
....fill out action


The tricky bits here are the 'if (container instanceof SkypeContainer)'. Although this works fine, it would be better to have alternatives.

Scott