There are a lot of examples in IntelliJ IDEA Community source code and opensource plugins. For example actions from the Dart plugin that work only for files named pubspec.yaml:
Make sure to make the action invisible for all files except the ones the action is valid for: implement updateAction() in your action class accordingly
For sure there plugins which do it, but how do I find these plugins? Eg, I've never installed the Dart plugin before, I didn't know it had this menu.
Question: why are there 3 actions, then a separator, and then add-to-groups? I only want to display it when right-clicking on a file. Do I only need an action for that, or do I also need it to some group?
You'll probably have only one action. Separator - as you like. Add to group - yes, you need it. One adds to editor popup, the other one - to the context menu in Project View. Skip the latter if you want.
Ah, thanks. I actually read that page, but it wasn't clear to me how I could add context menu items based on that information. After re-reading it, it's still not clear to me, but your example is, so I'm sure I'll work something out. Thanks for the pointer!
There are a lot of examples in IntelliJ IDEA Community source code and opensource plugins.
For example actions from the Dart plugin that work only for files named pubspec.yaml:
Make sure to make the action invisible for all files except the ones the action is valid for: implement updateAction() in your action class accordingly
Hi Alexander, thanks for the reply.
For sure there plugins which do it, but how do I find these plugins? Eg, I've never installed the Dart plugin before, I didn't know it had this menu.
Question: why are there 3 actions, then a separator, and then add-to-groups? I only want to display it when right-clicking on a file. Do I only need an action for that, or do I also need it to some group?
You'll probably have only one action. Separator - as you like. Add to group - yes, you need it. One adds to editor popup, the other one - to the context menu in Project View. Skip the latter if you want.
Ah, now I see. Thanks, this make things much more clear. Is there any documentation on this I missed? I checked these locations, but couldn't find it:
- https://confluence.jetbrains.com/display/IDEADEV/PluginDevelopment
- https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Plugin+Structure
- http://www.jetbrains.org/display/IJOS/Writing+Plug-ins
- https://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA
- https://confluence.jetbrains.com/display/IntelliJIDEA/Custom+Language+Support
Yes, follow 'IntelliJ IDEA Action System' link on the first page that you mentioned.
You even can do without parent group tag, just add add-to-group tag as action tag child.
Ah, thanks. I actually read that page, but it wasn't clear to me how I could add context menu items based on that information. After re-reading it, it's still not clear to me, but your example is, so I'm sure I'll work something out. Thanks for the pointer!