Syncronizing Menu entries according to settings (Code Folding)

Hi,

I have made some settings in my code folding adjustable by implementing CodeFoldingOptionsProvider. Additionally, I have a dedicated menu entry that contains two actions that make only sense, when a specific folding setting is turned on.

http://i.stack.imgur.com/24Ug8.png

How can I disable menu entries, when a checkbox in the code folding settings is unselected?

Cheers
Patrick

2 comments
Comment actions Permalink

By calling getPresentation().setEnabled(false) from the update() method of your AnAction implementation when the corresponding option is set to false.


0
Comment actions Permalink

Works like a charm, thanks Dmitry.

Note for future readers: I didn't use AnAction for the menu buttons. Instead I extended BaseCodeInsightAction and CodeInsightAction like it was done in other parts of IDEA. The solution is still the same, just override the update method of BaseCodeInsideAction like e.g. this

  @Override
  public void update(final AnActionEvent event) {
    super.update(event);
    MathematicaCodeFoldingSettings settings = MathematicaCodeFoldingSettingsImpl.getInstance();
    event.getPresentation().setEnabled(settings.isCollapseNamedCharacters());
  }

0

Please sign in to leave a comment.