Home » Eclipse Projects » Eclipse Platform » Help getting popup menu item to appear based on a System Property
Help getting popup menu item to appear based on a System Property [message #334031] |
Fri, 16 January 2009 05:06 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Nadeem Aboobaker![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=nadeem.aboobaker%40oracle.com) Messages: 20 Registered: July 2009 |
Junior Member |
|
|
Hello all,
I have a menu item on the right-click Popup Menu for a Project in the
Project Explorer. I want this menu item to only appear if a certain
System Property is set; I don't care what value it is set to, only that it
is set. Does anybody have any suggestions?
I've been searching the newsgroups, searching Google, experimenting with
my plugin.xml, and looking at the Eclipse source code trying to get it to
work.
I initially thought I'd use <visibility> and <systemProperty ...> on my
<objectContribution> to org.eclipse.ui.popupMenus. It doesn't seem like I
can specify in the plugin.xml that the value of the System Property is
anything or, in the negative case, that the value is not set or null. In
reading the source code of
org.eclipse.ui.internal.ActionExpression.SystemPropertyExpre ssion, I see
that isEnabledFor() always returns false when the System Property is not
set. So, I can set the visibility like so:
<visibility>
<not>
<systemProperty name="some.property" value=""/>
</not>
</and>
However, if the System Property is set to something, this doesn't work at
all.
My next thought was to use <filter> on my <objectContribution> and write
a custom org.eclipse.ui.IActionFilter. However, this doesn't seem like it
will work, because the menu item acts on a Project which already has an
IActionFilter.
The last thought was that I could set write code in my plugin activator
that would set the System Property to "" if it wasn't already set before.
Of course, this won't work, because the plugin with my action won't be
activated yet. This wouldn't work anyway, since in my case, the System
Property being set to a valid value is required for the plugin activator
to work correctly. So, I can't even make my plugin an EarlyStartup plugin
to set the System Property to "".
Thanks in advance!
Nadeem Aboobaker
|
|
|
Re: Help getting popup menu item to appear based on a System Property [message #334047 is a reply to message #334031] |
Fri, 16 January 2009 14:59 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Nadeem Aboobaker![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=nadeem.aboobaker%40oracle.com) Messages: 20 Registered: July 2009 |
Junior Member |
|
|
I forgot to mention that I'm using Eclipse 3.3.2.
Also, I tried EarlyStartup as mentioned in my "last thought" after
re-organizing my code so the plugin activation does not depend on the
system property. I can now get the exact behavior I want, but it seems a
little hacky to use EarlyStartup for this (and plus, I'm not sure what
side effects are caused by EarlyStartup for my plugin).
So, I'm still searching for the "right" solution, if it exists. :)
Thanks!
Nadeem
Nadeem Aboobaker wrote:
> Hello all,
> I have a menu item on the right-click Popup Menu for a Project in the
> Project Explorer. I want this menu item to only appear if a certain
> System Property is set; I don't care what value it is set to, only that it
> is set. Does anybody have any suggestions?
> I've been searching the newsgroups, searching Google, experimenting with
> my plugin.xml, and looking at the Eclipse source code trying to get it to
> work.
> I initially thought I'd use <visibility> and <systemProperty ...> on my
> <objectContribution> to org.eclipse.ui.popupMenus. It doesn't seem like I
> can specify in the plugin.xml that the value of the System Property is
> anything or, in the negative case, that the value is not set or null. In
> reading the source code of
> org.eclipse.ui.internal.ActionExpression.SystemPropertyExpre ssion, I see
> that isEnabledFor() always returns false when the System Property is not
> set. So, I can set the visibility like so:
> <visibility>
> <not>
> <systemProperty name="some.property" value=""/>
> </not>
> </and>
> However, if the System Property is set to something, this doesn't work at
> all.
> My next thought was to use <filter> on my <objectContribution> and write
> a custom org.eclipse.ui.IActionFilter. However, this doesn't seem like it
> will work, because the menu item acts on a Project which already has an
> IActionFilter.
> The last thought was that I could set write code in my plugin activator
> that would set the System Property to "" if it wasn't already set before.
> Of course, this won't work, because the plugin with my action won't be
> activated yet. This wouldn't work anyway, since in my case, the System
> Property being set to a valid value is required for the plugin activator
> to work correctly. So, I can't even make my plugin an EarlyStartup plugin
> to set the System Property to "".
> Thanks in advance!
> Nadeem Aboobaker
|
|
|
Re: Help getting popup menu item to appear based on a System Property [message #334049 is a reply to message #334031] |
Fri, 16 January 2009 15:37 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Nadeem Aboobaker![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=nadeem.aboobaker%40oracle.com) Messages: 20 Registered: July 2009 |
Junior Member |
|
|
I forgot to mention that I'm using Eclipse 3.3.2.
Also, I tried the EarlyStartup option mentioned in the "last thought" of
the original post. After, re-organizing my code so that the plugin
initialization does not require the system property, the visibility of the
popup menu item works as I want. However, it seems a little "hacky" to
use EarlyStartup (not to mention, I'm unsure of the side effects of
EarlyStartup on my plugin).
So, does anybody know the right solution, if it exists?
Thanks,
Nadeem Aboobaker
Nadeem Aboobaker wrote:
> Hello all,
> I have a menu item on the right-click Popup Menu for a Project in the
> Project Explorer. I want this menu item to only appear if a certain
> System Property is set; I don't care what value it is set to, only that it
> is set. Does anybody have any suggestions?
> I've been searching the newsgroups, searching Google, experimenting with
> my plugin.xml, and looking at the Eclipse source code trying to get it to
> work.
> I initially thought I'd use <visibility> and <systemProperty ...> on my
> <objectContribution> to org.eclipse.ui.popupMenus. It doesn't seem like I
> can specify in the plugin.xml that the value of the System Property is
> anything or, in the negative case, that the value is not set or null. In
> reading the source code of
> org.eclipse.ui.internal.ActionExpression.SystemPropertyExpre ssion, I see
> that isEnabledFor() always returns false when the System Property is not
> set. So, I can set the visibility like so:
> <visibility>
> <not>
> <systemProperty name="some.property" value=""/>
> </not>
> </and>
> However, if the System Property is set to something, this doesn't work at
> all.
> My next thought was to use <filter> on my <objectContribution> and write
> a custom org.eclipse.ui.IActionFilter. However, this doesn't seem like it
> will work, because the menu item acts on a Project which already has an
> IActionFilter.
> The last thought was that I could set write code in my plugin activator
> that would set the System Property to "" if it wasn't already set before.
> Of course, this won't work, because the plugin with my action won't be
> activated yet. This wouldn't work anyway, since in my case, the System
> Property being set to a valid value is required for the plugin activator
> to work correctly. So, I can't even make my plugin an EarlyStartup plugin
> to set the System Property to "".
> Thanks in advance!
> Nadeem Aboobaker
|
|
|
Re: Help getting popup menu item to appear based on a System Property [message #334058 is a reply to message #334031] |
Fri, 16 January 2009 19:59 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: coolsnoopy.gmx.net
Nadeem Aboobaker wrote:
> Hello all,
>
> I have a menu item on the right-click Popup Menu for a Project in the
> Project Explorer. I want this menu item to only appear if a certain
> System Property is set; I don't care what value it is set to, only that
> it is set. Does anybody have any suggestions?
>
Talking about "System Property", so:
what about simply using java.lang.System.getProperty("myproperty") or do
I miss something here?
Regards, Norbert
|
|
| |
Goto Forum:
Current Time: Sat Aug 17 01:30:19 GMT 2024
Powered by FUDForum. Page generated in 0.07593 seconds
|