Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Enabling or disabling command handler based on selection
Enabling or disabling command handler based on selection [message #330981] Wed, 20 August 2008 13:19 Go to next message
Eclipse UserFriend
Originally posted by: nick.allen.onlinehome.de

Hi,

I am writing a plug-in for Eclipse that integrates with the Bazaar
version control system. I have written my command handlers and used the
menu extension point to insert a "Bazaar" menu into the main eclipse
window. The problem is that my actions are always enabled and I need to
change that based on which files are selected or whether the editor has
focus or not. For selected files I need to check if they are in a parent
(or ancestor) directory that contains a ".bzr" directory and if the
editor has focus I need to check if the file being edited is in such a
directory structure.

The examples show how to use expressions in the XML file for the command
handlers but my condition is too complex to express in XML syntax. I
would like to do this programmatically or to at least write a new
expression class which I can then use in the XML (e.g.
IsUnderBazaarVersionControlExpression).

I have searched for 3 days solid and found nothing appropriate.
How do I do this? Any feedback greatly appreciated.

Many thanks in advance,

Nicholas Allen
Re: Enabling or disabling command handler based on selection [message #331022 is a reply to message #330981] Thu, 21 August 2008 14:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nick.allen.onlinehome.de

Does no-one know how to do this? I would really appreciate any help - I
am new to Eclipse and am getting frustrated that something so easy
should turn out to require so much work and investigation.

Thanks,

Nick

Nicholas Allen wrote:
> Hi,
>
> I am writing a plug-in for Eclipse that integrates with the Bazaar
> version control system. I have written my command handlers and used the
> menu extension point to insert a "Bazaar" menu into the main eclipse
> window. The problem is that my actions are always enabled and I need to
> change that based on which files are selected or whether the editor has
> focus or not. For selected files I need to check if they are in a parent
> (or ancestor) directory that contains a ".bzr" directory and if the
> editor has focus I need to check if the file being edited is in such a
> directory structure.
>
> The examples show how to use expressions in the XML file for the command
> handlers but my condition is too complex to express in XML syntax. I
> would like to do this programmatically or to at least write a new
> expression class which I can then use in the XML (e.g.
> IsUnderBazaarVersionControlExpression).
>
> I have searched for 3 days solid and found nothing appropriate.
> How do I do this? Any feedback greatly appreciated.
>
> Many thanks in advance,
>
> Nicholas Allen
Re: Enabling or disabling command handler based on selection [message #331027 is a reply to message #331022] Thu, 21 August 2008 15:17 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
I don't know exactly, but have a look at org.eclipse.core.expressions,
that shows you how to provide an expression programatically.

Look at the command stuff in the Wiki as well. I always try to find an
email by Paul Webster if I need to know about this stuff (it has the
best links):

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm

You can create a Command programatically and associated an expression
with it.

HTH,
Francis


Nicholas Allen wrote:
> Does no-one know how to do this? I would really appreciate any help - I
> am new to Eclipse and am getting frustrated that something so easy
> should turn out to require so much work and investigation.
>
> Thanks,
>
> Nick
>
> Nicholas Allen wrote:
>> Hi,
>>
>> I am writing a plug-in for Eclipse that integrates with the Bazaar
>> version control system. I have written my command handlers and used the
>> menu extension point to insert a "Bazaar" menu into the main eclipse
>> window. The problem is that my actions are always enabled and I need to
>> change that based on which files are selected or whether the editor has
>> focus or not. For selected files I need to check if they are in a parent
>> (or ancestor) directory that contains a ".bzr" directory and if the
>> editor has focus I need to check if the file being edited is in such a
>> directory structure.
>>
>> The examples show how to use expressions in the XML file for the command
>> handlers but my condition is too complex to express in XML syntax. I
>> would like to do this programmatically or to at least write a new
>> expression class which I can then use in the XML (e.g.
>> IsUnderBazaarVersionControlExpression).
>>
>> I have searched for 3 days solid and found nothing appropriate.
>> How do I do this? Any feedback greatly appreciated.
>>
>> Many thanks in advance,
>>
>> Nicholas Allen


--
*new* Common Navigator Framework section in:
3.4RC4 Platform Plugin Developer Guide (Programmer's Guide)
http://help.eclipse.org/ganymede/topic/org.eclipse.platform. doc.isv/guide/cnf.htm
http://dev.eclipse.org/blogs/francis
http://wiki.eclipse.org/Common_Navigator_Framework
http://wiki.eclipse.org/Common_Navigator_Framework_Use_Cases


You have brains in your head.
You have feet in your shoes.
- Dr Seuss, Oh the Places You'll Go


Re: Enabling or disabling command handler based on selection [message #331028 is a reply to message #331027] Thu, 21 August 2008 15:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nick.allen.onlinehome.de

Many thanks for your replies! I will look into these - I hope it turns
out to be fairly easy...

Nick

Francis Upton (News) wrote:
> I don't know exactly, but have a look at org.eclipse.core.expressions,
> that shows you how to provide an expression programatically.
>
> Look at the command stuff in the Wiki as well. I always try to find an
> email by Paul Webster if I need to know about this stuff (it has the
> best links):
>
> 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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
>
>
> You can create a Command programatically and associated an expression
> with it.
>
> HTH,
> Francis
>
>
> Nicholas Allen wrote:
>> Does no-one know how to do this? I would really appreciate any help - I
>> am new to Eclipse and am getting frustrated that something so easy
>> should turn out to require so much work and investigation.
>>
>> Thanks,
>>
>> Nick
>>
>> Nicholas Allen wrote:
>>> Hi,
>>>
>>> I am writing a plug-in for Eclipse that integrates with the Bazaar
>>> version control system. I have written my command handlers and used the
>>> menu extension point to insert a "Bazaar" menu into the main eclipse
>>> window. The problem is that my actions are always enabled and I need to
>>> change that based on which files are selected or whether the editor has
>>> focus or not. For selected files I need to check if they are in a parent
>>> (or ancestor) directory that contains a ".bzr" directory and if the
>>> editor has focus I need to check if the file being edited is in such a
>>> directory structure.
>>>
>>> The examples show how to use expressions in the XML file for the command
>>> handlers but my condition is too complex to express in XML syntax. I
>>> would like to do this programmatically or to at least write a new
>>> expression class which I can then use in the XML (e.g.
>>> IsUnderBazaarVersionControlExpression).
>>>
>>> I have searched for 3 days solid and found nothing appropriate.
>>> How do I do this? Any feedback greatly appreciated.
>>>
>>> Many thanks in advance,
>>>
>>> Nicholas Allen
>
>
Re: Enabling or disabling command handler based on selection [message #331055 is a reply to message #331022] Fri, 22 August 2008 09:20 Go to previous message
Achim Loerke is currently offline Achim LoerkeFriend
Messages: 376
Registered: July 2009
Location: Braunschweig, Germany
Senior Member

Not quite sure if this is helpful, but basically you should register a
selection listener with your commands. Depending on the active
selection you may then enable/disable your commands. For finding
files/directories start looking at the Common Navigator pages managed
by Frances.


Achim
--
Achim Lörke

Eclipse-Stammtisch in the Braunschweig, Germany area:
http://www.bredex.de/de/news/events.html


Achim Lörke

Previous Topic:Workaround for overriding buildRule?
Next Topic:Add/Edit Watch expression and code completion
Goto Forum:
  


Current Time: Tue Jul 16 06:18:01 GMT 2024

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

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

Back to the top