Package ro.sync.ecss.dita
Class DITATextAccess
- java.lang.Object
-
- ro.sync.ecss.dita.DITATextAccess
-
@API(type=NOT_EXTENDABLE, src=PRIVATE) public final class DITATextAccess extends java.lang.Object
Access utility methods to work with DITA in the text editing mode.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.String
buildFigureHrefImageXMLToInsert(WSXMLTextEditorPage textAccess, java.net.URL nodeBaseUrl, java.lang.String title, java.lang.String[] referenceAttributeNameAndValue)
Creates a figure with title and image XML element.static java.lang.String
buildFigureKeyrefImageXMLToInsert(WSXMLTextEditorPage textAccess, java.lang.String figTitle, java.lang.String keyName)
Creates a figure with title and image XML element with a keyref.static java.lang.String
buildNonMediaFragment(java.lang.String[] referenceAttributeNameAndValue, java.lang.String elementName, java.net.URL nodeBaseUrl)
Creates the xml fragment to insert for non media objects.static java.lang.String[]
collectPossibleElements(java.lang.String reqAttr, java.lang.String defaultElementName, WSTextXMLSchemaManager schemaManager, int caretOffset, java.lang.String... classFrag)
Get all the element names that can be inserted at the current caret position and have the class 'classFrag' and a 'reqAttr' attribute.static java.lang.String
computeKeyReferenceElementName(WSXMLTextEditorPage textAccess, ro.sync.ecss.dita.reference.keyref.KeyInfo key, boolean isImage, boolean forceInsertAsVariableKeyref, boolean preferRelatedLinks)
Calculates a suitable reference element to be later inserted for the dropped key.static java.net.URL
getCurrentNodeBaseURL(WSXMLTextEditorPage textAccess)
static ro.sync.ecss.dita.reference.keyref.KeyInfo
getKeyInfo(WSXMLTextEditorPage textPage, java.lang.String fullyQualifiedKeyName)
Get the key info for the fully qualified key name.static java.lang.String
getPossibleElementQName(WSTextXMLSchemaManager schemaManager, java.lang.String clazzFrag, java.lang.String mostUsed)
Obtain the qualified name of the element with the given class, which will be inserted in the document.static java.lang.String
getPreferredKeyRefElementName(WSXMLTextEditorPage textPage, boolean insertImg, boolean insertVariable)
Get the preferred key ref element name.static java.lang.String
getPreferredKeyRefElementName(WSXMLTextEditorPage textPage, ro.sync.ecss.dita.reference.keyref.KeyInfo key)
Get the preferred key ref element name.static java.lang.String
getPreferredKeyRefElementName(WSXMLTextEditorPage textPage, ro.sync.ecss.dita.reference.keyref.KeyInfo key, boolean insertImg)
Deprecated.static UtilAccess
getUtilAccess()
Provides access to generic utility methods.
-
-
-
Method Detail
-
getKeyInfo
public static ro.sync.ecss.dita.reference.keyref.KeyInfo getKeyInfo(WSXMLTextEditorPage textPage, java.lang.String fullyQualifiedKeyName)
Get the key info for the fully qualified key name.- Parameters:
textPage
- The text page access.fullyQualifiedKeyName
- The fully qualified name.- Returns:
- The key info. Can be
null
.
-
getPreferredKeyRefElementName
@Deprecated public static java.lang.String getPreferredKeyRefElementName(WSXMLTextEditorPage textPage, ro.sync.ecss.dita.reference.keyref.KeyInfo key, boolean insertImg)
Deprecated.Get the preferred key ref element name. If the key is reference to an image and the insertImg param is set totrue
, the returned element will be an image element. Please usegetPreferredKeyRefElementName(WSXMLTextEditorPage, boolean, boolean)
}- Parameters:
textPage
- The text page.key
- The keyinsertImg
-true
if the keyref should be an image element.- Returns:
- the preferred key ref element name.
-
getPreferredKeyRefElementName
public static java.lang.String getPreferredKeyRefElementName(WSXMLTextEditorPage textPage, ro.sync.ecss.dita.reference.keyref.KeyInfo key)
Get the preferred key ref element name. If the key has reference to an image, won't insert an image element.- Parameters:
textPage
- The text page.key
- The key- Returns:
- the preferred key ref element name.
-
getPreferredKeyRefElementName
public static java.lang.String getPreferredKeyRefElementName(WSXMLTextEditorPage textPage, boolean insertImg, boolean insertVariable)
Get the preferred key ref element name. If the key is reference to an image and the insertImg param is set totrue
, the returned element will be an image element.- Parameters:
textPage
- The text page.insertImg
-true
if the keyref should be an image element.insertVariable
-true
to insert a variable (ph with keyref).- Returns:
- the preferred key ref element name.
-
collectPossibleElements
public static java.lang.String[] collectPossibleElements(java.lang.String reqAttr, java.lang.String defaultElementName, WSTextXMLSchemaManager schemaManager, int caretOffset, java.lang.String... classFrag)
Get all the element names that can be inserted at the current caret position and have the class 'classFrag' and a 'reqAttr' attribute.- Parameters:
reqAttr
- The required attribute that needs to be on the elementdefaultElementName
- The default element name, returned if no matching element found.schemaManager
- Text page XML schema manager. Provides support for obtaining information about what elements, attributes can be inserted in a given context.caretOffset
- The caret offset.classFrag
- The class fragment to search for in the element.- Returns:
- All the element names that can be inserted at the current caret position and have the class 'classFrag' and a 'reqAttr' attribute
-
getPossibleElementQName
public static java.lang.String getPossibleElementQName(WSTextXMLSchemaManager schemaManager, java.lang.String clazzFrag, java.lang.String mostUsed)
Obtain the qualified name of the element with the given class, which will be inserted in the document.- Parameters:
schemaManager
- Current schema manager.clazzFrag
- The class of the element, whose name is searched.mostUsed
- The most used name of the element with the given class.- Returns:
- The qualified name of the element with the given class.
-
getCurrentNodeBaseURL
public static java.net.URL getCurrentNodeBaseURL(WSXMLTextEditorPage textAccess)
- Parameters:
textAccess
- Contains methods specific to XML editors.- Returns:
- The base url of the node at caret position or
null
.
-
computeKeyReferenceElementName
public static java.lang.String computeKeyReferenceElementName(WSXMLTextEditorPage textAccess, ro.sync.ecss.dita.reference.keyref.KeyInfo key, boolean isImage, boolean forceInsertAsVariableKeyref, boolean preferRelatedLinks)
Calculates a suitable reference element to be later inserted for the dropped key.- Parameters:
textAccess
- Contains methods specific to XML editors.key
- The key to insert.isImage
-true
if the key is an image reference.forceInsertAsVariableKeyref
-true
to force insert a variable (ph with keyref).preferRelatedLinks
-true
to prefer insertion as related links.- Returns:
- Reference element qName to insert or at least a fallback element, never
null
.
-
buildFigureHrefImageXMLToInsert
public static java.lang.String buildFigureHrefImageXMLToInsert(WSXMLTextEditorPage textAccess, java.net.URL nodeBaseUrl, java.lang.String title, java.lang.String[] referenceAttributeNameAndValue)
Creates a figure with title and image XML element.- Parameters:
textAccess
- Offers access to Text page API.nodeBaseUrl
- The base url of the document.title
- The title of the fig.referenceAttributeNameAndValue
- Pair attribute name and value; For example: href, file://filename.pdf.- Returns:
- a figure with title and image XML element.
-
buildFigureKeyrefImageXMLToInsert
public static java.lang.String buildFigureKeyrefImageXMLToInsert(WSXMLTextEditorPage textAccess, java.lang.String figTitle, java.lang.String keyName)
Creates a figure with title and image XML element with a keyref.- Parameters:
textAccess
- Offers access to Text page API.figTitle
- The title of the fig.keyName
- The name of the key.- Returns:
- a figure with title and image XML element with a keyref.
-
buildNonMediaFragment
public static java.lang.String buildNonMediaFragment(java.lang.String[] referenceAttributeNameAndValue, java.lang.String elementName, java.net.URL nodeBaseUrl)
Creates the xml fragment to insert for non media objects.- Parameters:
referenceAttributeNameAndValue
- Pair attribute name and value; For example: href, file://filename.pdf.elementName
- The name of the element to be inserted.nodeBaseUrl
- The value of the base-uri() attribute of the current node.- Returns:
- The XML fragment to insert.
-
getUtilAccess
public static UtilAccess getUtilAccess()
Provides access to generic utility methods.- Returns:
- Access to generic utility methods. or
null
from tests.
-
-