Class DefaultUniqueAttributesRecognizer
- java.lang.Object
-
- ro.sync.ecss.extensions.commons.id.DefaultUniqueAttributesRecognizer
-
- All Implemented Interfaces:
AuthorExtensionStateListener
,ClipboardFragmentProcessor
,Extension
,UniqueAttributesProcessor
,UniqueAttributesRecognizer
- Direct Known Subclasses:
DITAUniqueAttributesRecognizer
,DocBookUniqueAttributesRecognizer
,TEIP5UniqueAttributesRecognizer
,XHTMLUniqueAttributesRecognizer
@API(type=INTERNAL, src=PUBLIC) public class DefaultUniqueAttributesRecognizer extends java.lang.Object implements UniqueAttributesRecognizer, ClipboardFragmentProcessor
Default unique attributes recognizer
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorAccess
authorAccess
The author accessprotected java.lang.String
idAttrQname
The ID attribute qname
-
Constructor Summary
Constructors Constructor Description DefaultUniqueAttributesRecognizer()
Default constructor.DefaultUniqueAttributesRecognizer(java.lang.String idAttrQname)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activated(AuthorAccess authorAccess)
Method called when the Author extension was activated.void
assignUniqueIDs(int startOffset, int endOffset, boolean forceGeneration)
Assigns unique IDs between a start and an end offset in the document.boolean
copyAttributeOnSplit(java.lang.String attrQName, AuthorElement element)
Checks if the attribute specified by QName can be considered as a valid attribute to copy when the element is split.void
deactivated(AuthorAccess authorAccess)
Method called when the Author extension was deactivated.protected java.lang.String
generateUniqueIDFor(java.lang.String idGenerationPattern, AuthorElement element)
Generate an unique ID for an elementprotected GenerateIDElementsInfo
getDefaultOptions()
protected java.lang.String
getDefaultOptionsXMLResourceName()
Get the name of the XML resource from which to load the default options.java.lang.String
getDescription()
protected java.lang.String
getGenerateIDAttributeQName(AuthorElement element, java.lang.String[] elemsWithAutoGeneration, boolean forceGeneration)
GenerateIDElementsInfo
getGenerateIDElementsInfo()
boolean
isAutoIDGenerationActive()
protected boolean
preserveIDsWhenPastingBetweenResources(int fragmentPurpose)
Check if we should preserve IDs when pasting between resources.void
process(ClipboardFragmentInformation fragmentInformation)
Process a fragment in the clipboard before inserting it in the document.
-
-
-
Field Detail
-
idAttrQname
protected java.lang.String idAttrQname
The ID attribute qname
-
authorAccess
protected AuthorAccess authorAccess
The author access
-
-
Method Detail
-
copyAttributeOnSplit
public boolean copyAttributeOnSplit(java.lang.String attrQName, AuthorElement element)
Description copied from interface:UniqueAttributesProcessor
Checks if the attribute specified by QName can be considered as a valid attribute to copy when the element is split.- Specified by:
copyAttributeOnSplit
in interfaceUniqueAttributesProcessor
- Parameters:
attrQName
- The attribute qualified name.element
- The element.- Returns:
true
if the attribute should be copied when Split is performed.- See Also:
UniqueAttributesProcessor.copyAttributeOnSplit(java.lang.String, ro.sync.ecss.extensions.api.node.AuthorElement)
-
activated
public void activated(AuthorAccess authorAccess)
Description copied from interface:AuthorExtensionStateListener
Method called when the Author extension was activated. This event is triggered when the Author extension where this listener is defined was activated in relation with a document opened in Author page. Listeners likeAuthorMouseListener
orAuthorListener
can be added at this point.- Specified by:
activated
in interfaceAuthorExtensionStateListener
- Parameters:
authorAccess
- TheAuthorAccess
of the Author page where the listener was activated.- See Also:
AuthorExtensionStateListener.activated(ro.sync.ecss.extensions.api.AuthorAccess)
-
deactivated
public void deactivated(AuthorAccess authorAccess)
Description copied from interface:AuthorExtensionStateListener
Method called when the Author extension was deactivated. This event is triggered when another Author extension corresponding to the the current document opened in Author page was activated, the user switches to another editor page or the editor is closed.- Specified by:
deactivated
in interfaceAuthorExtensionStateListener
- Parameters:
authorAccess
- TheAuthorAccess
of the Author page where the listener was deactivated.- See Also:
AuthorExtensionStateListener.deactivated(ro.sync.ecss.extensions.api.AuthorAccess)
-
getDefaultOptions
protected GenerateIDElementsInfo getDefaultOptions()
- Returns:
- The default generation options
-
getDefaultOptionsXMLResourceName
protected java.lang.String getDefaultOptionsXMLResourceName()
Get the name of the XML resource from which to load the default options.- Returns:
- the name of the XML resource from which to load the default options.
-
isAutoIDGenerationActive
public boolean isAutoIDGenerationActive()
- Specified by:
isAutoIDGenerationActive
in interfaceUniqueAttributesRecognizer
- Returns:
- true if auto generation is active and we have elements for which to generate.
-
getGenerateIDAttributeQName
protected java.lang.String getGenerateIDAttributeQName(AuthorElement element, java.lang.String[] elemsWithAutoGeneration, boolean forceGeneration)
- Parameters:
element
- The current element.elemsWithAutoGeneration
- The array of elements for which generation is activatedforceGeneration
- Force ID generation if there is no selection.- Returns:
- The name of the attribute for which to generate the ID or null (default behavior).
-
generateUniqueIDFor
protected java.lang.String generateUniqueIDFor(java.lang.String idGenerationPattern, AuthorElement element)
Generate an unique ID for an element- Parameters:
idGenerationPattern
- The pattern for id generation.element
- The element- Returns:
- The unique ID
-
assignUniqueIDs
public void assignUniqueIDs(int startOffset, int endOffset, boolean forceGeneration)
Description copied from interface:UniqueAttributesProcessor
Assigns unique IDs between a start and an end offset in the document.- Specified by:
assignUniqueIDs
in interfaceUniqueAttributesProcessor
- Parameters:
startOffset
- Start offset.endOffset
- End offset.forceGeneration
-true
to generate ID even if the ID generation pattern list does not match.- See Also:
UniqueAttributesProcessor.assignUniqueIDs(int, int, boolean)
-
getGenerateIDElementsInfo
public GenerateIDElementsInfo getGenerateIDElementsInfo()
- Returns:
- Returns the autoGenerateElementsInfo.
-
process
public void process(ClipboardFragmentInformation fragmentInformation)
Description copied from interface:ClipboardFragmentProcessor
Process a fragment in the clipboard before inserting it in the document.- Specified by:
process
in interfaceClipboardFragmentProcessor
- Parameters:
fragmentInformation
- Information about a fragment in the clipboard.- See Also:
ClipboardFragmentProcessor.process(ro.sync.ecss.extensions.api.content.ClipboardFragmentInformation)
-
preserveIDsWhenPastingBetweenResources
protected boolean preserveIDsWhenPastingBetweenResources(int fragmentPurpose)
Check if we should preserve IDs when pasting between resources.- Parameters:
fragmentPurpose
- The fragment purpose. On of theAuthorSchemaAwareEditingHandler
purposes.- Returns:
true
if we should preserve IDs when pasting between resources. By default the base method returnstrue
.
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
Extension.getDescription()
-
-