Determine user starting to edit file

I am developing a plugin where I need to know when a user has started to edit a read-only file in the editor. Is it possible to determine this?

2 comments
Comment actions Permalink

This was recently discussed in another thread: https://devnet.jetbrains.com/thread/466474


0
Comment actions Permalink

Hello Dmitry,

Thanks for pointing to the thread. I am working on a plugin where when a read-only file is edited for first time, I need to checkout the file at source depo.
I could find out below approaches:

1. Implementing writingaccessprovider. As discussed in the thread and with my testing, each edit on a file looks for access. But I don't intend to resrict or grant access. Eventually for me a user will have write access to all files. Files are just read-only by default so that when a user edit files, then that can be tracked.

2. Adding a file listener. This lets IDE clear the read-only status and then get notified by property change event and can do a checkout further. In case when a user used IDE it will have cache of file property. After this if checkout on file is done without using IDE. Then file listener will show a property change event and it will try to do a checkout again. If number of such files grows, filelistener would make IDE busy or stuck doing re-checkout in background.


I came across ReadOnlyStatusHandler.java which probably handles the changing file from read-only to writable. I am not sure on how it gets triggered. Is it possible to write a code which gets hit in the same way readonlystatushandler does? My need is just to catch user action of editing a read-only file using IDE. Please suggest if in plugin we can do this.

0

Please sign in to leave a comment.