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

0
16 comments

Jon Steelman schrieb:

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.


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/

0

Hello Jon,

  • 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?


FileDocumentManagerListener.beforeDocumentSaving()

  • A hook that would allow you to find all the changed files and also

save all those outside of the proejct's content roots?


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!"


0

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

0

Dmitry - Thanks! I'll give those a try.
Jon

0

Hello Jon,

Dmitry - Thanks! I'll give those a try.


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!"


0

Note that not all disk writes go through this path. For example, ipr/iml/iws saving does not.


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?

Have you considered simply using rsync?


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

0

Hello Jon,

  • 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?


FileDocumentManagerListener.beforeDocumentSaving()


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

0

Hello Jon,

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.)


ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile()

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


0
Avatar
Carolina Arce Terceros

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

0

Hello Carolina,

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...


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!"


0
Avatar
Carolina Arce Terceros

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

0

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:

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


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0

Hello Carolina,

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...


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!"


0
Avatar
Carolina Arce Terceros

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

0

Hello Carolina,

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...


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!"


0
Avatar
Carolina Arce Terceros

Thanks for your answer! I'll try it out.

Carolina

0

Please sign in to leave a comment.