Enabling commands for particular file types only [message #486192] |
Wed, 16 September 2009 12:26  |
Eclipse User |
|
|
|
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 #623556 is a reply to message #486192] |
Wed, 16 September 2009 17:01  |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03750 seconds