Using importGlobalOptions in a menu option is not updating UI dialog/views

Post here questions and problems related to oXygen frameworks/document types.
gerardch
Posts: 5
Joined: Mon Sep 14, 2020 6:43 pm

Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by gerardch » Mon Sep 14, 2020 8:54 pm

Hello,

I am using method PluginWorkspace importGlobalOptions to include some global options such transformation associations and dita transformation scenarios.
If I do this as part of a WorkspaceAccessPluginExtension.applicationStarted everything imports fine.

However, I have been changing this code to be executed in a Menu option. I want to let the user choose between some alternatives they can use dynamically. I would not like having the users clicking the standard menu "Options > Import Global Options..." so they do not have to look for the right file and choose the right import options every time.

But the problem is that when I use importGlobalOptions in this context then the options are not being updated in the UI views.
For example, if I click a Menu option to change some scenario association, the importGlobalOptions commands executes correctly, but changes are not being reflected in the "Configure Transformation Scenario(s)" dialog or view.

Should I be doing something else to trigger the update of the UI views, etc? Or Is there something else I can do??

As a reference I am using Oxygen XML Author and SDK version 22.0.

Thank you!

Radu
Posts: 7154
Joined: Fri Jul 09, 2004 5:18 pm

Re: Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by Radu » Tue Sep 15, 2020 12:20 pm

Hi,

Such a problem may occur if Oxygen does not have explicit listeners in its code to update various components when options are changed.
Each global option in Oxygen has an option key. For example a set of transformation scenarios may be serialized to XML something like:

Code: Select all

                 <entry>
                        <String>scenario.associations</String>
                        <scenarioAssociation-array>
                            <scenarioAssociation>
I looked in our code and we seem to have listeners which update our Transformation Scenarios view when the "scenario.associations" is updated to contain a new list of scenarios. We also seem to have listeners on the "scenario.associations" options key.
Can you maybe send us (support@oxygenxml.com) an options XML file along with Java sample code showing how you import it on your side? Also give some details about what you expect Oxygen's behavior to be after the options are imported? What Oxygen side view or dialog should be updated?

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

gerardch
Posts: 5
Joined: Mon Sep 14, 2020 6:43 pm

Re: Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by gerardch » Wed Sep 16, 2020 1:37 am

Thanks Radu,

I have sent some sample code and files as you requested. I am new to Oxygen development so I hope to be doing things right. At the end, all I need is to be able to change some transformation scenario data (such output directories) and transformation associations from a Menu option. I am trying to use the "importGlobalOptions" as I did not find any other way to do this. Please take a look at the info I sent and if you need something else just let me know.

Thanks!

Radu
Posts: 7154
Joined: Fri Jul 09, 2004 5:18 pm

Re: Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by Radu » Wed Sep 16, 2020 9:57 am

Hi,

Thanks for the samples. I can reproduce the problem on my side. Oxygen has a repository of transformation scenarios and it seems we are not reloading that repository automatically when the value of the global key "scenarios" changes in the global options. I added an internal issue to look more into this.
As a possible workaround, we have API to access the project view "ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace.getProjectManager()". A project ".xpr" file can also contain scenarios and various other settings. And we have API (version 22.0 and newer) to force load an XPR in the Project view:

ro.sync.exml.workspace.api.standalone.project.ProjectController.loadProject(File)

From what I looked in our code, if a loaded project XPR file comes with scenarios, Oxygen's inner scenarios repository should refresh and the scenarios should appear in the Transformation side view for example.

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

gerardch
Posts: 5
Joined: Mon Sep 14, 2020 6:43 pm

Re: Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by gerardch » Fri Sep 18, 2020 7:46 am

Hi Radu,

Thanks for the workaround. I have tried this and when I call the "ProjectController.loadProject(File)" method I get a dialog notifying that project has changed. I can reload or dismiss the change. If I reload then I get all the updates properly.
OxygenLoadProject.JPG
OxygenLoadProject.JPG (21.73 KiB) Viewed 683 times

Currently, what I am doing is, I am updating directly the scenario info in the project file.xpr. As soon as I save the file I call the loadProject method.
I am not sure if this should be done in a different way but if you have any suggestion please let me know.

Regards,

Radu
Posts: 7154
Joined: Fri Jul 09, 2004 5:18 pm

Re: Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by Radu » Fri Sep 18, 2020 2:13 pm

Hi,

Oxygen looks at the timestamp on disk to check if a file was modified or not and then show that reload dialog. Maybe you could preserve the file.lastModified() before modifying the file and then set back the same timestamp on it. I think that will prevent Oxygen from automatically detecting a change in the XPR contents.

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

gerardch
Posts: 5
Joined: Mon Sep 14, 2020 6:43 pm

Re: Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by gerardch » Wed Sep 23, 2020 9:42 am

Hi, just to confirm that this is a useful trick to prevent the "project file changed" dialog. However, in this case, if I have only one project open, when method "loadProject" is called to force reload this one project then nothing happens. Not sure is there is a validation to stop the project being actually reloaded if no change detected?

So right now, it seems that the only useful workaround is to allow the reload dialog to show up and hit the reload button to make sure everything gets actually reloaded and updated.

I guess the ideal solution is that the importGlobalOptions could be fixed so it updates the repositories in a future release. In the meantime, if you get to find any other suggestion please let me know.

Thanks,

Radu
Posts: 7154
Joined: Fri Jul 09, 2004 5:18 pm

Re: Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by Radu » Wed Sep 23, 2020 9:58 am

Hi,

About this remark:
Not sure is there is a validation to stop the project being actually reloaded if no change detected?
Indeed if the same project is already loaded and there is no modification detected on disk we probably no longer force re-load it. Maybe you could load an empty project and then the project with the options to always force reloading it.

Anyway, we made some progress on the automatic reload when the scenarios and scenario associations keys are changed using the API, hopefully we'll be able to make this work in version 23 (November this year). I will update this forum thread if we do.

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

gerardch
Posts: 5
Joined: Mon Sep 14, 2020 6:43 pm

Re: Using importGlobalOptions in a menu option is not updating UI dialog/views

Post by gerardch » Fri Sep 25, 2020 3:22 am

Hi Radu,

this is great news, glad you have made progress with the scenarios reloading when using the API.

Also, thanks for the suggestion about the empty project. I will try this and see how it works.
I think these two options, either the empty project or even keeping the reload dialog are good for me for now
while waiting for the improvement. Hopefully you will be able to make it for version 23.

I appreciate all the help. Thank you very much!

Regards,
Gerardo

Post Reply