Reload Editor Contents from Workspace Plugin

Post here questions and problems related to oXygen frameworks/document types.
Posts: 8

Reload Editor Contents from Workspace Plugin

Wed Jan 24, 2018 9:20 am


I am creating a CMS plugin. I have implemented my plugin as a WorkspaceAccess plugin with a custom protocol handler implementation.
Now, I need to give the user an option of reloading the contents of their editor (discarding any local changes) from the original source (the custom protocol URL). I found the following 2 methods in the SDK documentation:

1) WSEditor.reloadContent(Reader) -- Reloads from provided reader.
2) ro.sync.ecss.extensions.commons.operations.ReloadContentOperation.doOperation(AuthorAccess, ArgumentsMap) -- Reloads from the original source.

I am currently using the first (1) method, but it doesn't quite fit my requirement as it marks the file dirty. While all I want is to just tell the editor that the file has been modified from outside, and just reload from the original source and mark it not dirty instead.

The second method seems perfect for my use case, just that I could not find a way to obtain an instance of AuthorAccess in a WorkspaceAccess plugin.

I want to know if there is a better way of achieving what I'm trying to do? Or how to obtain the AuthorAccess instance so that I can call ReloadContentOperation.

Posts: 179

Re: Reload Editor Contents from Workspace Plugin

Wed Jan 24, 2018 4:46 pm


To obtain the AuthorAccess in a WorkspaceAccess plugin you have to add an editor changed listener that allows you to get access to the editor page:

Code: Select all

    public void applicationStarted(final StandalonePluginWorkspace pluginWorkspaceAccess) {
      pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener(){
        public void editorOpened(URL editorLocation) {
          WSEditor editorAccess = pluginWorkspaceAccess.getEditorAccess(editorLocation, PluginWorkspace.MAIN_EDITING_AREA);
          WSEditorPage edPage = editorAccess.getCurrentPage();
          if(edPage instanceof WSAuthorEditorPage){
            // Get the author access
            AuthorAccess authorAccess = ((WSAuthorEditorPage)edPage).getAuthorAccess();
            // Your code here...
      }, PluginWorkspace.MAIN_EDITING_AREA);

Best Regards,
Mihaela Calotescu
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 2 guests