dynamic content in context-menu defined in plugin.xml? [message #299364] |
Wed, 15 February 2006 11:57  |
Eclipse User |
|
|
|
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&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="&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="&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&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="&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  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03368 seconds