|How to filter context menu action according to Build Automatically setting [message #337024]
||Tue, 21 July 2009 21:14
| Josh Wolfe
Registered: July 2009
I need a context menu item to be visible only when Build Automatically is |
turned off. So far, the objectContribution's objectClass is restricted to
IProject and I have a filter for my own projectNature. However, I'm stuck
when it comes to filtering for Build Automatically.
I've done about 3 hours of research and below is an outline of my progress
and failed attempts.
This is the information that I want to respond to. The problem is that I
don't know where to put the code that contains the above line. I need my
code to be consulted on whether the menu item is visible or not. How can I
get Eclipse to call my code for that?
This article describes how to use an IActionFilter to determine the
visibility of a menu item.
I don't think this will work because the selected items in my situation
are of type IResource, not my own class as in the article. I have no
control over what the IResource's return in getAdapter() so I can't get my
own IActionFilter code to execute using this strategy.
Workspace Property Change Events
I've seen that internally Eclipse is using an event model to handle the
Build Automatically setting changes. I'd love to subscribe to such an
event, but I can't see where to add a listener. If I were notified every
time Build Automatically was switched on or off, I could turn the menu
item on and off manually.
plugin.xml: enablement/visibility -> objectState, systemProperty,
objectState suffers from the IActionFilter problem. systemProperty would
work I guess if I had a reliable way to turning my own system variable on
and off in synch with Eclipse's Build Automatically property.
systemProperty suffers from the Property Change Event problem. pluginState
as well as the other choices don't seem to be any better than the above
Powered by FUDForum
. Page generated in 0.02781 seconds