Class AbstractTableOperation
- java.lang.Object
-
- ro.sync.ecss.extensions.commons.table.operations.AbstractTableOperation
-
- All Implemented Interfaces:
AuthorOperation
,Extension
- Direct Known Subclasses:
DeleteColumnOperationBase
,DeleteRowOperationBase
,InsertColumnOperationBase
,InsertRowOperationBase
,InsertTableOperation
,JoinCellAboveBelowOperationBase
,JoinOperationBase
,JoinRowCellsOperationBase
,SplitCellAboveBelowOperationBase
,SplitLeftRightOperationBase
,SplitOperationBase
@API(type=INTERNAL, src=PUBLIC) public abstract class AbstractTableOperation extends java.lang.Object implements AuthorOperation
Base class for table operations.
-
-
Field Summary
Fields Modifier and Type Field Description static ArgumentDescriptor
CHANGE_TRACKING_BEHAVIOR_ARGUMENT
Argument descriptor for change tracking behavior.static ArgumentDescriptor
TABLE_INFO_ARGUMENT_DESCRIPTOR
Argument descriptor for a table info argument.static java.lang.String
TABLE_INFO_ARGUMENT_NAME
The name of the table info argument.protected AuthorTableHelper
tableHelper
Table helper, has methods specific to each document type.-
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 AbstractTableOperation(AuthorTableHelper authorTableHelper)
Constructor.AbstractTableOperation(AuthorTableHelper authorTableHelper, boolean markAsChange)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected AuthorDocumentFragment
createEmptyCell(AuthorAccess authorAccess, AuthorElement cell, java.lang.String[] skippedAttributes)
Create anAuthorDocumentFragment
representing an empty cell by duplicating the given cell without its content and skipping the specified attributes.void
doOperation(AuthorAccess authorAccess, ArgumentsMap args)
Perform the actual operation.protected abstract void
doOperationInternal(AuthorAccess authorAccess, ArgumentsMap args)
Perform the actual operation.protected int
findCellInsertionOffset(AuthorAccess authorAccess, AuthorElement tableElement, int row, int column)
Find the offset in the document where a new entry (table cell) should be inserted for the given table row and column.protected AuthorElement
getElementAncestor(AuthorNode node, int type)
Search for an ancestorAuthorNode
with the specified type.protected boolean
isElement(AuthorNode node, java.lang.String elemLocalName)
Test if a givenAuthorNode
is an element and has the a specific local name.protected boolean
isTableElement(AuthorNode node, int type)
Test if anAuthorNode
is an element and it has one of the following types:AuthorTableHelper.TYPE_CELL
,AuthorTableHelper.TYPE_ROW
orAuthorTableHelper.TYPE_TABLE
.-
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
-
CHANGE_TRACKING_BEHAVIOR_ARGUMENT
public static final ArgumentDescriptor CHANGE_TRACKING_BEHAVIOR_ARGUMENT
Argument descriptor for change tracking behavior.
-
TABLE_INFO_ARGUMENT_NAME
public static final java.lang.String TABLE_INFO_ARGUMENT_NAME
The name of the table info argument.- See Also:
- Constant Field Values
-
TABLE_INFO_ARGUMENT_DESCRIPTOR
public static final ArgumentDescriptor TABLE_INFO_ARGUMENT_DESCRIPTOR
Argument descriptor for a table info argument.
-
tableHelper
protected AuthorTableHelper tableHelper
Table helper, has methods specific to each document type.
-
-
Constructor Detail
-
AbstractTableOperation
public AbstractTableOperation(AuthorTableHelper authorTableHelper)
Constructor.- Parameters:
authorTableHelper
- Table helper, has methods specific to each document type.
-
AbstractTableOperation
public AbstractTableOperation(AuthorTableHelper authorTableHelper, boolean markAsChange)
Constructor.- Parameters:
authorTableHelper
- Table helper, has methods specific to each document type.markAsChange
-true
if the operation result is marked as a change.
-
-
Method Detail
-
getElementAncestor
protected AuthorElement getElementAncestor(AuthorNode node, int type)
Search for an ancestorAuthorNode
with the specified type.- Parameters:
node
- The starting node.type
- The type of the ancestor.- Returns:
- The ancestor node of the given
node
or thenode
itself if the type matches.
-
isElement
protected boolean isElement(AuthorNode node, java.lang.String elemLocalName)
Test if a givenAuthorNode
is an element and has the a specific local name.- Parameters:
node
- TheAuthorNode
to be checked.elemLocalName
- The local name of the element.- Returns:
true
if the givenAuthorNode
is an element and its local name matches the given string.
-
isTableElement
protected boolean isTableElement(AuthorNode node, int type)
Test if anAuthorNode
is an element and it has one of the following types:AuthorTableHelper.TYPE_CELL
,AuthorTableHelper.TYPE_ROW
orAuthorTableHelper.TYPE_TABLE
.- Parameters:
node
- The node to be checked.type
- The type to search for.- Returns:
true
if thenode
is an element with the specified type.
-
findCellInsertionOffset
protected int findCellInsertionOffset(AuthorAccess authorAccess, AuthorElement tableElement, int row, int column)
Find the offset in the document where a new entry (table cell) should be inserted for the given table row and column.- Parameters:
authorAccess
- The author access. Provides access to specific informations and actions for editor, document, workspace, tables, change tracking, utilitytableElement
- The element rendered as a table. Its 'display' CSS property is set to 'table'.row
- The table row where the insertion will occur, 0 based.column
- The column where the insertion will occur, 0 based.- Returns:
- The offset where the new entry should be inserted.
-
createEmptyCell
protected AuthorDocumentFragment createEmptyCell(AuthorAccess authorAccess, AuthorElement cell, java.lang.String[] skippedAttributes) throws javax.swing.text.BadLocationException
Create anAuthorDocumentFragment
representing an empty cell by duplicating the given cell without its content and skipping the specified attributes.- Parameters:
authorAccess
- The author access. Provides access to specific informations and actions for editor, document, workspace, tables, change tracking, utilitycell
- The reference cell.skippedAttributes
- The attributes which should not be copied.- Returns:
- The document fragment representing the empty cell created starting from the original cell.
- Throws:
javax.swing.text.BadLocationException
- When the fragment cannot be created.
-
doOperation
public final 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)
-
doOperationInternal
protected abstract void doOperationInternal(AuthorAccess authorAccess, ArgumentsMap args) throws AuthorOperationException
Perform the actual operation.- 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:
java.lang.IllegalArgumentException
- Thrown when one or more arguments are illegal.AuthorOperationException
- Thrown when the operation fails.
-
-