Oxygen API to detect close operation on file

Post here questions and problems related to oXygen frameworks/document types.
FrankDLT
Posts: 17
Joined: Tue Jul 12, 2022 10:17 pm

Oxygen API to detect close operation on file

Post by FrankDLT »

Hello and good day.
I'm working on a project with the requirement of suggesting an action to the user upon trying to close a file in the editor, is there any API I could use that detects when a file was selected to close by the "X" button or the right click close option?

Thank you.
-Frank
FrankDLT
Posts: 17
Joined: Tue Jul 12, 2022 10:17 pm

Re: Oxygen API to detect close operation on file

Post by FrankDLT »

Hello team,
I while after I posted the question I came across the API for editorAboutToBeClosed() which is exactly what I was looking for.
But I did have another query, since I have the plugin workspace access is there a way to extract the name of the file its been worked on?
Thank you.
-Frank
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Oxygen API to detect close operation on file

Post by Radu »

Hi Frank,

The "editorAboutToBeClosed" callback receives the URL of the file which is about to be closed.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
FrankDLT
Posts: 17
Joined: Tue Jul 12, 2022 10:17 pm

Re: Oxygen API to detect close operation on file

Post by FrankDLT »

Hi Radu

Thanks for your response, I have been testing the API that you suggested and works great.
I do have a question regarding the API, is it possible to detect only when the user clicks on the (X) or does a right click and selects "close" on the file?
Right now it is triggering the API when the file is closed by any reason such as closing oxygen itself and other methods that involve closing a file, but I only need it to trigger on direct closure of the file.

Thank you for your time and assistance,
Frank
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Oxygen API to detect close operation on file

Post by Radu »

Hi Frank,

We do not have particular API which would allow you to know "how" an end user decided to close a file.
We do have this callback that you receive in the plugin extension "ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension.applicationClosing()" and which should notify you before the actual opened documents are closed so maybe you can use this to your advantage and on the "WorkspaceAccessPluginExtension.applicationClosing" callback remove for example the listener you have added to listen for editor closed notifications.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply