Hi Nathan,
I'm sorry I didn't give more details. I kind of expected our
documentation to also mention more on how to install the filter,
but at a closer look I see that it doesn't... I'll add an issue to
add more details.
There are two places where you can add the filter:
1. AuthorExtensionStateListener.activated(), if you are working
with framework level API. Like you've said, you can create a class
which extends the DITAExtensionBundle and override
createAuthorExtensionStateListener(). I recommend also delegating
to the super listener (the default bundle needs this listener
too), like so:
public class CustomDITAExtensionBundle extends
DITAExtensionsBundle {
/**
* @see
ro.sync.ecss.extensions.dita.DITAExtensionsBundle#createAuthorExtensionStateListener()
*/
@Override
public AuthorExtensionStateListener
createAuthorExtensionStateListener() {
final AuthorExtensionStateListener superListener =
super.createAuthorExtensionStateListener();
return new AuthorExtensionStateListenerDelegator() {
@Override
public String getDescription() {
return "";
}
@Override
public void deactivated(AuthorAccess authorAccess) {
superListener.deactivated(authorAccess);
}
@Override
public void activated(AuthorAccess authorAccess) {
// TODO INSTALL FILTER
authorAccess.getDocumentController().setDocumentFilter(authorDocumentFilter);
superListener.activated(authorAccess);
}
};
}
}
2. An Workspace Access plugin [2], if you are working with plugin
API. Like so:
public void applicationStarted(final StandalonePluginWorkspace
pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditorChangeListener(
new WSEditorChangeListener() {
@Override
public void editorOpened(URL editorLocation) {
WSEditor editorAccess =
pluginWorkspaceAccess.getEditorAccess(editorLocation,
PluginWorkspace.MAIN_EDITING_AREA);
WSEditorPage currentPage =
editorAccess.getCurrentPage();
if (currentPage instanceof WSAuthorEditorPage) {
WSAuthorEditorPage authorEditorPage =
(WSAuthorEditorPage) currentPage;
authorEditorPage.getAuthorAccess().getDocumentController().setDocumentFilter(authorDocumentFilter);
}
// TODO It's also a good idea to listener for page
changes on the editor.
// Perhaps the editor opens in the text page and the
user switches later on to author.
editorAccess.addPageChangedListener(new
WSEditorPageChangedListener() {
@Override
public void editorPageChanged() {
// TODO Same code here to add the filter.
}
});
}
},
PluginWorkspace.MAIN_EDITING_AREA);
[1]
http://www.oxygenxml.com/InstData/Editor/SDK/javadoc/ro/sync/ecss/extensions/api/AuthorExtensionStateListener.html
[2]
http://www.oxygenxml.com/doc/ug-editor/#concepts/workspace-access-plugin.html
Best regards,
Alex
--
Alex Jitianu
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
On 06-May-14 8:50 AM, Nathan wrote: