Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » dynamic content in context-menu defined in plugin.xml?
dynamic content in context-menu defined in plugin.xml? [message #299364] Wed, 15 February 2006 11:57 Go to next message
Eclipse UserFriend
R3.1.1, WinXP

The newsgroups, the HTML-help in Eclipse, and the javadocs that I have looked at say nothing about
this.

I have a context-menu (an objectContribution) defined in my plug-in; it works fine, items show up,
they act the way they should. Some of them even have submenus defined (see the extract from
plugin.xml below).

Now, I want to take one of those submenu actions -- the "restrict type" -- and *dynamically*
populate its submenu depending upon the value of the current type (e.g., if the current type is
"VDT" I might want to populate with "Plasma", "CRT", and "LCD"; whereas if the current type is
"Mouse", I might want to populate with "USB", "Wireless", and "Standard").

How do I do that? (I know how to do it if the *menu* itself is *not* created by the plugin.xml,
i.e., in the menuAboutToShow(IMenuManager) method.)

thanks,
Paul

<objectContribution
adaptable="false"
id="com.foo.bar.saw2.semanticQueryType"
objectClass="com.foo.bar.saw2.models.semantic.ISemanticQuery ">
<menu
id="com.foo.bar.saw2.semanticQueryTypeMenu"
label="T&amp;ype"
path="type">
<groupMarker name="com.foo.bar.saw2.typeGroup"/>
</menu>
<action
class="com.foo.bar.saw2.editors.popups.SelectTypeAction"
enablesFor="1"
icon="icons/select.PNG"
id="com.foo.bar.saw2.selectTypeAction"
label="&amp;Select..."
menubarPath="com.foo.bar.saw2.semanticQueryTypeMenu/typeGroup ">
<enablement>
<objectState
name="selectType"
value="allowed"/>
</enablement>
</action>
<action
class="com.foo.bar.saw2.editors.popups.RestrictTypeAction"
enablesFor="1"
icon="icons/restrict.PNG"
id="com.foo.bar.saw2.restrictTypeAction"
label="&amp;Restrict..."
menubarPath="com.foo.bar.saw2.semanticQueryTypeMenu/typeGroup ">
<enablement>
<objectState
name="subtype"
value="!empty"/>
</enablement>
</action>
<action
class="com.foo.bar.saw2.editors.popups.RelaxTypeAction"
enablesFor="+"
icon="icons/relax.PNG"
id="com.foo.bar.saw2.relaxTypeAction"
label="Rela&amp;x"
menubarPath="com.foo.bar.saw2.semanticQueryTypeMenu/typeGroup ">
<enablement>
<objectState
name="relaxType"
value="allowed"/>
</enablement>
</action>
<action
class="com.foo.bar.saw2.editors.popups.ClearTypeAction"
enablesFor="+"
id="com.foo.bar.saw2.clearTypeAction"
label="&amp;Clear"
menubarPath="com.foo.bar.saw2.semanticQueryTypeMenu/typeGroup ">
<enablement>
<objectState
name="type"
value="allowed"/>
</enablement>
</action>
</objectContribution>
Re: dynamic content in context-menu defined in plugin.xml? [message #299772 is a reply to message #299364] Thu, 23 February 2006 15:40 Go to previous message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

Paul Keyser wrote:
> Now, I want to take one of those submenu actions -- the "restrict type" --
> and *dynamically* populate its submenu depending upon the value of the
> current type (e.g., if the current type is "VDT" I might want to populate
> with "Plasma", "CRT", and "LCD"; whereas if the current type is "Mouse", I
> might want to populate with "USB", "Wireless", and "Standard").

Set the class style="pulldown". Make your action implement
IObjectActionDelegate and IMenuCreator. On the first call to
selectionChanged, call setMenuCreator on the IAction you are passed. See
org.eclipse.debug.ui.actions.ContextualLaunchAction (in
"org.eclipse.debug.ui") for an example.



cheers,
d.
Previous Topic:how to contribute editor action activated by mouse double-clicked?
Next Topic:How do I remove the dynamically created MenuManager ?
Goto Forum:
  


Current Time: Tue Jul 22 13:07:39 EDT 2025

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

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

Back to the top