Update Project

Hello,

I've been browsing the forum for a couple of hours and I didn't really found an answer to my question. I want to perform an "Update Project" in code. My question is simple: "Is it possible to update the current project using the IntelliJ openAPI?". additional question, How to do it?
I've already been looking at the UpdateEnvironment, AbstractVcs and UpdatedFiles, but I can't figure it out how to do so.

I tried the environment.fillGroups(updatedFiles) to get an idea of changes. But all the values are 0 wich is strange, because there are differences between the local version and the one on the svn server.

Thanks in advance,

Joey

5 comments
Comment actions Permalink

Hello Joey,

See the CommonUpdateProjectAction class for the implementation of the update
project operation. Currently it's quite involved and not wrapped in any API
for use by plugin developers. If showing UI is OK for you, the best option
is to call the actionPerformed() method of the action class programmatically.

I've been browsing the forum for a couple of hours and I didn't really
found an answer to my question. I want to perform an "Update Project"
in code. My question is simple: "Is it possible to update the current
project using the IntelliJ openAPI?". additional question, How to do
it?

I've already been looking at the UpdateEnvironment, AbstractVcs and
UpdatedFiles, but I can't figure it out how to do so.

I tried the environment.fillGroups(updatedFiles) to get an idea of
changes. But all the values are 0 wich is strange, because there are
differences between the local version and the one on the svn server.


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

And how do I invoke the actionPerformed? I've tried:

final AnAction action = ActionManager.getInstance().getAction("Vcs.UpdateProject");
final AnActionEvent evt = new AnActionEvent(null, DataManager.getInstance().getDataContext(), ActionPlaces.UNKNOWN, action.getTemplatePresentation(), ActionManager.getInstance(), 5);
action.actionPerformed(evt);



But I keep getting a nullpointer exception.
Is it also possible to generate the VcsContext from a certain project?
0
Comment actions Permalink

Hello Joey,

A null pointer exception where?

To get the data context for a specific project, you can use DataManager.getDataContext(WindowManager.getFrame(project)).

And how do I invoke the actionPerformed? I've tried:

final AnAction action =
ActionManager.getInstance().getAction("Vcs.UpdateProject");

final AnActionEvent evt = new AnActionEvent(null,
DataManager.getInstance().getDataContext(), ActionPlaces.UNKNOWN,
action.getTemplatePresentation(), ActionManager.getInstance(), 5);

action.actionPerformed(evt);

But I keep getting a nullpointer exception.
Is it also possible to generate the VcsContext from a certain project?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks a lot, now it works :)

0
Comment actions Permalink

Hello,

could someone give a more extended answer? According javadocs of AbstractVcs one should extend AbstractVcs#createUpdateEnvrironment() to handle 'update workspace actions'. Overriding this making 'Update project' action active.


As far as I undestand, UpdateEnvironment#updateDirectories assumed to be called to perform actual update, but it seems nothing happens when the button clicked. 

Could someone please describe a set of minimal conditions for updating project?

------------

Sincerely,

Danila

0

Please sign in to leave a comment.