How to display plugin action (ie. icon related to action) only for certain development platform (eg. Android Studio)?
Answered
Hello,
I am developing a plugin for Android projects. I want display the action only if project is opened via Android Studio or the project is for Android development. What is the approach I should take?
Please sign in to leave a comment.
You can check whether `AndroidFacet` is present in `update` method of your action and invoke `e.getPresentation().setVisible(false)` if it isn't. If the action works with specific files (or elements inside a file), get a `PsiElement` from `DataContext` using `CommonDataKeys#PSI_ELEMENT` and invoke `AndroidFacet.getInstance(psiElement)`. If the action is global, i.e. it isn't always invoked in context of a file or a module, you can check whether `AndroidFacet` is present in any module of the project by calling `ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID)`.
Hey Nikolay Chashnikov,
Thanks for the answer :)