[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: retrieve MenuItem by ID

Philippe Ombredanne ha scritto:
"Luciano Boschi" <boschi@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:d7k6t4$bm$1@xxxxxxxxxxxxxxxxxxx

Hi everyone,
I'm developing an Eclipse plugin.
I need to enable/disable a menu item programmatically.

The question is: how can I access the MenuItem object?
for instance: from its IWorkbenchWindowActionDelegate.

The only things I know are the MenuItem id and menubarPath (as specified
in the plugin.xml file).

Has the menu been contributed by YOUR plugin? or another one?



It's contributed by my plugin.

I've edited plugin.xml via the PDE interface. Here is something of what I have got:
-----------------
<extension
point="org.eclipse.ui.actionSets">
<actionSet
label="Gruppo di azioni"
description="Menu delle funzionalità di &quot;Lexlooter&quot;"
visible="false"
id="it.unifi.ing.lexlooter.actionSet">
<menu
label="&amp;Lexlooter"
id="LexlooterMenu">
<separator name="saveGroup"/>
<separator
name="openGroup">
</separator>
<separator name="toolGroup"/>
<separator name="configGroup"/>
</menu>
<action
label="&amp;Salva..."
icon="icons/etool16/save.gif"
class="it.unifi.ing.lexlooter.actions.SaveResult"
tooltip="Salva tutti i modelli e i testi consolidati in un unico archivio"
style="push"
state="true"
menubarPath="LexlooterMenu/saveGroup"
id="it.unifi.ing.lexlooter.actions.SaveResult"/>
....
-----------------


then I have a SaveResult.java file that begins with something like:

-----------------
package it.unifi.ing.lexlooter.actions;
public class SaveResult implements IWorkbenchWindowActionDelegate
....
-----------------

I know that the methods IWorkbenchWindowActionDelegate.run and .selectionChanged have an IAction reference passed to them, but I would like to access that IAction also from other methods.

Or have I to use another approach?

Thanks