Page 1 of 1
API for reload a editor
Posted: Thu Feb 23, 2023 1:52 pm
by vishwavaranasi
Hello Team , is there any API in oxygenxml for reload a editor?
we know manually we can use the option from File ->Reload(F5)
Thanks,
Vishwa
Re: API for reload a editor
Posted: Thu Feb 23, 2023 3:13 pm
by Cosmin Duna
Hi Vishwa,
We don't have an API for this, but we already have an internal issue and I added your request to it.
As a workaround you can search for the Reload action in the author common actions like this:
Code: Select all
WSEditorPage page = editor.getCurrentPage();
if (page instanceof WSAuthorEditorPage) {
WSAuthorEditorPage authorPage = (WSAuthorEditorPage)page;
Map<String, Object> commonActions = authorPage.getActionsProvider().getAuthorCommonActions();
AbstractAction realoadAction = (AbstractAction) commonActions.get("File/Reload");
}
Best regards,
Cosmin
Re: API for reload a editor
Posted: Fri Mar 31, 2023 9:49 am
by vishwavaranasi
Thanks Cosmin ,
am trying something like this
/** try to reload editor*/
Code: Select all
AuthorActionsProvider actionsProvider = (AuthorActionsProvider) pluginWorkspaceAccess.getActionsProvider();
Map<String, Object> authorCommonActions = actionsProvider.getAuthorCommonActions();
Object reloadEditorAction = authorCommonActions.get("File/Reload");
actionsProvider.invokeAction(reloadEditorAction);
but this giving me an error
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: ro.sync.exml.MainFrame cannot be cast to ro.sync.exml.workspace.api.editor.page.author.actions.AuthorActionsProvider
would you please help me?
Re: API for reload a editor
Posted: Mon Apr 03, 2023 9:18 am
by Cosmin Duna
Hi Vishwa,
The ActionsProvider returned by this method is not an "AuthorActionsProvider", but you can get the Reload action from the global actions too. Please try this code:
Code: Select all
ActionsProvider actionsProvider = pluginWorkspaceAccess.getActionsProvider();
Map<String, Object> globalActions = actionsProvider.getGlobalActions();
AbstractAction reloadAction = (AbstractAction)globalActions.get("File/Reload");
Best regards,
Cosmin
Re: API for reload a editor
Posted: Wed May 03, 2023 11:22 am
by vishwavaranasi
Hello Cosmin ,
I wanted to invoke this File Reload outside of method
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess)
so here , how can i get the object for pluginWorkspaceAccess
to call as below
ActionsProvider actionsProvider = pluginWorkspaceAccess.getActionsProvider();
Map<String, Object> globalActions = actionsProvider.getGlobalActions();
AbstractAction reloadAction = (AbstractAction)globalActions.get("File/Reload");
Re: API for reload a editor
Posted: Wed May 03, 2023 2:07 pm
by Radu
Hi,
You can use our static access to the plugin workspace:
Code: Select all
((StandalonePluginWorkspace)PluginWorkspaceProvider.getPluginWorkspace()).getActionsProvider()
or of course pass the "pluginWorkspaceAccess" received on the applicationStarted callback to all places where you need it further, for example keep it as a field in the plugin extension class...
Regards,
Radu
Re: API for reload a editor
Posted: Wed May 03, 2023 3:23 pm
by vishwavaranasi
Thanks Radu.
Code: Select all
ActionsProvider actionsProvider = ((StandalonePluginWorkspace)PluginWorkspaceProvider.getPluginWorkspace()).getActionsProvider();
Map<String, Object> globalActions = actionsProvider.getGlobalActions();
AbstractAction reloadAction = (AbstractAction)globalActions.get("File/Reload");
actionsProvider.invokeAction(reloadAction);
is this invokeAction will reload all files opened inside DITA MAPS manager ?
my use case here ,
I have a main ditamap and it has submap , and i inserted a topic ref to submap , and the guids.ditamap is referred as mapref inside the main ditamap file.
until unless i reload the main ditamap manually , the newly inserted topicref inside submap are not resolving , to avoid that i wanted to relaod all files inside DITA MAPS manager as soon as insert anything anywhere.
any help on this would be appreciated please.
Thanks,
vishwa