Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » IObjectActionDelegate + ISelction filtering
IObjectActionDelegate + ISelction filtering [message #541171] Fri, 18 June 2010 14:11 Go to next message
Sebastian is currently offline SebastianFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

I'd like to have a context menu entry for a specific class (realized
with IObjectActionDelegate) which is only visible if all selected items
match some criteria. The problem is that it is not sufficient to test
how many items are selected (e.g. with enablesFor) or to test every
single item for itself.
For example the action should be enabled if one of the selected items
fullfill a special requirement. Therefore to test for the amount or an
objectState separatly is not sufficient.
Is there any possibility to get a setEnabled-method for a
IObjectContribution?
Or maybe an ISelction for an Action?
Or is there any other possiblity?

Thanks

Sebastian
Re: IObjectActionDelegate + ISelction filtering [message #541219 is a reply to message #541171] Fri, 18 June 2010 17:54 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

In general the object contribution filters are applied as an "and".
i.e. every object in the selection must match all criteria. There's
nothing you can do about that.

Even the core expression, objectContribution/enablement, is applied to
each element individually.

If you use commands and org.eclipse.ui.menus to contribute to a popup
menu, you have a lot more flexibility with the visibleWhen clause (<with
variables="activeMenuSelection")

PW

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: IObjectActionDelegate + ISelction filtering [message #541478 is a reply to message #541219] Mon, 21 June 2010 10:01 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 18.06.2010 19:54, Paul Webster wrote:
> In general the object contribution filters are applied as an "and". i.e.
> every object in the selection must match all criteria. There's nothing
> you can do about that.

I believe that would still allow the OP to use a property tester to
check the constraints. If some special item needs some special test,
the only thing the OP needs to be able to *recognice*, which object
is special. So, the test would basically look like:

return ifSpecial(obj) ? checkSpecial(obj) : checkNormal(obj);

Greetings from Bremen,

Daniel Krügler
Re: IObjectActionDelegate + ISelction filtering [message #541528 is a reply to message #541478] Mon, 21 June 2010 13:14 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Daniel Krügler wrote:
>
> return ifSpecial(obj) ? checkSpecial(obj) : checkNormal(obj);
>

Yes, but that test will be applied individually to each element in the
selection. If that's what you want, then you're gold.

It's the case where you want "If most of the selection is normal but
there is at least one special case" that won't work, because you can't
tell how your siblings evaluated.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: IObjectActionDelegate + ISelction filtering [message #541542 is a reply to message #541528] Mon, 21 June 2010 13:28 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 21.06.2010 15:14, Paul Webster wrote:
> Daniel Krügler wrote:
>>
>> return ifSpecial(obj) ? checkSpecial(obj) : checkNormal(obj);
>>
>
> Yes, but that test will be applied individually to each element in the
> selection. If that's what you want, then you're gold.
>
> It's the case where you want "If most of the selection is normal but
> there is at least one special case" that won't work, because you can't
> tell how your siblings evaluated.

I agree - I misread what the OP actually wants.

Thx,

- Daniel
Previous Topic:Translations work well in IDE but are missing after export
Next Topic:Re: Exported RCP tutorial crashes when run
Goto Forum:
  


Current Time: Fri Nov 28 22:04:22 GMT 2014

Powered by FUDForum. Page generated in 0.02043 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software