Package ro.sync.ecss.extensions.api
Class DefaultAuthorActionEventHandler
java.lang.Object
ro.sync.ecss.extensions.api.AuthorActionEventHandlerBase
ro.sync.ecss.extensions.api.DefaultAuthorActionEventHandler
- All Implemented Interfaces:
AuthorActionEventHandler,Extension
- Direct Known Subclasses:
DITAAuthorActionEventHandler,DocbookAuthorActionEventHandler,TEIAuthorActionEventHandler,XHTMLAuthorActionEventHandler
@API(type=EXTENDABLE,
src=PUBLIC)
public class DefaultAuthorActionEventHandler
extends AuthorActionEventHandlerBase
Intercepts TAB and SHIFT+TAB events inside a list item and promotes or demotes it.
- Since:
- 18
-
Nested Class Summary
Nested classes/interfaces inherited from interface ro.sync.ecss.extensions.api.AuthorActionEventHandler
AuthorActionEventHandler.AuthorActionEventType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanareCompatibleLists(AuthorNode node1, AuthorNode node2) Check if two given nodes are compatible lists (i.e.booleancanHandleEvent(AuthorAccess authorAccess, AuthorActionEventHandler.AuthorActionEventType type) Check if an Author action event can be handled.getContentCompletionActions(AuthorAccess authorAccess, int caretOffset) Intercepts action events in the Author mode and provides them in the content completion lists.protected StringgetParagraphElement(AuthorAccess authorAccess) Get the preferred XML element content to be inserted.protected StringgetPreferredXMLElementContent(AuthorAccess authorAccess) Get the preferred XML element content to be inserted.booleanhandleEvent(AuthorAccess authorAccess, AuthorActionEventHandler.AuthorActionEventType eventType) An event was generated.protected booleanisList(AuthorNode node) Check if the given node is a list.protected booleanisMovableListItem(AuthorAccess authorAccess, AuthorNode candidate) Checks if this node represents a list item that can be promoted/demoted.protected ContentIntervalpromote(AuthorDocumentController controller, int offset, List<AuthorNode> candidates, boolean hasSelection) Unwraps these list items from the list.protected voidpromoteSubListItems(AuthorDocumentController controller, AuthorNode theDemotedCandidate, AuthorNode listElement) Sometimes, when we demote a list item, we want it to become the sibling of its children.Methods 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.AuthorActionEventHandler
canHandleEvent, getListItemAncestorToSplit
-
Constructor Details
-
DefaultAuthorActionEventHandler
public DefaultAuthorActionEventHandler()
-
-
Method Details
-
handleEvent
public boolean handleEvent(AuthorAccess authorAccess, AuthorActionEventHandler.AuthorActionEventType eventType) Description copied from interface:AuthorActionEventHandlerAn event was generated.- Parameters:
authorAccess- Author access.eventType- The type of the generated event.- Returns:
trueif the event was handled and the default operation should be skipped,falseto let the default operation execute.- See Also:
-
getPreferredXMLElementContent
Get the preferred XML element content to be inserted. Can benull.- Parameters:
authorAccess- The author access.- Returns:
- the preferred XML element content to be inserted. Can be
null
-
getParagraphElement
Get the preferred XML element content to be inserted. Can benull.- Parameters:
authorAccess- The author access.- Returns:
- the preferred XML element content to be inserted.
-
isMovableListItem
Checks if this node represents a list item that can be promoted/demoted.- Parameters:
authorAccess- The Author access.candidate- The node that candidates for promotion/demotion.- Returns:
trueif the list item can be promoted/demoted.
-
promote
protected ContentInterval promote(AuthorDocumentController controller, int offset, List<AuthorNode> candidates, boolean hasSelection) throws BadLocationException, AuthorOperationException Unwraps these list items from the list. Moves them up one level in the hierarchy of nested lists.- Parameters:
controller- Author document controller.offset- If there is no selection, this is the offset where the action is invoked. Otherwise, this represents the end offset of the selection, needed for restoring caret position.candidates- The list items to promote.hasSelection-trueif the promotion is performed on a selection.- Returns:
- If there was no selection, return an interval from the next caret position to itself. Otherwise, if the selection was forward, return an interval from the lower offset to the higher one, or if the selection was backward, return an interval from the higher offset to the lower one. "From" means start offset and "to" means end offset.
- Throws:
BadLocationExceptionAuthorOperationException
-
promoteSubListItems
protected void promoteSubListItems(AuthorDocumentController controller, AuthorNode theDemotedCandidate, AuthorNode listElement) throws BadLocationException, AuthorOperationException Sometimes, when we demote a list item, we want it to become the sibling of its children. To obtain this, after demoting the item along with its children, we promote the children. This method promotes the children.- Parameters:
controller- The Author document controller.theDemotedCandidate- The candidate which was demoted.listElement- The parent list of the demoted item.- Throws:
AuthorOperationExceptionBadLocationException
-
isList
Check if the given node is a list.- Parameters:
node- The node.- Returns:
trueif the node is a list.
-
areCompatibleLists
Check if two given nodes are compatible lists (i.e. if we accept items from one list to migrate into the other one).- Returns:
trueif the two given nodes are compatible lists.
-
canHandleEvent
public boolean canHandleEvent(AuthorAccess authorAccess, AuthorActionEventHandler.AuthorActionEventType type) Description copied from interface:AuthorActionEventHandlerCheck if an Author action event can be handled.- Parameters:
authorAccess- Access to the Author API.type- The type of event generated.- Returns:
trueif the Author action event can be handled.- See Also:
-
getDescription
- Returns:
- The description of the extension.
- See Also:
-
getContentCompletionActions
public List<IAuthorExtensionAction> getContentCompletionActions(AuthorAccess authorAccess, int caretOffset) Intercepts action events in the Author mode and provides them in the content completion lists.- Overrides:
getContentCompletionActionsin classAuthorActionEventHandlerBase- Parameters:
authorAccess- The author access.caretOffset- The caret offset.- Returns:
- The content completion actions.
-