|Closing editors when project is closed/deleted [message #570384]
||Tue, 21 September 2010 16:47
| Subhash Gopalakrishnan
Registered: July 2009
I have frequently come across the scenario where a project is closed or |
deleted and the editors that are opened on the contained files don't
close automatically, but remain open and complain about missing files.
While debugging my editors, I realized that some editors subscribe to
resource change events and close with the project. But when a workbench
with open editors restarts, some of the editors might not be initialized
and therefore not subscribed to resource change events. This causes the
aforementioned error to occur when editors haven't yet got focus.
Is it a valid solution to instead keep a singleton listener in my plugin
activator and subscribe it during start() and unsubscribe during stop()?
This listener gets the active workbench page, gets all the editor
references, checks if their input matches the event's resource and if
so, close the editor.
I tried out this solution and it seems to work fine for project closes,
project deletes, file deletes across workbench restarts. And then, I was
curious to know if this is the usual way this problem is handled and if
I am missing something. Please let me know if there's a specific reason
for subscribing a listener for each editor.
Powered by FUDForum
. Page generated in 0.11160 seconds