Override option prompting user when opening map in DITA Map Manager

Post here questions and problems related to oXygen frameworks/document types.
bdargham
Posts: 2
Joined: Tue Dec 21, 2021 3:47 pm

Override option prompting user when opening map in DITA Map Manager

Post by bdargham »

Hello,

In the standalone Oxygen workspace, I'm trying to programically open a DITA map in both the DITA Maps Manager and the primary Editor, irrespective of user preferences and without prompting the user to decide. I've tried several approaches but none seem to work:

To simply open it in the Dita Maps Manager, I've tried the following:

Code: Select all

PluginWorkspaceProvider.getPluginWorkspace().open(url, EditorPageConstants.PAGE_DITA_MAP);
But the user still gets prompted as to where to open the file. From what I can tell, none of the

Code: Select all

ro.sync.ecss.extensions.api.component.BaseComponentEditorManager#open(URL,...)
methods do anything with the parameters other than the initial URL, and the subclasses don't override this behavior.

Another approach I tried was to set the user preference before the call and then restore it afterwards, something like:

Code: Select all

final String ASK_OPEN_IN_DITAMAP_PROP = "ask.open.ditamap.in.dita.manager";
PluginWorkspace ws = PluginWorkspaceProvider.getPluginWorkspace();
Object originalValue = PluginWorkspaceProvider.getPluginWorkspace().getGlobalObjectProperty(ASK_OPEN_IN_DITAMAP_PROP);
ws.setGlobalObjectProperty(ASK_OPEN_IN_DITAMAP_PROP, StandalonePluginWorkspace.DITA_MAPS_EDITING_AREA);
ws.open(url, EditorPageConstants.PAGE_DITA_MAP);
ws.setGlobalObjectProperty(ASK_OPEN_IN_DITAMAP_PROP, originalValue);
But I get the following error:

Code: Select all

java.lang.IllegalArgumentException: Only keys in the APIAccessibleOptionTags interface are accessible via the API.
Am I missing something or is what I'm trying to do simply not possible?

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

Re: Override option prompting user when opening map in DITA Map Manager

Post by Radu »

Hi,

Doing something like this should open the map in the main editing area:

Code: Select all

pluginWorkspaceAccess.open(new URL("...flowers.ditamap"), null, "text/xml");
I'm afraid we do not have an API to force open the DITA Map in the DITA Maps Manager view.
About this alternative you are trying with reading the current state of the global setting "PluginWorkspaceProvider.getPluginWorkspace().getGlobalObjectProperty(ASK_OPEN_IN_DITAMAP_PROP)", I'm afraid that for security reasons (for example not allowing plugins to read saved passwords) we allow plugins to read only keys which appear in the "ro.sync.exml.options.APIAccessibleOptionTags" interface.
As the "ask.open.ditamap.in.dita.manager" key is safe I just moved it to the "ro.sync.exml.options.APIAccessibleOptionTags" interface so in Oxygen 24.1 you will be able to query its current value.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
bdargham
Posts: 2
Joined: Tue Dec 21, 2021 3:47 pm

Re: Override option prompting user when opening map in DITA Map Manager

Post by bdargham »

Thank you.
Post Reply