Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Dynamically changing state of menus and toolbuttons
Dynamically changing state of menus and toolbuttons [message #329471] Wed, 25 June 2008 14:13
David Fait is currently offline David FaitFriend
Messages: 1
Registered: July 2009
Junior Member
Hi,

I've added a menu item and toolbutton in my plugin. What I want is
that the menu (and the toolbutton) be available only when a certain
file type is open in the workbench window.

Below is the snippet from plugin.xml

<extension
point="org.eclipse.ui.actionSets">
<actionSet
label="My action set"
visible="true"
id="com.plugin.test.my.actionSet">
<menu
label="Plugin Menu"
id="PluginMenu">
<separator
name="PluginMenuGroup">
</separator>
</menu>
<action>
label="Command menu"
tooltip="This is my command menu"
class="com.plugin.test.my.action.ExecuteDelegate"
menubarPath="PluginMenu/PluginMenuGroup"
toolbarPath="PluginMenuGroup"
id="com.plugin.test.my.action.Execute">
<enablement>
<and>
<objectClass name="org.eclipse.core.resources.IFile"/>
<objectState name="extension" value="foobar"/>
</and>
</enablement>
</action>
</actionSet>
</extension>


Upon running the plugin, the behavior is:

- Until no file with extension .foobar is opened in the workbench
window, the added toolbutton and menu item remain disabled as
expected.

- The toolbutton and menu item dynamically change their state
depending upon the selected file in the package explorer UNTIL no file
with extension .foobar is opened in the workbench window.

- The moment a file .foobar is opened in the workbench window, both
the added menu item and toolbutton become active (enabled). Now even
if any other file is opened in the workbench window, or any file is
selected in the package explorer, the toolbutton and menu item always
remain active.


Could someone kindly suggest what am I missing here?

I want the toolbutton and menu item to be active (enabled/highlighted)
only when a file with extension .foobar is open in the workbench
window.

Thanks for your suggestions.

Dave
Previous Topic:Using Common Navigator Framework for EMF objects browsing
Next Topic:Programmatically invoking a cheat sheet
Goto Forum:
  


Current Time: Sat Nov 09 05:26:54 GMT 2024

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

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

Back to the top