Execute update project from git in action
Answered
Hello,
I would like to create an action, which will execute another action: update project (a pull from git), but I would like it to be executed in another window. I wrote such function:
private fun executeProjectUpdate() {
val project = ProjectManager.getInstance().openProjects.first { it.name == "another-open-project" }
val manager = ServiceManager.getService(project, SearchEverywhereManager::class.java)
manager.show("ActionSearchEverywhereContributor", "git pull ", event);
}
In this new popup I can't see any action, but searching status:

Could you give me some advice how such action should be implemented?
Please sign in to leave a comment.
Sorry, I'm not sure I follow what your code/screenshot really is about.
If you want to execute GIT PULL action (git4idea.actions.GitPull) programmatically from within another action, you can query it via ActionManager#getAction with ID "Git.Pull" and then execute it via com.intellij.openapi.actionSystem.ex.ActionUtil#invokeAction()
Thanks for response. How can I execute this action in another Intellij window?
what is "another intellij window"? why would you want to invoke an action not for the current project?
Yes. I have open project A with some configuration and project B with code. When in project B i run my action I would like update project A and run maven in project A directory (what I have done). This is reason why I tried access another project by ProjectManager, by I don't know how to use found project instance.
You'll have to pass DataContext for the project-A project
eventually com.intellij.openapi.wm.impl.WindowWatcher#getFocusedComponent(com.intellij.openapi.project.Project) might work
This whole approach looks rather dangerous and will probably not work reliably.