Page 1 of 1
How to set a root map programmatically ?
Posted: Fri Feb 14, 2020 1:38 am
by Vince
Hi,
Is there any easy way to set a root map programmatically to a loaded map in the DITA map manager ?
Something like :
Code: Select all
URL url = new URL("...");
PluginWorkspaceProvider.getPluginWorkspace().open(url, "PAGE_DITA_ROOT_MAP");
Thank in advance for your help.
Vince
Re: How to set a root map programmatically ?
Posted: Fri Feb 14, 2020 12:59 pm
by adrian_sorop
Hi Vince,
The easiest way to set the root map from API is to use the
KEYS_CONTEXT_MAP option.
Something like:
Code: Select all
URL contextMapToSet = new URL("");
PluginWorkspaceProvider.getPluginWorkspace().getOptionsStorage().setOption(APIAccessibleOptionTags.KEYS_CONTEXT_MAP, contextMapToSet.toExternalForm());
Regards,
Adrian
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: How to set a root map programmatically ?
Posted: Fri Feb 14, 2020 4:52 pm
by Vince
Thanks for your reply Adrian
But, using this method, nothing appends on currently loaded map.
The specified root map is not selected in DITA MAP Manager combo box.
And any opened topic in the editor reports that the definition of keys are not found.
Any other help would be welcome.
Regards,
Vince
Re: How to set a root map programmatically ?
Posted: Fri Feb 14, 2020 6:20 pm
by adrian_sorop
Hello again,
Yes, you are right. Using the
getOptionsStorage().setOption() doesn't work.
I've made a small sample and used
setGlobalObjectProperty(). It changes the value of the
Contex combo and loads the keys from the map.
Code: Select all
PluginWorkspaceProvider.getPluginWorkspace().setGlobalObjectProperty(APIAccessibleOptionTags.KEYS_CONTEXT_MAP, contextMapToSet.toExternalForm());
Here's a sample code
Code: Select all
import java.net.URL;
import ro.sync.exml.options.APIAccessibleOptionTags;
import ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension;
import ro.sync.exml.workspace.api.PluginWorkspace;
import ro.sync.exml.workspace.api.listeners.WSEditorChangeListener;
import ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace;
public class MyPluginExtension implements WorkspaceAccessPluginExtension {
@Override
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
@Override
public void editorOpened(URL editorLocation) {
if (foo()) {
URL contextMapToSet = new URL("...");
pluginWorkspaceAccess.setGlobalObjectProperty(APIAccessibleOptionTags.KEYS_CONTEXT_MAP,
contextMapToSet.toExternalForm());
}
}
private boolean foo() {
return true;
}
},PluginWorkspace.DITA_MAPS_EDITING_AREA);
}
@Override
public boolean applicationClosing() {
return true;
}
}
Regards,
Adrian
Re: How to set a root map programmatically ?
Posted: Fri Feb 14, 2020 7:02 pm
by Vince
Great ! It works !
Thanks you very much for your help.
Regards,
Vincent