Can you tie into the file save logic?
Does the Open API support the following:
A hook so that whenever a file saves (automatically or explicitly) to its content root that you can also save the file out to another point outside of the project's content roots?
A hook that would allow you to find all the changed files and also save all those outside of the proejct's content roots?
I'm interested in creating a plugin that might do either of these. The motivation is that IDEA is so slow over the samba mount but by corporate decree the projects have to be built and run over that samba mount, so a system that runs in parallel on a local drive and pushes the changes out to samba is one performance workaround worth exploring.
Thanks,
Jon
Please sign in to leave a comment.
Jon Steelman schrieb:
I strongly suggest you look into using a version control system (e.g.
Subversion). Several developers working on one source tree via Samba
isn't exactly the recommendable method of collaboration in a developer
team ... :)
cu,
Raffi
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is nothing like Shakespeare!
herzog@raffael.ch · PGP Key 5D1FF5F4 · http://www.raffael.ch/
Hello Jon,
FileDocumentManagerListener.beforeDocumentSaving()
Depending on what you mean by "changed", FileDocumentManager.getUnsavedDocuments()
may be what you need.
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Hi Raffi,
:)
It actually is in Subversion. The problem is that the ant builds & runtimes have all been tied to UNIX (write once, run one place), but everyone develops on Windows and mounts the unix directories. They are loathe to de-UNIXifiy the builds & runs. IDE performance is fine on the Windows systems if the projects are local but it is excruciatingly slow over samba, so I'm looking for creative performance workarounds.
Jon
Dmitry - Thanks! I'll give those a try.
Jon
Hello Jon,
Note that not all disk writes go through this path. For example, ipr/iml/iws
saving does not.
Have you considered simply using rsync?
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
That's for a problem for my purposes.
BTW, are the Path Variables accessible within the context of FileDocumentManagerListener.beforeDocumentSaving()? Will IDEA ask you to supply the value variable value if you haven't yet like it does on opening the project?
If it were just me, that might be the way to go. Trying to build a solution to roll out simply with IDEA.
Thanks,
Jon
Hi Dmitry,
Once you have a Document & also the VirtualFile, is there a way to find out the associated Content root? (I realize an Open file won't have such if it is outside of the Content roots.)
Thanks,
Jon
Hello Jon,
ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile()
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Hello Dmity,
Where would you call FileDocumentManagerListener.beforeDocumentSaving() or FileDocumentManager.getUnsavedDocuments()?
Is there a special interface I need to implement or register?
I want to do a plugin that asks if you want to save modified files before closing idea... But can't seem to find where to hook up...
Thanks for any help you can provide me!
Carolina
Hello Carolina,
Why do you need such a plugin? The modified files are saved automatically.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Because I want the user to be able to say no to my question, that is to cancel the saving.
This makes sense if you disable Idea autosave... Eclipse does something similar, I hate Eclipse but I have to recognize that would be the right behaviour...
Carolina
Don't you think it's a strange idea to design a system in a way that it
favors throwing away the work you've done?
Carolina Arce Terceros wrote:
--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com
Hello Carolina,
Actually IntelliJ IDEA saves files automatically in very many situations
(compiles/Ant builds, VCS operations, refactorings etc.), so giving an option
not to save only on exit will hardly be an adequate solution.
Also, the local history keeps track of old versions of files, so even if
you make some unwanted changes which are then saved, you can restore the
previous version from the local history.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Hello Dmitry,
Actually we are not using the Java part a lot... we are mainly using xml editing so refactors, etc, are not a concern for me.
I never disable automatic saving.. but I've got a coworker that does, and he complains that Idea saves his files without asking (like any other editor would) even when he has disabled automatic saving. I believe he is right there...
I posted a question to support and they said there is an opened issue about it, but that it is not likely to be fixed... http://jetbrains.net/jira/browse/IDEABKL-59
So I thought that I could do a plugin to make it behave that way, because I thought it was a reasonable thing to ask...
It seemed to me that those to methods I've asked for would serve my purpose... but I don't know where to define them...
Carolina
Hello Carolina,
Well, you can try to write such a plugin, but I don't think it would provide
a satisfactory user experience.
You need to define an ApplicationComponent in your plugin, and call FileDocumentManager.getInstance().addFileDocumentSynchronizationVetoer()
with your implementation of FileDocumentSynchronizationVetoListener. Your
implementation should throw VetoDocumentSavingException from the beforeDocumentSaving()
method implementation if you decide to block document saving.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Thanks for your answer! I'll try it out.
Carolina