Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Enable/disable Editor popup menu items
Enable/disable Editor popup menu items [message #327161] Fri, 11 April 2008 20:31
mp is currently offline mpFriend
Messages: 7
Registered: July 2009
Junior Member
I've contributed a number of popup menu actions for a *.java file.
Currently, all my actions are always enabled. When the user selects an
action, I perform a number of tests -- and if it turns out that the action
isn't allowed, I display a generic "That action isn't allowed" error dialog.
Ideally, I'd like to prevent the user from selecting the action in the first
place.

In looking at the eclipse.org docs, I see I can implement IActionFilter, add
the <enablement> tag to my plugin.xml for the <action>:

<action label="My Label"
class="MyAction"
...menubarpath...icon...id...definitionId...>
<enablement>
<objectState name="myTest" value="true"/>
</enablement>
</action>

and then use the testAttribute public boolean testAttribute(Object target,
String name, String value).


I've used <enablement> in the past, but that was when the the
<viewerContribution> had a <visibility><objectClass name="some
class"/></visibility>. Then, the "some class".testAttribute was called.

In my current implementation, I don't have any <objectClass> defined for the
<viewerrContribution>. Not knowing where to put the testAttribute method
then, I stuck it in the MyAction and it seems to be ignored. So, I'm pretty
sure that's not the right place. Where should it go? Do I need to register
some sort of listener or delegate?


I'm sure I'm missing something that will be obvious to everyone but me. Any
pointers would be greatly appreciated. Thank you for your time.
Previous Topic:Modifying resources from outside the workbench
Next Topic:The JAR of this class file belongs to a container "Plugin Depenedencies" which does not al
Goto Forum:
  


Current Time: Thu Dec 26 20:57:26 GMT 2024

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

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

Back to the top