Package ro.sync.ecss.extensions.api
Class AuthorSchemaAwareEditingHandlerAdapter
- java.lang.Object
-
- ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandlerAdapter
-
- All Implemented Interfaces:
AuthorSchemaAwareEditingHandler
- Direct Known Subclasses:
DITASchemaAwareEditingHandler
,DocbookSchemaAwareEditingHandler
,TEISchemaAwareEditingHandler
@API(type=EXTENDABLE, src=PUBLIC) public class AuthorSchemaAwareEditingHandlerAdapter extends java.lang.Object implements AuthorSchemaAwareEditingHandler
Adapter class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AuthorSchemaAwareEditingHandlerAdapter.WrapInAncestorsOptions
One of the default smart paste strategies involves detecting an path o ancestors from the context element to the inserted one.
-
Field Summary
Fields Modifier and Type Field Description protected SchemaAwareHandlerResult
lastHandlerResult
Last handler result.-
Fields 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 Constructor Description AuthorSchemaAwareEditingHandlerAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
canBeReplaced(AuthorNode nodeToReplace)
When pasting an element inside an empty element with the same name, a possible solution is to replace the empty node with the new one.boolean
changeElementsToMoveUpDown(java.util.List<AuthorNode> selectedElements)
Determine the elements that should be moved by the Move Up/Down operation.AuthorSchemaAwareEditingHandlerAdapter.WrapInAncestorsOptions
getAncestorDetectionOptions()
One of the default smart paste strategies involves detecting an path o ancestors from the context element to the inserted one.SchemaAwareHandlerResult
getLastResult()
Deprecated.Will be removed in a future versionjavax.xml.namespace.QName
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.AuthorDocumentFragment
handleCreateDocumentFragment(int startOffset, int endOffset, int creationPurposeID, AuthorAccess authorAccess)
Create an AuthorDocumentFragment for a paste or DnD purposeboolean
handleDelete(int offset, int deleteType, AuthorAccess authorAccess, boolean wordLevel)
Handle a keyboard delete event at the given offset (using Delete or Backspace keys) in the Author edit area.boolean
handleDeleteElementTags(AuthorNode nodeToUnwrap, AuthorAccess authorAccess)
Handle delete element tags event.boolean
handleDeleteNodes(AuthorNode[] nodes, int deleteType, AuthorAccess authorAccess)
Handle a delete nodes event coming from the Outline or Bread crumb.boolean
handleDeleteSelection(int selectionStart, int selectionEnd, int generatedByActionId, AuthorAccess authorAccess)
Handle a delete selection event in the Author edit area.boolean
handleJoinElements(AuthorNode targetNode, java.util.List<AuthorNode> nodesToJoin, AuthorAccess authorAccess)
Handle a join event between the given nodes.boolean
handlePasteFragment(int offset, AuthorDocumentFragment[] fragmentsToInsert, int actionId, AuthorAccess authorAccess)
Handle an insert fragment event generated by: a Paste action.boolean
handleTyping(int offset, char ch, AuthorAccess authorAccess)
Handle a typing event.boolean
handleTypingFallback(int offset, char ch, AuthorAccess authorAccess)
Give a fallback solution for a typing event.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandler
handleCodePointTyping, handleCodePointTypingFallback
-
-
-
-
Field Detail
-
lastHandlerResult
protected SchemaAwareHandlerResult lastHandlerResult
Last handler result.
-
-
Method Detail
-
handleDelete
public boolean handleDelete(int offset, int deleteType, AuthorAccess authorAccess, boolean wordLevel) throws InvalidEditException
Description copied from interface:AuthorSchemaAwareEditingHandler
Handle a keyboard delete event at the given offset (using Delete or Backspace keys) in the Author edit area.- Specified by:
handleDelete
in interfaceAuthorSchemaAwareEditingHandler
- Parameters:
offset
- Offset where the delete event happened.deleteType
-ACTION_ID_DELETE
if Delete key was used orACTION_ID_BACKSPACE
for Backspace.authorAccess
- Access class to the author functions.wordLevel
-true
if the user requested a delete for a whole word.- Returns:
true
if the event was handled.- Throws:
InvalidEditException
- This is an invalid edit and must be rejected.- See Also:
AuthorSchemaAwareEditingHandler.handleDelete(int, int, ro.sync.ecss.extensions.api.AuthorAccess, boolean)
-
handleDeleteElementTags
public boolean handleDeleteElementTags(AuthorNode nodeToUnwrap, AuthorAccess authorAccess) throws InvalidEditException
Description copied from interface:AuthorSchemaAwareEditingHandler
Handle delete element tags event. (Unwrapping)- Specified by:
handleDeleteElementTags
in interfaceAuthorSchemaAwareEditingHandler
- Parameters:
nodeToUnwrap
- The node to delete element tags.authorAccess
- Access class to the author functions.- Returns:
true
if the event was handled.- Throws:
InvalidEditException
- This is an invalid edit and must be rejected.- See Also:
AuthorSchemaAwareEditingHandler.handleDeleteElementTags(ro.sync.ecss.extensions.api.node.AuthorNode, ro.sync.ecss.extensions.api.AuthorAccess)
-
handleDeleteSelection
public boolean handleDeleteSelection(int selectionStart, int selectionEnd, int generatedByActionId, AuthorAccess authorAccess) throws InvalidEditException
Description copied from interface:AuthorSchemaAwareEditingHandler
Handle a delete selection event in the Author edit area. The event is generated when a selection exists inside the document and one of following actions takes place:- typing (insert a new character in document by typing);
- cut;
- DND move;
- delete or backspace.
- Specified by:
handleDeleteSelection
in interfaceAuthorSchemaAwareEditingHandler
- Parameters:
selectionStart
- Selection start offset, inclusive.selectionEnd
- Selection end offset, inclusive.generatedByActionId
- An id identifying the action that generated this event. One of the following constants are possible: ACTION_ID_TYPING, ACTION_ID_DELETE, ACTION_ID_PASTE, ACTION_ID_CUT, ACTION_ID_DND, ACTION_ID_INSERT_FRAGMENT.authorAccess
- Access class to the author functions.- Returns:
true
if the event was handled.- Throws:
InvalidEditException
- This is an invalid edit and must be rejected.- See Also:
AuthorSchemaAwareEditingHandler.handleDeleteSelection(int, int, int, ro.sync.ecss.extensions.api.AuthorAccess)
-
handleJoinElements
public boolean handleJoinElements(AuthorNode targetNode, java.util.List<AuthorNode> nodesToJoin, AuthorAccess authorAccess) throws InvalidEditException
Description copied from interface:AuthorSchemaAwareEditingHandler
Handle a join event between the given nodes.- Specified by:
handleJoinElements
in interfaceAuthorSchemaAwareEditingHandler
- Parameters:
targetNode
- The node where the content of the other nodes must migrate.nodesToJoin
- The nodes that must be joined in the target node.authorAccess
- Access class to the author functions.- Returns:
true
if the event was handled.- Throws:
InvalidEditException
- This is an invalid edit and must be rejected.- See Also:
AuthorSchemaAwareEditingHandler.handleJoinElements(ro.sync.ecss.extensions.api.node.AuthorNode, java.util.List, ro.sync.ecss.extensions.api.AuthorAccess)
-
handlePasteFragment
public boolean handlePasteFragment(int offset, AuthorDocumentFragment[] fragmentsToInsert, int actionId, AuthorAccess authorAccess) throws InvalidEditException
Description copied from interface:AuthorSchemaAwareEditingHandler
Handle 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:
handlePasteFragment
in interfaceAuthorSchemaAwareEditingHandler
- 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 anAuthorDocumentController
schema aware insert method.authorAccess
- Access class to the author functions.- Returns:
true
if the insertion was handled.- Throws:
InvalidEditException
- This is an invalid edit and must be rejected.- See Also:
AuthorSchemaAwareEditingHandler.handlePasteFragment(int, ro.sync.ecss.extensions.api.node.AuthorDocumentFragment[], int, ro.sync.ecss.extensions.api.AuthorAccess)
-
handleTyping
public boolean handleTyping(int offset, char ch, AuthorAccess authorAccess) throws InvalidEditException
Description copied from interface:AuthorSchemaAwareEditingHandler
Handle 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:
handleTyping
in interfaceAuthorSchemaAwareEditingHandler
- Parameters:
offset
- Offset where the typing occurred.ch
- The typed character.authorAccess
- Access class to the author functions.- Returns:
true
if the typing was handled.- Throws:
InvalidEditException
- This is an invalid edit and must be rejected.- See Also:
AuthorSchemaAwareEditingHandler.handleTyping(int, char, ro.sync.ecss.extensions.api.AuthorAccess)
-
getLastResult
@Deprecated public SchemaAwareHandlerResult getLastResult()
Deprecated.Will be removed in a future version- Returns:
- The result generated by the last handler method invoked before this call.
Is
null
if event was not handled.
-
handleCreateDocumentFragment
public AuthorDocumentFragment handleCreateDocumentFragment(int startOffset, int endOffset, int creationPurposeID, AuthorAccess authorAccess) throws javax.swing.text.BadLocationException
Create an AuthorDocumentFragment for a paste or DnD purpose- Specified by:
handleCreateDocumentFragment
in interfaceAuthorSchemaAwareEditingHandler
- Parameters:
startOffset
- Start offset of fragmentendOffset
- End offset of fragmentcreationPurposeID
- One of the CREATE_FRAGMENT_* constants in this class.authorAccess
- Access to the Author API.- Returns:
- The created fragment or null if the event was not handled.
- Throws:
javax.swing.text.BadLocationException
- Since:
- 12.1
- See Also:
AuthorSchemaAwareEditingHandler.handleCreateDocumentFragment(int, int, int, ro.sync.ecss.extensions.api.AuthorAccess)
-
handleDeleteNodes
public boolean handleDeleteNodes(AuthorNode[] nodes, int deleteType, AuthorAccess authorAccess) throws InvalidEditException
Description copied from interface:AuthorSchemaAwareEditingHandler
Handle a delete nodes event coming from the Outline or Bread crumb.- Specified by:
handleDeleteNodes
in interfaceAuthorSchemaAwareEditingHandler
- Parameters:
nodes
- The nodes to delete.deleteType
-ACTION_ID_DELETE
if the nodes were deleted directly by the user orACTION_ID_DND
if the nodes were deleted as a result of a drag and drop move operation in the Outline.authorAccess
- Access class to the author functions.- Returns:
true
if the event was handled.- Throws:
InvalidEditException
- This is an invalid edit and must be rejected.- See Also:
AuthorSchemaAwareEditingHandler.handleDeleteNodes(ro.sync.ecss.extensions.api.node.AuthorNode[], int, ro.sync.ecss.extensions.api.AuthorAccess)
-
handleTypingFallback
public boolean handleTypingFallback(int offset, char ch, AuthorAccess authorAccess) throws InvalidEditException
Description copied from interface:AuthorSchemaAwareEditingHandler
Give 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:
handleTypingFallback
in interfaceAuthorSchemaAwareEditingHandler
- Parameters:
offset
- Offset where the typing occurred.ch
- The typed character.authorAccess
- Access class to the author functions.- Returns:
true
if the typing was handled.- Throws:
InvalidEditException
- This is an invalid edit and must be rejected.- See Also:
AuthorSchemaAwareEditingHandler.handleTypingFallback(int, char, ro.sync.ecss.extensions.api.AuthorAccess)
-
changeElementsToMoveUpDown
public boolean changeElementsToMoveUpDown(java.util.List<AuthorNode> selectedElements)
Determine the elements that should be moved by the Move Up/Down operation. For example if the current selected element is atitle
then the element that should actually be moved is its parent (e.g.section
for DocBook).- 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 atitle
then the element that should actually be present in this list is its parent (e.g.section
for DocBook).- Returns:
true
if the list of elements to be moved was altered by the framework specific handler.- Since:
- 15.2
-
getAncestorDetectionOptions
public AuthorSchemaAwareEditingHandlerAdapter.WrapInAncestorsOptions getAncestorDetectionOptions()
One 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.- Returns:
- Preferences for choosing the best possible ancestors while building a path.
- Since:
- 18
-
canBeReplaced
public boolean canBeReplaced(AuthorNode nodeToReplace)
When pasting an element inside an empty element with the same name, a possible solution is to replace the empty node with the new one. This callback has a chance of rejecting this behavior when, for example, the node to replace has important attributes set on it.- Parameters:
nodeToReplace
- The node to replace.- Returns:
true
if this node can be replaced by the strategy with a similar one.false
if this node is important and must be kept in the document.- Since:
- 18
-
getPreferredElement
public javax.xml.namespace.QName 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.- 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
.
-
-