Package ro.sync.ecss.extensions.docbook
Class DocbookSchemaAwareEditingHandler
java.lang.Object
ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandlerAdapter
ro.sync.ecss.extensions.docbook.DocbookSchemaAwareEditingHandler
- All Implemented Interfaces:
AuthorSchemaAwareEditingHandler
- Direct Known Subclasses:
Docbook5SchemaAwareEditingHandler
@API(type=INTERNAL,
src=PUBLIC)
public class DocbookSchemaAwareEditingHandler
extends AuthorSchemaAwareEditingHandlerAdapter
Specific editing support for Docbook documents. Handles typing and paste events inside itemizedlist, orderlist (a
listitem with a para will be created and the typing/paste content be put inside it) and tables.
-
Nested Class Summary
Nested classes/interfaces inherited from class ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandlerAdapter
AuthorSchemaAwareEditingHandlerAdapter.WrapInAncestorsOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringFor Docbook 5 http://docbook.org/ns/docbook, for Docbook 4 an empty string.protected static final StringDocbook info element name suffix.protected static final StringDocbook HTML para element name.protected static final StringDocbook HTML title element name.Fields inherited from class ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandlerAdapter
lastHandlerResultFields inherited from interface ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler
ACTION_ID_BACKSPACE, ACTION_ID_CUT, ACTION_ID_DELETE, ACTION_ID_DND, ACTION_ID_INSERT_FRAGMENT, ACTION_ID_PASTE, ACTION_ID_TYPING, CREATE_FRAGMENT_PURPOSE_COPY, CREATE_FRAGMENT_PURPOSE_CUT, CREATE_FRAGMENT_PURPOSE_DND_COPY, CREATE_FRAGMENT_PURPOSE_DND_MOVE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanchangeElementsToMoveUpDown(List<AuthorNode> selectedElements) Determine the elements that should be moved by the Move Up/Down operation.One of the default smart paste strategies involves detecting an path o ancestors from the context element to the inserted one.protected StringgetInfoElementChildOfSect(String sectElementName) Get the info child element name of to the given sect element name.getPreferredElement(AuthorDocumentController ctrl, int offset) Get the qualified name of the best element to be inserted at the caret position as a wrapper for the content that is being typed or pasted.booleanhandlePasteFragment(int offset, AuthorDocumentFragment[] fragmentsToInsert, int actionId, AuthorAccess authorAccess) Handle an insert fragment event generated by: a Paste action.booleanhandleTyping(int offset, char ch, AuthorAccess authorAccess) Handle a typing event.booleanhandleTypingFallback(int offset, char ch, AuthorAccess authorAccess) Give a fallback solution for a typing event.protected booleanisElementWithNameAndNamespace(AuthorNode node, String elementLocalName) protected voidpushContextElement(WhatElementsCanGoHereContext context, String elementName) Derive the given context by adding the given element.Methods inherited from class ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandlerAdapter
canBeReplaced, getLastResult, handleCreateDocumentFragment, handleDelete, handleDeleteElementTags, handleDeleteNodes, handleDeleteSelection, handleJoinElementsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler
handleCodePointTyping, handleCodePointTypingFallback
-
Field Details
-
documentNamespace
For Docbook 5 http://docbook.org/ns/docbook, for Docbook 4 an empty string. -
PARA
Docbook HTML para element name.- See Also:
-
TITLE
Docbook HTML title element name.- See Also:
-
INFO_SUFIX
Docbook info element name suffix.- See Also:
-
-
Constructor Details
-
DocbookSchemaAwareEditingHandler
Constructor.- Parameters:
documentNamespace- The document namespace, for different versions of Docbook.
-
-
Method Details
-
handleTyping
public boolean handleTyping(int offset, char ch, AuthorAccess authorAccess) throws InvalidEditException Description copied from interface:AuthorSchemaAwareEditingHandlerHandle a typing event. If the event is not handled, the default implementation of a handler will be given a chance to handle the event. If that fails to provide a solution,AuthorSchemaAwareEditingHandler.handleTypingFallback(int, char, AuthorAccess)will get called.- Specified by:
handleTypingin interfaceAuthorSchemaAwareEditingHandler- Overrides:
handleTypingin classAuthorSchemaAwareEditingHandlerAdapter- Parameters:
offset- Offset where the typing occurred.ch- The typed character.authorAccess- Access class to the author functions.- Returns:
trueif the typing was handled.- Throws:
InvalidEditException- This is an invalid edit and must be rejected.- See Also:
-
handleTypingFallback
public boolean handleTypingFallback(int offset, char ch, AuthorAccess authorAccess) throws InvalidEditException Description copied from interface:AuthorSchemaAwareEditingHandlerGive a fallback solution for a typing event. This call comes when this object'sAuthorSchemaAwareEditingHandler.handleTyping(int, char, AuthorAccess)method did not handle the typing event and neither did theAuthorSchemaAwareEditingHandler.handleTyping(int, char, AuthorAccess)from the default implementation.As a fallback solution, a paragraph can be inserted at the given offset (if allowed) and then the typed character can be inserted inside it.
- Specified by:
handleTypingFallbackin interfaceAuthorSchemaAwareEditingHandler- Overrides:
handleTypingFallbackin classAuthorSchemaAwareEditingHandlerAdapter- Parameters:
offset- Offset where the typing occurred.ch- The typed character.authorAccess- Access class to the author functions.- Returns:
trueif the typing was handled.- Throws:
InvalidEditException- This is an invalid edit and must be rejected.- See Also:
-
handlePasteFragment
public boolean handlePasteFragment(int offset, AuthorDocumentFragment[] fragmentsToInsert, int actionId, AuthorAccess authorAccess) throws InvalidEditException Description copied from interface:AuthorSchemaAwareEditingHandlerHandle an insert fragment event generated by:- a Paste action. In this case, selection removal is handled before calling this method.
- a DND action. In this case source removal is handled after calling this method (unless an exception was thrown).
- an insert fragment event occurred as a result of an schema aware insert event,
like
AuthorDocumentController.insertXMLFragmentSchemaAware(String, int). Selection removal is handled before calling this method.
- Specified by:
handlePasteFragmentin interfaceAuthorSchemaAwareEditingHandler- Overrides:
handlePasteFragmentin classAuthorSchemaAwareEditingHandlerAdapter- Parameters:
offset- Offset where the event occurred.fragmentsToInsert- Fragments to be inserted.actionId- ACTION_ID_PASTE if event was generated by paste action, ACTION_ID_DND if it was generated by a DND event or ACTION_ID_INSERT_FRAGMENT if the event was generated by anAuthorDocumentControllerschema aware insert method.authorAccess- Access class to the author functions.- Returns:
trueif the insertion was handled.- Throws:
InvalidEditException- This is an invalid edit and must be rejected.- See Also:
-
getInfoElementChildOfSect
Get the info child element name of to the given sect element name.- Parameters:
sectElementName- The sect element name.- Returns:
- The info child element name.
-
pushContextElement
Derive the given context by adding the given element. -
isElementWithNameAndNamespace
- Returns:
trueif the given node is an element with the given local name and from the Docbook namespace.
-
changeElementsToMoveUpDown
Description copied from class:AuthorSchemaAwareEditingHandlerAdapterDetermine the elements that should be moved by the Move Up/Down operation. For example if the current selected element is atitlethen the element that should actually be moved is its parent (e.g.sectionfor DocBook).- Overrides:
changeElementsToMoveUpDownin classAuthorSchemaAwareEditingHandlerAdapter- Parameters:
selectedElements- the selected elements in the author page. This list should be altered depending on the framework specific structure.
For example if the current selected element is atitlethen the element that should actually be present in this list is its parent (e.g.sectionfor DocBook).- Returns:
trueif the list of elements to be moved was altered by the framework specific handler.- See Also:
-
getAncestorDetectionOptions
Description copied from class:AuthorSchemaAwareEditingHandlerAdapterOne of the default smart paste strategies involves detecting an path o ancestors from the context element to the inserted one. These are the preferences that control how these ancestors are chosen.- Overrides:
getAncestorDetectionOptionsin classAuthorSchemaAwareEditingHandlerAdapter- Returns:
- Preferences for choosing the best possible ancestors while building a path.
- See Also:
-
getPreferredElement
Description copied from class:AuthorSchemaAwareEditingHandlerAdapterGet the qualified name of the best element to be inserted at the caret position as a wrapper for the content that is being typed or pasted.- Overrides:
getPreferredElementin classAuthorSchemaAwareEditingHandlerAdapter- Parameters:
ctrl- Provides methods for modifying the Author document.offset- The caret offset where the insertion is performed.- Returns:
- the qualified name of the preferred element or
null. - See Also:
-