The
ro.sync.ecss.extensions.api.AuthorExtensionStateListener
implementation is notified when the Author extension where the
listener is defined is activated or deactivated in the Document Type
detection process.
import ro.sync.ecss.extensions.api.AuthorAccess; import ro.sync.ecss.extensions.api.AuthorExtensionStateListener; public class SDFAuthorExtensionStateListener implements AuthorExtensionStateListener { private AuthorListener sdfAuthorDocumentListener; private AuthorMouseListener sdfMouseListener; private AuthorCaretListener sdfCaretListener; private OptionListener sdfOptionListener;
The activation event received by
this listener when the rules of the Document Type Association match a
document opened in the Author editor page, should be used to perform
custom initializations and to register listeners like
ro.sync.ecss.extensions.api.AuthorListener
,
ro.sync.ecss.extensions.api.AuthorMouseListener
or
ro.sync.ecss.extensions.api.AuthorCaretListener
.
public void activated(AuthorAccess authorAccess) { // Get the value of the option. String option = authorAccess.getOptionsStorage().getOption( "sdf.custom.option.key", ""); // Use the option for some initializations... // Add an option listener. authorAccess.getOptionsStorage().addOptionListener(sdfOptionListener); // Add author document listeners. sdfAuthorDocumentListener = new SDFAuthorListener(); authorAccess.getDocumentController().addAuthorListener( sdfAuthorDocumentListener); // Add mouse listener. sdfMouseListener = new SDFAuthorMouseListener(); authorAccess.getEditorAccess().addAuthorMouseListener(sdfMouseListener); // Add caret listener. sdfCaretListener = new SDFAuthorCaretListener(); authorAccess.getEditorAccess().addAuthorCaretListener(sdfCaretListener); // Other custom initializations... }
The authorAccess
parameter received by the
activated
method can be used to gain
access to Author specific actions and informations related to
components like the editor, document, workspace, tables, change
tracking a.s.o.
If options specific to the custom developed Author extension need to
be stored or retrieved, a reference to the
OptionsStorage
can be obtained by calling
the getOptionsStorage
method from the author
access. The same object can be used to register
OptionListener
listeners. An option
listener is registered in relation with an option key and will be notified about the value
changes of that option.
An AuthorListener
can be used if events
related to the Author document modifications are of interest. The
listener can be added to the
AuthorDocumentController
. A reference to
the document controller is returned by the
getDocumentController
method from the
author access. The document controller can also be used to perform
operations involving document modifications.
To provide access to Author editor component related functionality
and informations, the author access has a reference to the
AuthorEditorAccess
that can be obtained
when calling the getEditorAccess
method. At
this level AuthorMouseListener
and
AuthorCaretListener
can be added which
will be notified about mouse and caret events occurring in the Author
editor page.
The deactivation event is received
when another framework is activated for the same document, the user
switches to another editor page or the editor is closed. The
deactivate
method is typically used to
unregister the listeners previously added on the
activate
method and to perform other
actions. For example options related to the deactivated author
extension can be saved at this point.
public void deactivated(AuthorAccess authorAccess) { // Store the option. authorAccess.getOptionsStorage().setOption( "sdf.custom.option.key", optionValue); // Remove the option listener. authorAccess.getOptionsStorage().removeOptionListener(sdfOptionListener); // Remove document listeners. authorAccess.getDocumentController().removeAuthorListener( sdfAuthorDocumentListener); // Remove mouse listener. authorAccess.getEditorAccess().removeAuthorMouseListener(sdfMouseListener); // Remove caret listener. authorAccess.getEditorAccess().removeAuthorCaretListener(sdfCaretListener); // Other actions... }