ExtensionsBundle activating twice with changePage()
Posted: Wed Oct 22, 2014 12:51 am
I have the following code in my WorkspaceAccessPluginExtension to force the initial opening of a document into AuthorMode to ensure that some processing accomplished in the AuthorExtensionStateListener is performed. From a user perspective everything appears to function fine. When I look at the logging I see that my ExtensionsBundle is being activated as a result of my changePage() method call, but is activated again at some point after my editorOpened override is complete. This is effectively causing my AuthorExtensionStateListener activated() code to run twice, which is undesired overhead. Is there some issue with me using changePage() this way?
Thanks,
AN
Code: Select all
@Override
public void applicationStarted(final StandalonePluginWorkspace pluginWorkspaceAccess) {
LOGGER.debug("Application started...");
// Force the Author view when a file is initially opened.
pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
@Override
public void editorOpened(URL editorLocation) {
LOGGER.debug("Editor opened");
WSEditor editorAccess = pluginWorkspaceAccess.getEditorAccess(editorLocation,
StandalonePluginWorkspace.MAIN_EDITING_AREA);
if (editorAccess != null && !(editorAccess.getCurrentPage() instanceof WSAuthorEditorPage)) {
LOGGER.debug("Switching to Author Mode");
editorAccess.changePage(EditorPageConstants.PAGE_AUTHOR);
LOGGER.debug("Finished switching to Author Mode");
}
}
}, StandalonePluginWorkspace.MAIN_EDITING_AREA);
LOGGER.debug("End app started block");
}
AN