@API(type=INTERNAL,
src=PUBLIC)
public class TableOperationsUtil
extends java.lang.Object
Constructor and Description |
---|
TableOperationsUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
areOtherTablesThanChoicetableAllowed(AuthorAccess authorAccess)
Check if a table other than choicetable is allowed here.
|
static void |
computeElementsList(java.util.List<AuthorElement> elementsList,
AuthorElement node,
int startOffset,
int endOffset,
int type,
boolean fullySelected,
TableHelper tableHelper)
Computes all the nodes of the given type starting from the given node, which are
in the given selection.
|
static java.lang.String |
createCellXMLFragment(AuthorAccess authorAccess,
AuthorDocumentFragment[] fragments,
boolean cellsFragment,
java.lang.String cellElementName,
int currentFragmentIndex,
java.lang.String namespace,
AuthorTableHelper authorTableHelper,
java.lang.String... imposedAttributesFragments)
Create a cell fragment for a specific offset, having the name of the cell and
a source fragment from which the attributes and content must be copied.
|
static TableHelper |
createTableHelper(AuthorTableHelper authorTableHelper)
Create a
TableHelper starting from an AuthorTableHelper . |
static java.util.Map<AuthorElement,java.util.Set<java.lang.Integer>> |
getCellIndexes(java.util.List<AuthorElement> cells,
AuthorAccess authorAccess,
TableHelper tableHelper,
boolean isCals)
Obtain the indexes for selected cells.
|
static void |
getChildElements(AuthorElement node,
int type,
java.util.List<AuthorElement> children,
TableHelper tableHelper)
* Obtain a list of children with the given type.
|
static java.lang.String |
getContentFromFragment(AuthorAccess authorAccess,
boolean cellsFragment,
AuthorDocumentFragment fragment)
Get the given fragment content.
|
static AuthorElement |
getElementAncestor(AuthorNode node,
int type,
TableHelper tableHelper)
Search for an ancestor
AuthorNode with the specified type. |
static AuthorElement |
getTableElementContainingOffset(int offset,
AuthorAccess access,
java.lang.String... tableClassValues)
Returns the element representing the table that contains the given offset and
has the given properties (name, class attribute).
|
static AuthorElement |
getTableElementContainingOffset(int offset,
java.lang.String namespace,
AuthorAccess access,
java.lang.String... tableElementNames)
Returns the element representing the table that contains the given offset and
has the given properties (name, namespace).
|
static java.util.List<AuthorElement> |
getTableElementsOfType(AuthorAccess authorAccess,
java.util.List<java.lang.Integer[]> selections,
int type,
TableHelper tableHelper)
Collects all the table elements having the given type, determined by the selection intervals.
|
static java.util.List<AuthorElement> |
getTableElementsOfTypeFromSelection(AuthorAccess authorAccess,
int type,
TableHelper tableHelper,
AuthorElement tableElement)
Collects all the table elements having the given type, determined by the selection intervals.
|
static boolean |
isChoiceTableAllowed(AuthorAccess authorAccess)
Check if a choice table can be inserted in the current context.
|
static boolean |
isIgnoredAttribute(java.lang.String attrName,
AuthorTableHelper tableHelper)
Check if the attribute should be ignored.
|
static boolean |
isPropertiesTableGlobalElement(AuthorAccess authorAccess)
Check if a properties table is allowed as a global element.
|
static boolean |
nodeHasProperties(AuthorNode node,
java.lang.String name,
java.lang.String namespace)
Check if the node has the given namespace and name
|
static void |
placeCaretInFirstCell(AuthorAccess authorAccess,
TableInfo tableInfo,
AuthorDocumentController controller,
SchemaAwareHandlerResult result)
Place the caret in the first cell of a table that was just inserted (a result of this operation
is send as parameter)
|
public static java.lang.String createCellXMLFragment(AuthorAccess authorAccess, AuthorDocumentFragment[] fragments, boolean cellsFragment, java.lang.String cellElementName, int currentFragmentIndex, java.lang.String namespace, AuthorTableHelper authorTableHelper, java.lang.String... imposedAttributesFragments) throws AuthorOperationException
authorAccess
- The author access.fragments
- The list of all content fragments.cellsFragment
- true
if the fragments represents cells.cellElementName
- The cell name.currentFragmentIndex
- The index of the fragment that must be used for attributes and content.namespace
- The cell namespace.authorTableHelper
- Author table helper.imposedAttributesFragments
- Imposed attributes for the created cell.
Each fragment has the following form: "attribute_name=\"attribute_value\""AuthorOperationException
public static boolean isIgnoredAttribute(java.lang.String attrName, AuthorTableHelper tableHelper)
attrName
- The attribute name.tableHelper
- Author table helpertrue
if the attribute should be ignored.public static java.lang.String getContentFromFragment(AuthorAccess authorAccess, boolean cellsFragment, AuthorDocumentFragment fragment)
true
,
the returned content represent the content of the cell, otherwise the fragment itself.authorAccess
- The author access.cellsFragment
- true
if the fragment represent a cell fragmentfragment
- The Author fragment.public static boolean nodeHasProperties(AuthorNode node, java.lang.String name, java.lang.String namespace)
node
- The node to check.name
- The name to compare the node name with.namespace
- The namespace to compare the node namespace with.true
if the node has the given namespace and name.public static AuthorElement getTableElementContainingOffset(int offset, AuthorAccess access, java.lang.String... tableClassValues)
offset
- The offset to search the parent table element for.access
- Access to Author operations.tableClassValues
- Possible table class attributes values.public static AuthorElement getTableElementContainingOffset(int offset, java.lang.String namespace, AuthorAccess access, java.lang.String... tableElementNames)
offset
- The offset to search the parent table element for.namespace
- The table node namespace.access
- Access to Author operations.tableElementNames
- Possible table element names.public static boolean isChoiceTableAllowed(AuthorAccess authorAccess)
authorAccess
- The author access.true
if a choice table can be inserted in the given context.public static boolean areOtherTablesThanChoicetableAllowed(AuthorAccess authorAccess)
authorAccess
- The author access.true
if a choice table can be inserted in the given context.public static boolean isPropertiesTableGlobalElement(AuthorAccess authorAccess)
authorAccess
- The author access.true
if the "properties" table element is a global element of the schema.public static java.util.List<AuthorElement> getTableElementsOfTypeFromSelection(AuthorAccess authorAccess, int type, TableHelper tableHelper, AuthorElement tableElement)
authorAccess
- The author accesstype
- The type of the elements to be collected.
Can be one of TYPE_ prefixed constants from TableHelperConstants
.tableHelper
- Utility class to determine information about table nodes.tableElement
- The table parent elements.public static java.util.List<AuthorElement> getTableElementsOfType(AuthorAccess authorAccess, java.util.List<java.lang.Integer[]> selections, int type, TableHelper tableHelper)
authorAccess
- The author accessselections
- The currently selected nodes. They can be mixed.type
- The type of the elements to be collected.
Can be one of TYPE_ prefixed constants from TableHelperConstants
.tableHelper
- Utility class to determine information about table nodes.public static void computeElementsList(java.util.List<AuthorElement> elementsList, AuthorElement node, int startOffset, int endOffset, int type, boolean fullySelected, TableHelper tableHelper)
elementsList
- The list which will contain the elements.node
- The starting node.startOffset
- Selection start.endOffset
- Selection end.type
- The elements type.
Can be one of TYPE_ prefixed constants from TableHelperConstants
.fullySelected
- true
if the nodes should be entire contained by the selection.tableHelper
- Utility class to determine information about table nodes.public static AuthorElement getElementAncestor(AuthorNode node, int type, TableHelper tableHelper)
AuthorNode
with the specified type.node
- The starting node.type
- The type of the ancestor.tableHelper
- Utility class to determine information about table nodes.node
or the node
itself if the type matches.public static void getChildElements(AuthorElement node, int type, java.util.List<AuthorElement> children, TableHelper tableHelper)
node
- The parent node.type
- The child elements type.
Can be one of TYPE_ prefixed constants from TableHelperConstants
.children
- The list with collected children. Empty when the function is called.tableHelper
- Utility class to determine information about table nodes.public static java.util.Map<AuthorElement,java.util.Set<java.lang.Integer>> getCellIndexes(java.util.List<AuthorElement> cells, AuthorAccess authorAccess, TableHelper tableHelper, boolean isCals)
cells
- The selected cells.authorAccess
- The author access.tableHelper
- Utility class to determine information about table nodes.isCals
- true
if it is a CALS tablepublic static TableHelper createTableHelper(AuthorTableHelper authorTableHelper)
TableHelper
starting from an AuthorTableHelper
.authorTableHelper
- The Author table helperTableHelper
public static void placeCaretInFirstCell(AuthorAccess authorAccess, TableInfo tableInfo, AuthorDocumentController controller, SchemaAwareHandlerResult result)
authorAccess
- Author access.tableInfo
- Table information.controller
- Controller.result
- Insert operation result.© Copyright SyncRO Soft SRL 2002 - 2016. All rights reserved.