Syncronizing Menu entries according to settings (Code Folding)


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.

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


Comment actions Permalink

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

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

  public void update(final AnActionEvent event) {
    MathematicaCodeFoldingSettings settings = MathematicaCodeFoldingSettingsImpl.getInstance();


Please sign in to leave a comment.