|
Re: Enable/Disable plugin.xml generated menus [message #336640 is a reply to message #336638] |
Thu, 25 June 2009 18:27 |
Eclipse User |
|
|
|
Originally posted by: christopher.oezbek.fu-berlin.de
Hi Javier,
> What I need to do now is to enable/disable some menuitems according to
> one simple variable: the selected project is versioned in bazaar [
> http://bazaar-vcs.org/ ] or not.
>
> I've tried like 20 ways of doing this...but I can't find a way to
> actually access the menuitem from inside the plugin's code.
How about doing it the other way around: In the associated action of the
menuitem you set the action to enabled/disabled.
For instance we have a action directly in the popup menu for IResources
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id="de.fu_berlin.inf.dpp.ui.popupmenu"
objectClass="org.eclipse.core.resources.IResource">
....
<action
class="de.fu_berlin.inf.dpp.ui.actions.NewSessionAction"
icon="icons/transmit.png"
id="Saros.action1"
label="Share project...">
</action>
In the NewSessionAction, we then enable/disable based on the selection:
public class NewSessionAction implements IObjectActionDelegate {
....
public void selectionChanged(IAction action, ISelection selection) {
// Set to enabled if not already in a session
action.setEnabled(getProject(selection) == null);
}
....
Hope this helps,
Christopher
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04136 seconds