Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Platform - User Assistance (UA) » Enabling commands for particular file types only
Enabling commands for particular file types only [message #486192] Wed, 16 September 2009 12:26 Go to next message
Patrick Konemann is currently offline Patrick Konemann
Messages: 116
Registered: July 2009
Senior Member
Dear newsgroup,

I am not really sure whether this is the right newsgroup to ask, please tell me then whether there is a more appropriate one.

When defining actions in Eclipse, you can enable them only for particular file types in the extension definition (e.g. nameFilter="*.txt" in the objectContribution).
Following the command framework [1], restrictions can be modeled in the activeWhen clause of the handler, however, I cannot figure out how to restrict the handler to particular file types only.

I could not find any documentation for doing that.
Here is my extension so far:

<extension
point="org.eclipse.ui.handlers">
<handler
class="mypackage.MyHandler"
commandId="myCommand">
<activeWhen>
<with
variable="selection">
<iterate
operator="and">
<instanceof
value="org.eclipse.core.resources.IFile">
</instanceof>
[I guess the file type restriction has to go here]
</iterate>
</with>
</activeWhen>
</handler>
</extension>


Any help appreciated.

Best regards
Patrick


[1] http://wiki.eclipse.org/Platform_Command_Framework
Re: Enabling commands for particular file types only [message #486243 is a reply to message #486192] Wed, 16 September 2009 17:01 Go to previous messageGo to next message
Chris Goldthorpe is currently offline Chris Goldthorpe
Messages: 815
Registered: July 2009
Senior Member
Cross posting to eclipse.platform where you are more likely to find
someone who is an expert on commands.

Patrick Könemann wrote:
> Dear newsgroup,
>
> I am not really sure whether this is the right newsgroup to ask, please
> tell me then whether there is a more appropriate one.
>
> When defining actions in Eclipse, you can enable them only for
> particular file types in the extension definition (e.g.
> nameFilter="*.txt" in the objectContribution).
> Following the command framework [1], restrictions can be modeled in the
> activeWhen clause of the handler, however, I cannot figure out how to
> restrict the handler to particular file types only.
>
> I could not find any documentation for doing that.
> Here is my extension so far:
>
> <extension
> point="org.eclipse.ui.handlers">
> <handler
> class="mypackage.MyHandler"
> commandId="myCommand">
> <activeWhen>
> <with
> variable="selection">
> <iterate
> operator="and">
> <instanceof
> value="org.eclipse.core.resources.IFile">
> </instanceof>
> [I guess the file type restriction has to go here]
> </iterate>
> </with>
> </activeWhen>
> </handler>
> </extension>
>
>
> Any help appreciated.
>
> Best regards
> Patrick
>
>
> [1] http://wiki.eclipse.org/Platform_Command_Framework
Re: Enabling commands for particular file types only [message #486327 is a reply to message #486243] Thu, 17 September 2009 05:47 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
Chris Goldthorpe wrote:
>> the activeWhen clause of the handler, however, I cannot figure out how
>> to restrict the handler to particular file types only.

Use the contentTypeId property tester
(http://wiki.eclipse.org/Command_Core_Expressions)

- Prakash

Platform UI Team, IBM
http://blog.eclipse-tips.com
Re: Enabling commands for particular file types only [message #486460 is a reply to message #486327] Thu, 17 September 2009 14:11 Go to previous message
Patrick Konemann is currently offline Patrick Konemann
Messages: 116
Registered: July 2009
Senior Member
Great!
Thanks for the link, it works!

And thank you Chris for forwarding the message.

Cheers
Patrick


On 17-09-2009 10:47, Prakash G.R. wrote:
> Chris Goldthorpe wrote:
>>> the activeWhen clause of the handler, however, I cannot figure out
>>> how to restrict the handler to particular file types only.
>
> Use the contentTypeId property tester
> (http://wiki.eclipse.org/Command_Core_Expressions)
>
> - Prakash
>
> Platform UI Team, IBM
> http://blog.eclipse-tips.com
Re: Enabling commands for particular file types only [message #623556 is a reply to message #486192] Wed, 16 September 2009 17:01 Go to previous message
Chris Goldthorpe is currently offline Chris Goldthorpe
Messages: 815
Registered: July 2009
Senior Member
Cross posting to eclipse.platform where you are more likely to find
someone who is an expert on commands.

Patrick Könemann wrote:
> Dear newsgroup,
>
> I am not really sure whether this is the right newsgroup to ask, please
> tell me then whether there is a more appropriate one.
>
> When defining actions in Eclipse, you can enable them only for
> particular file types in the extension definition (e.g.
> nameFilter="*.txt" in the objectContribution).
> Following the command framework [1], restrictions can be modeled in the
> activeWhen clause of the handler, however, I cannot figure out how to
> restrict the handler to particular file types only.
>
> I could not find any documentation for doing that.
> Here is my extension so far:
>
> <extension
> point="org.eclipse.ui.handlers">
> <handler
> class="mypackage.MyHandler"
> commandId="myCommand">
> <activeWhen>
> <with
> variable="selection">
> <iterate
> operator="and">
> <instanceof
> value="org.eclipse.core.resources.IFile">
> </instanceof>
> [I guess the file type restriction has to go here]
> </iterate>
> </with>
> </activeWhen>
> </handler>
> </extension>
>
>
> Any help appreciated.
>
> Best regards
> Patrick
>
>
> [1] http://wiki.eclipse.org/Platform_Command_Framework
Re: Enabling commands for particular file types only [message #623557 is a reply to message #486243] Thu, 17 September 2009 05:47 Go to previous message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
Chris Goldthorpe wrote:
>> the activeWhen clause of the handler, however, I cannot figure out how
>> to restrict the handler to particular file types only.

Use the contentTypeId property tester
(http://wiki.eclipse.org/Command_Core_Expressions)

- Prakash

Platform UI Team, IBM
http://blog.eclipse-tips.com
Re: Enabling commands for particular file types only [message #623558 is a reply to message #486327] Thu, 17 September 2009 14:11 Go to previous message
Patrick Konemann is currently offline Patrick Konemann
Messages: 116
Registered: July 2009
Senior Member
Great!
Thanks for the link, it works!

And thank you Chris for forwarding the message.

Cheers
Patrick


On 17-09-2009 10:47, Prakash G.R. wrote:
> Chris Goldthorpe wrote:
>>> the activeWhen clause of the handler, however, I cannot figure out
>>> how to restrict the handler to particular file types only.
>
> Use the contentTypeId property tester
> (http://wiki.eclipse.org/Command_Core_Expressions)
>
> - Prakash
>
> Platform UI Team, IBM
> http://blog.eclipse-tips.com
Previous Topic:Enabling commands for particular file types only
Next Topic:Remote Help and spaces in the path
Goto Forum:
  


Current Time: Thu Aug 28 05:11:47 EDT 2014

Powered by FUDForum. Page generated in 0.11185 seconds