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 java.lang.Object implements AuthorOperation
Operation used to convert a selection to an ordered/unordered list.
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorAccess
authorAccess
The author access.static java.lang.String
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.protected static ArgumentDescriptor
CONVERT_ELEMENT_AT_CARET_ARGUMENT_DESCRIPTOR
Schema aware argument.static java.lang.String
LIST_TYPE_ARGUMENT
Argument that controls the type of the list that will be inserted.protected java.lang.String
listType
The new list type.protected static ArgumentDescriptor
SCHEMA_AWARE_ARGUMENT_DESCRIPTOR
Schema aware argument.-
Fields inherited from interface ro.sync.ecss.extensions.api.AuthorOperation
NAMESPACE_ARGUMENT, NAMESPACE_ARGUMENT_DESCRIPTOR, SCHEMA_AWARE_ARGUMENT
-
-
Constructor Summary
Constructors Constructor Description InsertListOperation()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
doOperation(AuthorAccess authorAccess, ArgumentsMap args)
Perform the actual operation.protected abstract CommonsOperationsUtil.ConversionElementHelper
getConversionElementsChecker()
Get the conversion element checker.java.util.Optional<AuthorNode>
getElementAtCaretToConvert(AuthorAccess authorAccess, CommonsOperationsUtil.ConversionElementHelper helper)
Returns the element at caret that is suitable to be converted.protected abstract java.lang.String
getListTypeDescription(java.lang.String listType)
Obtain the name of every list type.protected abstract java.lang.StringBuilder
getListXMLFragment(java.lang.String listType, java.util.Map<java.lang.String,java.lang.String> listAttributes, int numberOfListItems, AuthorAccess authorAccess)
Get list XML fragment.protected abstract java.lang.String
getNamespace()
Get namespace.protected abstract java.lang.String
getParentListType(AuthorNode node)
Get the type of the list in which the new list will be inserted.protected abstract java.lang.String
getXMLFragment(AuthorAccess authorAccess, java.lang.String listType, java.lang.String parentListType)
Get XML fragment to be inserted when nothing is selected.protected abstract void
insertContent(AuthorAccess authorAccess, AuthorNode listNode, java.util.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 Detail
-
SCHEMA_AWARE_ARGUMENT_DESCRIPTOR
protected static final ArgumentDescriptor SCHEMA_AWARE_ARGUMENT_DESCRIPTOR
Schema aware argument.
-
CONVERT_ELEMENT_AT_CARET_ARGUMENT
public static final java.lang.String 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:
- Constant Field Values
-
CONVERT_ELEMENT_AT_CARET_ARGUMENT_DESCRIPTOR
protected static final ArgumentDescriptor CONVERT_ELEMENT_AT_CARET_ARGUMENT_DESCRIPTOR
Schema aware argument.
-
LIST_TYPE_ARGUMENT
public static final java.lang.String LIST_TYPE_ARGUMENT
Argument that controls the type of the list that will be inserted.- See Also:
- Constant Field Values
-
authorAccess
protected AuthorAccess authorAccess
The author access.
-
listType
protected java.lang.String listType
The new list type.
-
-
Method Detail
-
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:
AuthorOperation.doOperation(ro.sync.ecss.extensions.api.AuthorAccess, ro.sync.ecss.extensions.api.ArgumentsMap)
-
getElementAtCaretToConvert
public java.util.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
protected boolean isListElement(AuthorNode node)
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
protected abstract boolean isList(AuthorNode node)
Checks if the given node is a list.- Parameters:
node
- The element to check.- Returns:
true
if the node is a list.
-
getParentListType
protected abstract java.lang.String getParentListType(AuthorNode node)
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
protected abstract CommonsOperationsUtil.ConversionElementHelper getConversionElementsChecker()
Get the conversion element checker.- Returns:
- The conversion element checker.
-
insertContent
protected abstract void insertContent(AuthorAccess authorAccess, AuthorNode listNode, java.util.List<CommonsOperationsUtil.SelectedFragmentInfo> selectedFragmentsInfos)
Insert content.- Parameters:
authorAccess
- The author access.listNode
- The list node.selectedFragmentsInfos
- The fragments to be inserted.
-
getNamespace
protected abstract java.lang.String getNamespace()
Get namespace.- Returns:
- The namespace to be used at insertion.
-
getXMLFragment
protected abstract java.lang.String getXMLFragment(AuthorAccess authorAccess, java.lang.String listType, java.lang.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 java.lang.StringBuilder getListXMLFragment(java.lang.String listType, java.util.Map<java.lang.String,java.lang.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
protected abstract java.lang.String getListTypeDescription(java.lang.String listType)
Obtain the name of every list type.- Parameters:
listType
- The list type.- Returns:
- A string representing the name of the given list type.
-
-