API for reload a editor

Post here questions and problems related to oXygen frameworks/document types.
vishwavaranasi
Posts: 140
Joined: Fri Feb 28, 2020 4:02 pm

API for reload a editor

Post 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
Thanks,
vishwa
Cosmin Duna
Site Admin
Posts: 120
Joined: Wed Dec 12, 2018 5:33 pm

Re: API for reload a editor

Post 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
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 140
Joined: Fri Feb 28, 2020 4:02 pm

Re: API for reload a editor

Post 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?
Thanks,
vishwa
Cosmin Duna
Site Admin
Posts: 120
Joined: Wed Dec 12, 2018 5:33 pm

Re: API for reload a editor

Post 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
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 140
Joined: Fri Feb 28, 2020 4:02 pm

Re: API for reload a editor

Post 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");
Thanks,
vishwa
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: API for reload a editor

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 140
Joined: Fri Feb 28, 2020 4:02 pm

Re: API for reload a editor

Post 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
Thanks,
vishwa
Post Reply