16 Replies Last post: Oct 26, 2007 6:48 PM by Carolina Arce Terceros  
Jon Steelman Apprentice 963 posts since
Aug 19, 2002
Currently Being Moderated

Aug 20, 2007 5:53 PM

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

Guest
Currently Being Moderated
Aug 20, 2007 6:01 PM in response to: Jon Steelman
Re: Can you tie into the file save logic?

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/

 

Guest
Currently Being Moderated
Aug 20, 2007 6:04 PM in response to: Jon Steelman
Re: Can you tie into the file save logic?

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

 

 

 

Guest
Currently Being Moderated
Aug 20, 2007 6:29 PM in response to: Jon Steelman
Re: Can you tie into the file save logic?

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

 

 

 

Guest
Currently Being Moderated
Aug 22, 2007 7:14 PM in response to: Jon Steelman
Re: Can you tie into the file save logic?

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

 

 

 

Carolina Arce Terceros Newbie 8 posts since
Nov 3, 2002
Currently Being Moderated
Oct 24, 2007 1:21 AM in response to: Dmitry Jemerov
Re: Can you tie into the file save logic?

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

Guest
Currently Being Moderated
Oct 24, 2007 1:30 AM in response to: Carolina Arce Terceros
Re: Can you tie into the file save logic?

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

 

 

 

Carolina Arce Terceros Newbie 8 posts since
Nov 3, 2002
Currently Being Moderated
Oct 24, 2007 1:52 AM in response to: Dmitry Jemerov
Re: Can you tie into the file save logic?

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 Expert 1,655 posts since
Oct 9, 2002
Currently Being Moderated
Oct 24, 2007 12:28 PM in response to: Carolina Arce Terceros
Re: Can you tie into the file save logic?

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

 

Guest
Currently Being Moderated
Oct 24, 2007 1:55 PM in response to: Carolina Arce Terceros
Re: Can you tie into the file save logic?

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

 

 

 

Carolina Arce Terceros Newbie 8 posts since
Nov 3, 2002
Currently Being Moderated
Oct 24, 2007 10:55 PM in response to: Dmitry Jemerov
Re: Can you tie into the file save logic?

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

Guest
Currently Being Moderated
Oct 25, 2007 12:53 PM in response to: Carolina Arce Terceros
Re: Can you tie into the file save logic?

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

 

 

 

Carolina Arce Terceros Newbie 8 posts since
Nov 3, 2002
Currently Being Moderated
Oct 26, 2007 6:48 PM in response to: Dmitry Jemerov
Re: Can you tie into the file save logic?

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

 

Carolina

More Like This

  • Retrieving data ...