Class InsertListOperation
java.lang.Object
ro.sync.ecss.extensions.commons.operations.InsertListOperation
- All Implemented Interfaces:
AuthorOperation
,Extension
- Direct Known Subclasses:
DITAInsertListOperation
,DocbookInsertListOperation
,TEIInsertListOperation
,XHTMLInsertListOperation
@API(type=INTERNAL,
src=PUBLIC)
public abstract class InsertListOperation
extends Object
implements AuthorOperation
Operation used to convert a selection to an ordered/unordered list.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthorAccess
The author access.static final String
Argument that controls whether the action inserts a new list or converts the element at caret if no selection is made.protected static final ArgumentDescriptor
Schema aware argument.static final String
Argument that controls the type of the list that will be inserted.protected String
The new list type.protected static final ArgumentDescriptor
Schema aware argument.Fields inherited from interface ro.sync.ecss.extensions.api.AuthorOperation
NAMESPACE_ARGUMENT, NAMESPACE_ARGUMENT_DESCRIPTOR, SCHEMA_AWARE_ARGUMENT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
doOperation
(AuthorAccess authorAccess, ArgumentsMap args) Perform the actual operation.protected abstract CommonsOperationsUtil.ConversionElementHelper
Get the conversion element checker.getElementAtCaretToConvert
(AuthorAccess authorAccess, CommonsOperationsUtil.ConversionElementHelper helper) Returns the element at caret that is suitable to be converted.protected abstract String
getListTypeDescription
(String listType) Obtain the name of every list type.protected abstract StringBuilder
getListXMLFragment
(String listType, Map<String, String> listAttributes, int numberOfListItems, AuthorAccess authorAccess) Get list XML fragment.protected abstract String
Get namespace.protected abstract String
getParentListType
(AuthorNode node) Get the type of the list in which the new list will be inserted.protected abstract String
getXMLFragment
(AuthorAccess authorAccess, String listType, String parentListType) Get XML fragment to be inserted when nothing is selected.protected abstract void
insertContent
(AuthorAccess authorAccess, AuthorNode listNode, List<CommonsOperationsUtil.SelectedFragmentInfo> selectedFragmentsInfos) Insert content.protected abstract boolean
isList
(AuthorNode node) Checks if the given node is a list.protected boolean
isListElement
(AuthorNode node) Checks if the given node is a list element or list item.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.AuthorOperation
getArguments
Methods inherited from interface ro.sync.ecss.extensions.api.Extension
getDescription
-
Field Details
-
SCHEMA_AWARE_ARGUMENT_DESCRIPTOR
Schema aware argument. -
CONVERT_ELEMENT_AT_CARET_ARGUMENT
Argument that controls whether the action inserts a new list or converts the element at caret if no selection is made.- See Also:
-
CONVERT_ELEMENT_AT_CARET_ARGUMENT_DESCRIPTOR
Schema aware argument. -
LIST_TYPE_ARGUMENT
Argument that controls the type of the list that will be inserted.- See Also:
-
authorAccess
The author access. -
listType
The new list type.
-
-
Constructor Details
-
InsertListOperation
public InsertListOperation()
-
-
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:
-
getElementAtCaretToConvert
public Optional<AuthorNode> getElementAtCaretToConvert(AuthorAccess authorAccess, CommonsOperationsUtil.ConversionElementHelper helper) Returns the element at caret that is suitable to be converted.- Parameters:
authorAccess
- The author access.helper
- Used to check if the elements from selection can be converted in other elements (table cells or list entries)- Returns:
- The element to convert.
-
isListElement
Checks if the given node is a list element or list item.- Parameters:
node
- The element to check.- Returns:
true
if the node is a list element.
-
isList
Checks if the given node is a list.- Parameters:
node
- The element to check.- Returns:
true
if the node is a list.
-
getParentListType
Get the type of the list in which the new list will be inserted. Can benull
.- Parameters:
node
- The node at offset.- Returns:
- the type of the list in which the new list will be inserted. Can be
null
.
-
getConversionElementsChecker
Get the conversion element checker.- Returns:
- The conversion element checker.
-
insertContent
protected abstract void insertContent(AuthorAccess authorAccess, AuthorNode listNode, List<CommonsOperationsUtil.SelectedFragmentInfo> selectedFragmentsInfos) Insert content.- Parameters:
authorAccess
- The author access.listNode
- The list node.selectedFragmentsInfos
- The fragments to be inserted.
-
getNamespace
Get namespace.- Returns:
- The namespace to be used at insertion.
-
getXMLFragment
protected abstract String getXMLFragment(AuthorAccess authorAccess, String listType, String parentListType) Get XML fragment to be inserted when nothing is selected.- Parameters:
authorAccess
- The author access.listType
- The type of the list to be inserted.parentListType
- The type of the parent list, can benull
- Returns:
- the fragment to be inserted.
-
getListXMLFragment
protected abstract StringBuilder getListXMLFragment(String listType, Map<String, String> listAttributes, int numberOfListItems, AuthorAccess authorAccess) Get list XML fragment.- Parameters:
listType
- The list type.listAttributes
- The attributes to add to list items.numberOfListItems
- The number of list items.authorAccess
- The author access.- Returns:
- The list XML fragment.
-
getListTypeDescription
Obtain the name of every list type.- Parameters:
listType
- The list type.- Returns:
- A string representing the name of the given list type.
-