Community
Participate
Working Groups
We would like to preform a code to model synchronization upon editor saves. Currently there is no way to be notified when an editor is saved, and thus we are resorting to resource change notifications. However these notifications can be a result of any number of actions, and not necessarily the result of the user explicitly saving the source file, which makes our solution prone to preforming its behavior at the wrong time. I am requesting that there is either an extension point or public API provided to register an observer of text editor saves. It will be important to know the context (the IEditorPart) of the save, and for our purposes, to simply be notified after the save has occurred. We have no need to participate in the save, or preempt it. We just need to know that the user has explicitly saved a given source file.
Is this something that can be known from org.eclipse.ui.ISaveablesLifecycleListener? PW
(In reply to comment #1) > Is this something that can be known from > org.eclipse.ui.ISaveablesLifecycleListener? No, the only useful implementation of ISaveablesLifecycleListener is internal - you can't just hook one on a part. Why do you want to perform your actions only when an editor is saved, and not when the file changes on disk? The JDT has a notion of "Save Participant" - does that help in any way?
Hi, File changes could be a result of generating code, in which case we do not want to trigger our logic. Or our tooling may automatically save the source in some cases (not by invoking the Global SaveAction, but by invoking doSave directly on the editor()) in which case we again don't want to invoke our logic. Ideally we would be notified on explict user saves. Perhaps the logic could be apart of the SaveableHelper? In which case if we 'short cut' and save directly on the editor instance (via tooling) we could avoid notification. We are currently only dealing with the CDT so the JDT save participant is not feasible. I would also like to suggest that registration is done via an extension point, as this would allow interested plugins to stay as unloaded until a save occurs. Thanks, Adam
You could listen for the save command, org.eclipse.ui.file.save See org.eclipse.ui.commands.ICommandService.addExecutionListener(IExecutionListener) PW
Hi, the ICommandService was a great suggestion. This provides me with enough information to do what I was wanting. Thanks, Adam
(In reply to comment #5) > Hi, the ICommandService was a great suggestion. This provides me with enough > information to do what I was wanting. I am skeptical that this will work for you long-term. Have you tested the following: - Save All - Save As... - Close the editor and click "yes" when prompted to save - Shutdown Eclipse and click "yes" when prompted to save - Run/debug something from within Eclipse - before launching, you may be prompted to save - I am sure there are more. I have a feeling that you are working against the mechanisms provided by the Workbench and the IDE rather than with them.
Remy is now responsible for watching the [EditorMgmt] component area.
(In reply to comment #5) > Hi, the ICommandService was a great suggestion. This provides me with enough > information to do what I was wanting. Adam, can I close this bug report then?
Hi, We have taken a different approach to solve the problem on our side. So if you see minimal to no benefit in providing this enhancement, a then you should go head an close it.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Would be great to have some general save actions in platform, for example: - Remove trailing whitespace Tools which would benefit from such a framework would be JavaScript, Html editor, etc. Currently only JDT has this ability. Fabrice, do you think it is reasonable / possible to provide a general framework in text which JDT could also use?
It would be great but it's a big deal 😄 I should finish easier targets first.