Class ToggleSurroundWithElementOperation
java.lang.Object
ro.sync.ecss.extensions.commons.operations.ToggleSurroundWithElementOperation
- All Implemented Interfaces:
AuthorOperation
,Extension
@API(type=INTERNAL,
src=PUBLIC)
public class ToggleSurroundWithElementOperation
extends Object
implements AuthorOperation
Toggle "surround with element" operation.
Case 1: If there is no selection in the document:
- if the caret is inside a word
then the word is wrapped in the given element (or unwrapped if it is already included in the element)
- else the element is inserted at caret position.
Case 2: If there is a selection, it is wrapped in the given element
(or unwrapped if it is already included in the element)
-
Field Summary
FieldsFields inherited from interface ro.sync.ecss.extensions.api.AuthorOperation
NAMESPACE_ARGUMENT, NAMESPACE_ARGUMENT_DESCRIPTOR, SCHEMA_AWARE_ARGUMENT, SCHEMA_AWARE_ARGUMENT_DESCRIPTOR
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
doOperation
(AuthorAccess authorAccess, ArgumentsMap args) Perform the actual operation.static AuthorElement[]
getElementsPath
(AuthorDocumentFragment fragment) Given a document fragment it returns the path of elements until the first leaf.static List<int[]>
getEquiIntervalFromMarker
(AuthorAccess authorAccess, int[] interval) If the given interval is not balanced (balanced = starts and ends in the same element) it will be split into multiple balanced intervals.
-
Field Details
-
ARGUMENT_ELEMENT
The element argument.- See Also:
-
-
Constructor Details
-
ToggleSurroundWithElementOperation
public ToggleSurroundWithElementOperation()
-
-
Method Details
-
doOperation
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args) throws AuthorOperationException Description copied from interface:AuthorOperation
Perform the actual operation. You can check if the operation was invoked from the oXygen standalone application or from the oXygen plugin for Eclipse by using the method:ApplicationInformationAccess.getPlatform()
. To get to theWorkspace
you may use:AuthorAccess.getWorkspaceAccess()
.- Specified by:
doOperation
in interfaceAuthorOperation
- Parameters:
authorAccess
- The author access. Provides access to specific informations and actions for editor, document, workspace, tables, change tracking, utility a.s.o.args
- The map of arguments. All the arguments defined by methodAuthorOperation.getArguments()
must be present in the map of arguments.- Throws:
AuthorOperationException
- Thrown when the operation fails.- See Also:
-
getArguments
- Specified by:
getArguments
in interfaceAuthorOperation
- Returns:
- An array of
ArgumentDescriptor
representing the arguments this operation uses. - See Also:
-
getDescription
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
-
getElementsPath
Given a document fragment it returns the path of elements until the first leaf.- Parameters:
fragment
- The document fragment to check.- Returns:
- The path of elements to first leaf.
-
getEquiIntervalFromMarker
public static List<int[]> getEquiIntervalFromMarker(AuthorAccess authorAccess, int[] interval) throws BadLocationException If the given interval is not balanced (balanced = starts and ends in the same element) it will be split into multiple balanced intervals.- Parameters:
authorAccess
- Author access.interval
- The interval to split..- Returns:
- The list of intervals.
- Throws:
BadLocationException
-