Adding actions to before commit toolbar/window
已回答
Is it possible to add another entry to the before commit toolbar/window and execute a plugin action? See image below
请先登录再写评论。
See https://github.com/JetBrains/intellij-community/blob/master/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/TodoCheckinHandler.java#L162
You can use "com.intellij.openapi.vcs.checkin.CheckinHandlerFactory".
See "Update copyright" as an example. https://github.com/JetBrains/intellij-community/blob/master/plugins/copyright/src/com/maddyhome/idea/copyright/actions/UpdateCopyrightCheckinHandlerFactory.java
Thanks I will have a look at it!
I have managed to add an entry to the before commit panel but I can't make my Action run in the beforeCheckin() method. What am I missing?
The code above declares new AnAction, but never calls it.
Why do you need AnAction there? Is it possible to extract "GetSourceCode" logic into a static utility method or method in some Service?
Thanks!
How can I execute/call AnAction in the example above?
Currently I would like to keep it that way.
This depends on "GetSourceCode" implementation (what it does with AnActionEvent).
You can use "ActionUtil#invokeAction" using "CheckinProjectPanel" as target component and ActionPlaces#UNKNOWN, but it might not have a meaningful DataContext.
I use the AnActionEvent to get the Project and Editor objects.
Is it possible to cancel the commit operation after clicking the commit button in the CheckinProjectPanel? My idea is to display a message to the user that the commit was canceled if any dependencies were found.
Yes, see ReturnResult.CANCEL.
Thanks!
I would like to ask the user wheter he would like to commit, cancel and review the dependencies. Something like this:
Is this possible?
Yes. For example, like following:
Thank you very much!
Using the two methods above I get the following errors:
String literal 'checkin.commit' doesn't appear to be valid property key
Same goes for "checkin.cancel"
These were added in 20.3 version. You can use "Commit"/"Cancel" string instead.
Thanks, thought so!
Is it possible to achieve something like the "Review" functionality as seen in the second image a few posts above?