Enabling/disabling Menu selections.

How do I enable and disable my plugins menu selections? What I am looking to do is to only have the plugin's menu selection enabled if a certain type of file (specifically the .form file) is selected. I've been poking through the OpenAPI docs, but can't seem top find a way to do this.

0
1 comment
Avatar
Permanently deleted user

Ralph Saunders wrote:

How do I enable and disable my plugins menu selections? What I am looking to do is to only have the plugin's menu selection enabled if a certain type of file (specifically the .form file) is selected. I've been poking through the OpenAPI docs, but can't seem top find a way to do this.


You basically want to check when you get an update() call to your action.

So I use something like this in my AnAction subclass.

public void update( AnActionEvent event )
{
super.update( event );
Presentation presentation = event.getPresentation();

presentation.setIcon( getIcon() );

// Want to be disabled when no project open
Project p = (Project)event.getDataContext().getData(DataConstants.PROJECT);
presentation.setEnabled( p != null );
}


- Paul

0

Please sign in to leave a comment.