Package com.nomagic.magicdraw.uml
Class RepresentationTextCreator
- java.lang.Object
-
- com.nomagic.magicdraw.uml.DeprecatedRepresentationTextCreator
-
- com.nomagic.magicdraw.uml.RepresentationTextCreator
-
@OpenApiAll public class RepresentationTextCreator extends DeprecatedRepresentationTextCreator
Class for creating text of BaseElements represented in various UI components (tree nodes, text labels and etc).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RepresentationTextCreator.EnvironmentOptionsProjectCacheValidator
private static class
RepresentationTextCreator.RepresentationTextCache
static interface
RepresentationTextCreator.RepresentationTextProvider
Representation text provider extension point.private static class
RepresentationTextCreator.RepTextProviderProjectCacheValidator
Validator, which drops cached values when there are changes in RepresentationTextProvider list.
-
Field Summary
Fields Modifier and Type Field Description private com.nomagic.magicdraw.uml.ElementRepresentationTextCreatorImpl
creatorImpl
private static java.lang.ThreadLocal<RepresentationTextCreator>
LOCAL_TEXT_CREATOR
Every thread which access RepresentationTextCreator will have its own instance.-
Fields inherited from class com.nomagic.magicdraw.uml.DeprecatedRepresentationTextCreator
COLOR_POSTFIX, COLOR_PREFIX, EMPTY_NAME_NOTATION, GRAY_COLOR_STRING
-
-
Constructor Summary
Constructors Constructor Description RepresentationTextCreator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addProvider(RepresentationTextCreator.RepresentationTextProvider provider)
Registers a given representation text provider.static java.lang.String
createDefaultRepresentationText(BaseElement element, RepresentationTextParams textParams)
Gets default (not extended) representation text.private java.lang.String
createDefaultText(BaseElement element, RepresentationTextParams textParams)
static java.util.Comparator<BaseElement>
createRepresentationTextComparator(RepresentationTextParams params)
static java.lang.String
getAbsoluteUMLPathToRoot(Element element)
Method returns string representing path from root element to the given element.static java.util.Map<java.lang.Class<? extends Element>,SmartListenerConfig>
getAllConfigsFromProviders()
static boolean
getFullName(Element element, java.lang.StringBuffer path, java.lang.String separator, boolean checkTopStereotype)
Get Element full name.static boolean
getFullName(Element element, java.lang.StringBuffer path, java.lang.String separator, boolean checkTopStereotype, boolean checkTopModelElement)
Get NameElement full name.static java.lang.String
getFullUMLName(Element element)
Method returns full UML name of element given elementstatic java.lang.String
getFullUMLName(Element element, boolean doNotAddTopLevels)
Get full UML Name of the given elementstatic RepresentationTextCreator
getInstance()
static java.lang.String
getModelElementNameWithParentPath(NamedElement element, boolean addColor)
Get element name with parent path.static java.lang.String
getModelElementParentPath(Element element, boolean addBrackets)
Get element name with parent path.static java.lang.String
getPathToRoot(Element element)
Get path of the given element to the root of element.static java.lang.String
getPathToRoot(Element element, boolean checkTop)
Get path of the given element to the root of element.static java.lang.String
getPathToRoot(Element element, boolean relativeToLibrary, boolean compactMode)
Calculates qualified name.static java.lang.String
getPathToRoot(Element element, boolean relativeToLibrary, boolean relativeToModel, boolean compactMode)
Calculates qualified name.static java.lang.String
getPathToRoot(Element element, boolean toModelLibrary, boolean toModel, java.lang.String separator)
Get path to root.static java.lang.String
getPathToRoot(Element element, boolean checkTop, java.lang.String separator)
Get path to root.static RepresentationTextCreator.RepresentationTextProvider
getProviderFor(BaseElement element)
Looks for a provider for a given element.java.lang.String
getRelationshipFromToPart(Element relationship, Element clientModelElement, Element supplierModelElement, RepresentationTextParams textParams)
java.lang.String
getRelationshipFromToPart(Relationship relationship, RepresentationTextParams textParams)
(package private) java.lang.String
getRepresentationText(BaseElement element, RepresentationTextParams textParams, boolean noCache)
Returns representation text for the provided elementstatic java.lang.String
getRepresentedText(BaseElement element)
Returns representation text for the provided elementstatic java.lang.String
getRepresentedText(BaseElement element, RepresentationTextParams textParams)
Returns representation text for the provided elementstatic java.lang.String
getRepresentedText(BaseElement element, RepresentationTextParams textParams, boolean noCache)
Returns representation text for the provided elementstatic void
invalidateRepresentationCache(Project project)
private static boolean
isChildOfRootElement(Element element, boolean checkStereotype, boolean checkModel)
Test if given model element owner is the root model element according to rules indicated by checkStereotype and checkModel parameters.boolean
isCreateBoundElementName()
static boolean
isHumanTypeUsed(Element element)
Checks if human type may be used in representation text of given element.static void
removeProvider(RepresentationTextCreator.RepresentationTextProvider provider)
Unregisters a given representation text provider.void
resetAutoIdRepresentations(Project project)
Clear the text cache for all elements that are part of the given project and have element numbersvoid
resetCache(BaseElement element)
Reset all cached texts about given elementvoid
resetCache(java.util.Collection<? extends BaseElement> elements)
Reset all cached texts about given elementsvoid
setCreateBoundElementName(boolean createBoundElementName)
private static void
warnToOverrideMethod(java.lang.String methodName, java.lang.Class aClass)
-
Methods inherited from class com.nomagic.magicdraw.uml.DeprecatedRepresentationTextCreator
appendColor, appendColor, appendGrayColor, appendGrayColor, constructActivityEdgeText, constructCombinedFragmentOperatorText, createActivityParameterNodeText, createAssociationText, createBehaviorText, createBehaviorText, createBehaviorText, createBehaviorText, createClassifierName, createClassifiersRepresentation, createConstraintsText, createConstraintsText, createConstraintsText, createDefaultRepresentationText, createDefaultRepresentationText, createDefaultRepresentationText, createElementNameText, createEnumerationLiteralText, createEnumerationLiteralText, createEnumerationLiteralText, createEnumerationLiteralText, createEventText, createEventText, createGuardText, createId, createInstanceSpecificationText, createInstanceSpecificationText, createInteractionUseText, createInteractionUseText, createMultiplicityRangeText, createMultiplicityText, createMultiplicityText, createMultiplicityText, createMultiplicityText, createNamedElementListText, createOperandGuardText, createOperationText, createOperationText, createOperationText, createOperationText, createParameterDirectionText, createParametersText, createParametersText, createParameterText, createParameterText, createParameterText, createPinText, createPortText, createPortText, createPortText, createPropertyPropertyStringText, createPropertyPropertyStringText, createPropertyText, createPropertyText, createPropertyText, createPropertyText, createPropertyText, createProtocolTransitionText, createProtocolTransitionText, createProtocolTransitionText, createPureSlotsString, createReceptionText, createReceptionText, createReceptionText, createRepresentationTextComparator, createSlotsText, createSlotText, createSlotText, createSlotText, createSlotText, createStateText, createStereotypesText, createStereotypesText, createStereotypesText, createStereotypesText, createStereotypeText, createStereotypeText, createStereotypeText, createTemplateBindingText, createTemplateBindingText, createTemplateParametersText, createTemplateParameterSubstitutionText, createTemplateParameterText, createTransitionText, createTransitionText, createTransitionText, createTriggersText, createTriggersText, createTriggersText, createTriggerText, createTriggerText, createTriggerText, createTypedElementText, createTypeName, createValueSpecificationText, createVisibilityText, endColorHtmlTag, endColorHtmlTag, getLocationInTool, getPureTextFromColoredText, getRelationshipFromToRepresentation, getRepresentedText, getRepresentedText, getRepresentedText, getRepresentedText, getRepresentedText, getSlotTextBuilderFactory, getTaggedValueTextBuilderFactory, isAddColor, isShowFullType, resetColor, resetColor, setAddColor, setLocationInTool, setShowFullType, startColorHtmlTag, startColorHtmlTag
-
-
-
-
Field Detail
-
LOCAL_TEXT_CREATOR
private static final java.lang.ThreadLocal<RepresentationTextCreator> LOCAL_TEXT_CREATOR
Every thread which access RepresentationTextCreator will have its own instance.This is done because sometimes representation text can be modified from few threads, and returned result may be wrong.
-
creatorImpl
private final com.nomagic.magicdraw.uml.ElementRepresentationTextCreatorImpl creatorImpl
-
-
Method Detail
-
getRepresentedText
public static java.lang.String getRepresentedText(BaseElement element)
Returns representation text for the provided element- Parameters:
element
- element which representation text will be created.- Returns:
- representation text for the given element.
-
getRepresentedText
public static java.lang.String getRepresentedText(BaseElement element, RepresentationTextParams textParams)
Returns representation text for the provided element- Parameters:
element
- element which representation text will be created.textParams
- parameters describing how to construct the text, what to include- Returns:
- representation text for the given element.
-
getRepresentedText
public static java.lang.String getRepresentedText(BaseElement element, RepresentationTextParams textParams, boolean noCache)
Returns representation text for the provided element- Parameters:
element
- element which representation text will be created.textParams
- parameters describing how to construct the text, what to includenoCache
- if false, cached text value (that was calculated earlier) can be returned if true, cache will not be used and representation text will be constructed- Returns:
- representation text for the given element.
-
getRepresentationText
java.lang.String getRepresentationText(BaseElement element, RepresentationTextParams textParams, boolean noCache)
Returns representation text for the provided element- Parameters:
element
- element which representation text will be created.textParams
- parameters describing how to construct the text, what to includenoCache
- if false, cached text value (that was calculated earlier) can be returned if true, cache will not be used and representation text will be constructed- Returns:
- representation text for the given element.
-
createDefaultText
private java.lang.String createDefaultText(BaseElement element, RepresentationTextParams textParams)
-
createDefaultRepresentationText
public static java.lang.String createDefaultRepresentationText(BaseElement element, RepresentationTextParams textParams)
Gets default (not extended) representation text. Representation text can be extended by adding aRepresentationTextCreator.RepresentationTextProvider
- Parameters:
element
- element for which to retrieve representation text.textParams
- parameters describing how to construct the text, what to include
-
getInstance
public static RepresentationTextCreator getInstance()
- Returns:
- thread local specific instance
-
getModelElementParentPath
public static java.lang.String getModelElementParentPath(Element element, boolean addBrackets)
Get element name with parent path.- Parameters:
element
- the given name elementaddBrackets
- true for add brackets to the string- Returns:
- parent path
-
getModelElementNameWithParentPath
public static java.lang.String getModelElementNameWithParentPath(NamedElement element, boolean addColor)
Get element name with parent path.- Parameters:
element
- the given name elementaddColor
- add color flag- Returns:
- element name with parent path
-
getFullUMLName
public static java.lang.String getFullUMLName(Element element)
Method returns full UML name of element given element- Parameters:
element
- element- Returns:
- full element name with path to root
-
getFullUMLName
public static java.lang.String getFullUMLName(Element element, boolean doNotAddTopLevels)
Get full UML Name of the given element- Parameters:
element
- the given elementdoNotAddTopLevels
- do not add to top level- Returns:
- full UML Name
-
getAbsoluteUMLPathToRoot
public static java.lang.String getAbsoluteUMLPathToRoot(Element element)
Method returns string representing path from root element to the given element.- Parameters:
element
- element- Returns:
- path from the the root element to the given one
-
getPathToRoot
public static java.lang.String getPathToRoot(Element element)
Get path of the given element to the root of element.- Parameters:
element
- the given element- Returns:
- the path to root element element
-
getPathToRoot
public static java.lang.String getPathToRoot(Element element, boolean checkTop)
Get path of the given element to the root of element.- Parameters:
element
- the given elementcheckTop
- true for check the root- Returns:
- the path to root element element
-
getPathToRoot
public static java.lang.String getPathToRoot(Element element, boolean relativeToLibrary, boolean compactMode)
Calculates qualified name. It can generate string using standard UML notation (using double colon for separator) or in the old MagicDraw style (surrounded with parentheses). For more options seegetPathToRoot(Element, boolean, boolean, boolean)
- Parameters:
element
- model element used to calculate qualified namerelativeToLibrary
- if true, then qualified name is calculated from "model library" element, otherwise qualified name is calculated from root.compactMode
- if true, then old MagicDraw notation is used, otherwise uses standard UML notation- Returns:
- string containing "name space" qualified name part.
-
getPathToRoot
public static java.lang.String getPathToRoot(Element element, boolean relativeToLibrary, boolean relativeToModel, boolean compactMode)
Calculates qualified name. It can generate string using standard UML notation (using double colon for separator) or in the old MagicDraw style (surrounded with parentheses).- Parameters:
element
- model element used to calculate qualified namerelativeToLibrary
- if true, then qualified name is calculated from "model library" element, otherwise qualified name is calculated from root.relativeToModel
- if true, then qualified name is calculated from nearest "model" element, otherwise qualified name is calculated from root.compactMode
- if true, then old MagicDraw notation is used, otherwise uses standard UML notation- Returns:
- string containing "name space" qualified name part.
-
getPathToRoot
public static java.lang.String getPathToRoot(Element element, boolean checkTop, java.lang.String separator)
Get path to root. For More options seegetPathToRoot(Element, boolean, boolean, String)
- Parameters:
element
- the given elementcheckTop
- true for check the rootseparator
- separator to use to create a path- Returns:
- string
-
getPathToRoot
public static java.lang.String getPathToRoot(Element element, boolean toModelLibrary, boolean toModel, java.lang.String separator)
Get path to root.- Parameters:
element
- the given elementtoModelLibrary
- if true, stops at model librarytoModel
- if true, stops at mode elementseparator
- separator to use to create a path- Returns:
- string
-
getFullName
public static boolean getFullName(Element element, java.lang.StringBuffer path, java.lang.String separator, boolean checkTopStereotype)
Get Element full name. For more options seegetFullName(Element, StringBuffer, String, boolean, boolean)
.- Parameters:
element
- the given elementpath
- Path of elementseparator
- the separatorcheckTopStereotype
- is check top stereotype- Returns:
- true if element is NamedElement, otherwise false.
-
getFullName
public static boolean getFullName(Element element, java.lang.StringBuffer path, java.lang.String separator, boolean checkTopStereotype, boolean checkTopModelElement)
Get NameElement full name.- Parameters:
element
- The NameElement.path
- Path of NameElement.separator
- The separator.checkTopStereotype
- Is check to stereotype?checkTopModelElement
- indicates Model model element check- Returns:
- true if element is NamedElement, otherwise false.
-
isChildOfRootElement
private static boolean isChildOfRootElement(Element element, boolean checkStereotype, boolean checkModel)
Test if given model element owner is the root model element according to rules indicated by checkStereotype and checkModel parameters.- Parameters:
element
- the elementcheckStereotype
- check stereotypecheckModel
- check model- Returns:
- true if owner of "element" is the root element, otherwise false,
NullPointerException
is thrown if "element" is null.
-
addProvider
public static void addProvider(RepresentationTextCreator.RepresentationTextProvider provider)
Registers a given representation text provider.- Parameters:
provider
- provider
-
removeProvider
public static void removeProvider(RepresentationTextCreator.RepresentationTextProvider provider)
Unregisters a given representation text provider.- Parameters:
provider
- provider
-
getAllConfigsFromProviders
public static java.util.Map<java.lang.Class<? extends Element>,SmartListenerConfig> getAllConfigsFromProviders()
-
getProviderFor
@CheckForNull public static RepresentationTextCreator.RepresentationTextProvider getProviderFor(BaseElement element)
Looks for a provider for a given element.- Parameters:
element
- given element- Returns:
- found provider or null
-
getRelationshipFromToPart
public java.lang.String getRelationshipFromToPart(Relationship relationship, RepresentationTextParams textParams)
-
getRelationshipFromToPart
public java.lang.String getRelationshipFromToPart(Element relationship, @CheckForNull Element clientModelElement, @CheckForNull Element supplierModelElement, RepresentationTextParams textParams)
-
isCreateBoundElementName
public boolean isCreateBoundElementName()
-
setCreateBoundElementName
public void setCreateBoundElementName(boolean createBoundElementName)
-
resetAutoIdRepresentations
public void resetAutoIdRepresentations(Project project)
Clear the text cache for all elements that are part of the given project and have element numbers- Parameters:
project
- project
-
resetCache
public void resetCache(java.util.Collection<? extends BaseElement> elements)
Reset all cached texts about given elements- Parameters:
elements
- elements
-
resetCache
public void resetCache(BaseElement element)
Reset all cached texts about given element- Parameters:
element
- element
-
invalidateRepresentationCache
public static void invalidateRepresentationCache(Project project)
-
isHumanTypeUsed
public static boolean isHumanTypeUsed(Element element)
Checks if human type may be used in representation text of given element.- Parameters:
element
- element to check.- Returns:
- true human type is used in representation text, otherwise - false
-
warnToOverrideMethod
private static void warnToOverrideMethod(java.lang.String methodName, java.lang.Class aClass)
-
createRepresentationTextComparator
public static java.util.Comparator<BaseElement> createRepresentationTextComparator(RepresentationTextParams params)
-
-