Home » Eclipse Projects » Rich Client Platform (RCP) » Action enablement using System property
Action enablement using System property [message #464730] |
Wed, 14 March 2007 14:23 |
Eclipse User |
|
|
|
Originally posted by: C.O'Mahony.pilz.ie
Hi,
I have an Action declared in my plugin.xml in an actionSet, and I wish
to disable it, based on a certain condition within my application which
I can easily test for.
However from the Eclipse help it would appear that the <enablement>
expressions that i can use within my <action> are limited to conditions
based on what is selected in the application. However this does not suit
how I want to test whether my action can be enabled.
I noticed that I can test for a system property and enable my action
this way, by using System.setProperty("canGenerateReport", "true")
within my code when whatever condition is true and therefore enabling
the action, and by having the below <enablement> element in my <action>
<enablement>
<systemProperty name="canGenerateReport" value="true"/>
</enablement>
However I doubt that using System properties is a good way of enabling
actions. Does anyone know of something similar I can do to test and
enable my Action?
Thanks,
Conor
|
|
|
Re: Action enablement using System property [message #464882 is a reply to message #464730] |
Fri, 16 March 2007 20:46 |
No real name Messages: 38 Registered: July 2009 |
Member |
|
|
Conor O'Mahony wrote:
> Hi,
>
> I have an Action declared in my plugin.xml in an actionSet, and I wish
> to disable it, based on a certain condition within my application which
> I can easily test for.
>
> However from the Eclipse help it would appear that the <enablement>
> expressions that i can use within my <action> are limited to conditions
> based on what is selected in the application. However this does not suit
> how I want to test whether my action can be enabled.
>
> I noticed that I can test for a system property and enable my action
> this way, by using System.setProperty("canGenerateReport", "true")
> within my code when whatever condition is true and therefore enabling
> the action, and by having the below <enablement> element in my <action>
>
> <enablement>
> <systemProperty name="canGenerateReport" value="true"/>
> </enablement>
>
>
> However I doubt that using System properties is a good way of enabling
> actions. Does anyone know of something similar I can do to test and
> enable my Action?
>
> Thanks,
> Conor
I hate to say it, but this really depends on the business side of your
application. We use the <enablement...> nodes to an extreme, including
the <pluginState...>, <objectClass...>, and <systemproperty...> options
(and combinations thereof).
for example, we enable functionality based on a license key. If the key
exists (when the application fires up), we set a system property and
then check for that in the <enablement> nodes of the actions.
One gotcha, however..... Our application consists of a number of
plugins and all contribute actions, menu items, etc. Most menu items
are enabled depending on the type of object selected in our (treeViewer)
view. Using just an <objectClass name=""> enablement does *not*
automatically enable actions defined in another lazily-loaded plugin. I
had to tickle the various plugins so they enable/disable their actions
appropriately. never, ever, call Bundle.start()...... Bad news,
baaaaad news.....
|
|
|
Re: Action enablement using System property [message #465005 is a reply to message #464882] |
Wed, 21 March 2007 16:51 |
Eclipse User |
|
|
|
Originally posted by: C.O'Mahony.pilz.ie
Do you know if there is any way of enabling an action based on the
result of a method call?
RacerNewbie wrote:
> Conor O'Mahony wrote:
>> Hi,
>>
>> I have an Action declared in my plugin.xml in an actionSet, and I wish
>> to disable it, based on a certain condition within my application
>> which I can easily test for.
>>
>> However from the Eclipse help it would appear that the <enablement>
>> expressions that i can use within my <action> are limited to
>> conditions based on what is selected in the application. However this
>> does not suit how I want to test whether my action can be enabled.
>>
>> I noticed that I can test for a system property and enable my action
>> this way, by using System.setProperty("canGenerateReport", "true")
>> within my code when whatever condition is true and therefore enabling
>> the action, and by having the below <enablement> element in my <action>
>>
>> <enablement>
>> <systemProperty name="canGenerateReport" value="true"/>
>> </enablement>
>>
>>
>> However I doubt that using System properties is a good way of enabling
>> actions. Does anyone know of something similar I can do to test and
>> enable my Action?
>>
>> Thanks,
>> Conor
>
> I hate to say it, but this really depends on the business side of your
> application. We use the <enablement...> nodes to an extreme, including
> the <pluginState...>, <objectClass...>, and <systemproperty...> options
> (and combinations thereof).
>
> for example, we enable functionality based on a license key. If the key
> exists (when the application fires up), we set a system property and
> then check for that in the <enablement> nodes of the actions.
>
> One gotcha, however..... Our application consists of a number of
> plugins and all contribute actions, menu items, etc. Most menu items
> are enabled depending on the type of object selected in our (treeViewer)
> view. Using just an <objectClass name=""> enablement does *not*
> automatically enable actions defined in another lazily-loaded plugin. I
> had to tickle the various plugins so they enable/disable their actions
> appropriately. never, ever, call Bundle.start()...... Bad news,
> baaaaad news.....
|
|
| |
Re: Action enablement using System property [message #465327 is a reply to message #465234] |
Wed, 28 March 2007 15:03 |
Eclipse User |
|
|
|
Originally posted by: C.O'Mahony.pilz.ie
Would it be possible to use a PropertyTester somehow within the
<enablement> element of a action declared in an action set? Or something
similar to this?
<action id="org.eclipse.examples.actionEnablement.class"
label="Red Element"
menubarPath="additions"
class="org.eclipse.examples.actionEnablement.ObjectTestAction ">
<enablement>
<and>
<objectClass
name="org.eclipse.examples.actionEnablement.TestElement"/>
<objectState name="name" value="red"/>
</and>
</enablement>
</action>
Paul Webster wrote:
> In the new world, you can use a PropertyTester and call it from the
> enabledWhen clause for a handler.
>
> For actions I don't think that's as easy.
>
> Later,
> PW
|
|
| |
Goto Forum:
Current Time: Thu Sep 19 15:51:20 GMT 2024
Powered by FUDForum. Page generated in 0.05678 seconds
|