Class SortOperation
- java.lang.Object
-
- ro.sync.ecss.extensions.commons.sort.SortOperation
-
- All Implemented Interfaces:
AuthorOperation
,Extension
- Direct Known Subclasses:
DITAListSortOperation
,DocbookListSortOperation
,TableSortOperation
,TEIListSortOperation
,XHTMLListSortOperation
@API(type=INTERNAL, src=PUBLIC) public abstract class SortOperation extends java.lang.Object implements AuthorOperation
Sort operations base class.
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorAccess
authorAccess
The Author access.protected static java.lang.String
COLUMN
String used in the default name for the sorting criterion.-
Fields inherited from interface ro.sync.ecss.extensions.api.AuthorOperation
NAMESPACE_ARGUMENT, NAMESPACE_ARGUMENT_DESCRIPTOR, SCHEMA_AWARE_ARGUMENT, SCHEMA_AWARE_ARGUMENT_DESCRIPTOR
-
-
Constructor Summary
Constructors Constructor Description SortOperation(java.lang.String selElementsString, java.lang.String allElementsString)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
canBeSorted(AuthorElement parent, int[] selectedNonIgnoredChildrenInterval)
Check if the parent element selected children can be sorted.void
doOperation(AuthorAccess authorAccess, ArgumentsMap args)
Perform the actual operation.protected boolean
forceSortAll()
ArgumentDescriptor[]
getArguments()
java.lang.String
getDescription()
protected java.lang.String
getHelpPageID()
Get the ID of the help page which will be called by the end user.protected java.util.List<AuthorNode>
getNonIgnoredChildren(AuthorElement parent)
Returns a list of non ignored children.int[]
getSelectedNonIgnoredChildrenInterval(AuthorElement parent)
Return the interval of sortable nodes indices covered by selection.abstract java.util.List<CriterionInformation>
getSortCriteria(AuthorElement parent)
Obtain the sort criterion.abstract java.lang.String[]
getSortKeysValues(AuthorNode node, SortCriteriaInformation sortInfo)
Obtain the values of the keys that can be used for sorting.abstract AuthorElement
getSortParent(int offset, AuthorAccess authorAccess)
Obtain the parent node of all the nodes which will be sorted.protected java.lang.String
getTextContentToSort(AuthorNode node)
Given a node obtain the content to be used during the sort operation.abstract boolean
isIgnored(AuthorNode node)
Checks if a given node is ignored when sorting.
-
-
-
Field Detail
-
COLUMN
protected static final java.lang.String COLUMN
String used in the default name for the sorting criterion.- See Also:
- Constant Field Values
-
authorAccess
protected AuthorAccess authorAccess
The Author access.
-
-
Method Detail
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
Extension.getDescription()
-
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)
-
canBeSorted
public abstract void canBeSorted(AuthorElement parent, int[] selectedNonIgnoredChildrenInterval) throws AuthorOperationException
Check if the parent element selected children can be sorted. For example a table row containing a cell with rowspan cannot be sorted and stops the operation.- Parameters:
parent
- The parent of the elements which will be sorted.selectedNonIgnoredChildrenInterval
- The interval of selected children indices.- Throws:
AuthorOperationException
- When the given node is not sortable. For example a table row containing a cell with multiple rowspan stops the operation.
-
getSelectedNonIgnoredChildrenInterval
public int[] getSelectedNonIgnoredChildrenInterval(AuthorElement parent)
Return the interval of sortable nodes indices covered by selection.- Parameters:
parent
- The parent node for the sortable nodes.- Returns:
- An interval of sortable nodes indices that can be sorted.
Typically it returns a non-null interval when the selected sortable nodes from parent are part of a continuous sequence.
If the selection must be ignored or the sequence of selected nodes is discontinuous it returns
null
.
-
forceSortAll
protected boolean forceSortAll()
- Returns:
true
if the sort operation should not use the selected element and should always sort all elements.
-
getNonIgnoredChildren
protected java.util.List<AuthorNode> getNonIgnoredChildren(AuthorElement parent)
Returns a list of non ignored children.- Parameters:
parent
- The parent node.- Returns:
- A list of non ignored children.
-
getSortParent
public abstract AuthorElement getSortParent(int offset, AuthorAccess authorAccess) throws AuthorOperationException
Obtain the parent node of all the nodes which will be sorted.- Parameters:
offset
- The offset where the operation was invoked.authorAccess
- TheAuthorAccess
.- Returns:
- The parent node of the nodes which will be sorted.
- Throws:
AuthorOperationException
- When the offset is negative or greater than the content length.
-
isIgnored
public abstract boolean isIgnored(AuthorNode node)
Checks if a given node is ignored when sorting.- Parameters:
node
- The node to be checked.- Returns:
true
if the given node is ignored when sorting.
-
getSortKeysValues
public abstract java.lang.String[] getSortKeysValues(AuthorNode node, SortCriteriaInformation sortInfo) throws AuthorOperationException
Obtain the values of the keys that can be used for sorting.- Parameters:
node
- The element which will be sorted.sortInfo
- The sort information corresponding to the user choice.- Returns:
- an array containing the values of the keys which can be used for sorting.
- Throws:
AuthorOperationException
- If the text content cannot be obtained.
-
getSortCriteria
public abstract java.util.List<CriterionInformation> getSortCriteria(AuthorElement parent) throws AuthorOperationException
Obtain the sort criterion.- Parameters:
parent
- The parent node of the nodes which will be sorted.- Returns:
- A
SortCriteriaInformation
containing theCriterionInformation
objects. - Throws:
AuthorOperationException
-
getArguments
public ArgumentDescriptor[] getArguments()
- Specified by:
getArguments
in interfaceAuthorOperation
- Returns:
- An array of
ArgumentDescriptor
representing the arguments this operation uses. - See Also:
AuthorOperation.getArguments()
-
getTextContentToSort
protected java.lang.String getTextContentToSort(AuthorNode node)
Given a node obtain the content to be used during the sort operation. In general this text does not contain the deleted changes and the leading or trailing spaces.- Parameters:
node
- The node to get the value for.- Returns:
- The test to be considered as sort key value.
-
getHelpPageID
protected java.lang.String getHelpPageID()
Get the ID of the help page which will be called by the end user.- Returns:
- the ID of the help page which will be called by the end user or
null
.
-
-