Package com.nomagic.magicdraw.hyperlinks
Class HyperlinkUtils
java.lang.Object
com.nomagic.magicdraw.hyperlinks.HyperlinkUtils
Hyperlink utilities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classValue holder for hyperlink text -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddHyperlink(Element element, Hyperlink hyperlink) Adds given hyperlink as tagged value to the element.static HyperlinkcreateHyperlink(String text, BaseElement element) Creates hyperlink to given elementstatic HyperlinkcreateHyperlink(String text, String url) Deprecated.Uses the active project to resolve element hyperlinks.static HyperlinkcreateHyperlink(String text, String url, Project context) Creates hyperlink from given string url in the given project.static HyperlinkCreates hyperlink from given string url in the given project.static HyperlinkgetActiveHyperlink(Element element) Returns active hyperlink of the elementstatic Collection<Hyperlink>getAllHyperlinks(Element element) Returns hyperlinks of the element.getAllHyperlinksToElement(BaseElement targetElement) Collects information about all hyperlinks pointing to the given target element.getDisplayableHyperlinkText(Hyperlink hyperlink) Return information about hyperlink text.getDisplayableHyperlinkText(Hyperlink hyperlink, boolean colorfulText) Return information about hyperlink text.getDisplayableHyperlinkText(Hyperlink hyperlink, boolean colorfulText, boolean trimShortText) Return information about hyperlink text.static IconReturn hyperlink iconstatic StringgetURL(BaseElement element) Get URL of mdel:// protocol for a given element.static StringgetURLWithVersion(BaseElement element) Get URL of mdel:// protocol for a given element.static booleanhasActiveHyperlink(Element element) Returns active hyperlink of the elementstatic booleanhasHyperlink(Element element) Check if element has hyperlink(s).static booleanhasHyperlinks(Element element) static booleanisActiveHyperlink(Element element, Hyperlink hyperlink) Check given hyperlink is marked as active on the given elementstatic voidmakeActive(Element element, Hyperlink hyperlink) Make given hyperlink as active on a given elementstatic voidremoveActive(Element element) Remove active hyperlink from a given elementstatic voidremoveHyperlink(Element element, Hyperlink hyperlink) Remove given hyperlink from the element.
-
Field Details
-
HYPERLINK_TEXT_TAG
- See Also:
-
HYPERLINK_TEXT_ACTIVE_TAG
- See Also:
-
HYPERLINK_MODEL_TAG
- See Also:
-
HYPERLINK_MODEL_ACTIVE_TAG
- See Also:
-
HYPERLINK_OWNER
- See Also:
-
-
Constructor Details
-
HyperlinkUtils
public HyperlinkUtils()
-
-
Method Details
-
getURL
Get URL of mdel:// protocol for a given element.- Parameters:
element- the given element- Returns:
- URL of element.
-
getURLWithVersion
Get URL of mdel:// protocol for a given element. If project is remote project - include project version number, if project is local - method is equivalent togetURL(BaseElement).- Parameters:
element- the given element- Returns:
- URL of element.
-
getAllHyperlinks
Returns hyperlinks of the element.- Parameters:
element- given element- Returns:
- a collection of all hyperlinks
-
getAllHyperlinksToElement
Collects information about all hyperlinks pointing to the given target element.- Parameters:
targetElement- targetElement- Returns:
- information about hyperlinks
-
removeActive
Remove active hyperlink from a given element- Parameters:
element- element
-
makeActive
Make given hyperlink as active on a given element- Parameters:
element- given elementhyperlink- given hyperlink
-
createHyperlink
@Deprecated public static Hyperlink createHyperlink(@CheckForNull String text, @CheckForNull String url) Deprecated.Uses the active project to resolve element hyperlinks. UsecreateHyperlink(String, String, Project)and pass the correct context project.Creates hyperlink from given string url.- Parameters:
text- given texturl- hyperlink url- Returns:
- hyperlink
-
createHyperlink
public static Hyperlink createHyperlink(@CheckForNull String text, @CheckForNull String url, @CheckForNull Project context) Creates hyperlink from given string url in the given project. Url can be project specific(e.g. an element hyperlink),in order for such url to be resolved correctly into a hyperlink the Project context must be provided, otherwise null is sufficient.- Parameters:
text- given texturl- hyperlink urlcontext- project as context- Returns:
- hyperlink
-
createHyperlink
public static Hyperlink createHyperlink(@CheckForNull String text, @CheckForNull String url, @CheckForNull Project context, Map<Object, Object> attributes) Creates hyperlink from given string url in the given project.- Parameters:
text- given texturl- hyperlink urlcontext- project as contextattributes- additional attributes- Returns:
- hyperlink
-
createHyperlink
Creates hyperlink to given element- Parameters:
text- given textelement- element- Returns:
- hyperlink
-
getActiveHyperlink
Returns active hyperlink of the element- Parameters:
element- given element- Returns:
- active hyperlink
-
hasActiveHyperlink
Returns active hyperlink of the element- Parameters:
element- given element- Returns:
- active hyperlink
-
hasHyperlink
Check if element has hyperlink(s).- Parameters:
element- element- Returns:
- true if element has at least one hyperlink
-
isActiveHyperlink
Check given hyperlink is marked as active on the given element- Parameters:
element- elementhyperlink- hyperlink- Returns:
- true if hyperlink is active
-
getIcon
Return hyperlink icon- Parameters:
hyperlink- hyperlink- Returns:
- hyperlink icon
-
getDisplayableHyperlinkText
public static HyperlinkUtils.DisplayableHyperlinkText getDisplayableHyperlinkText(@CheckForNull Hyperlink hyperlink) Return information about hyperlink text. Trims short text to a size ofMAX_DISPLAYABLE_TEXT_LENGTH- Parameters:
hyperlink- hyperlink- Returns:
- hyperlink text information
-
getDisplayableHyperlinkText
public static HyperlinkUtils.DisplayableHyperlinkText getDisplayableHyperlinkText(@CheckForNull Hyperlink hyperlink, boolean colorfulText) Return information about hyperlink text. Trims short text to a size ofMAX_DISPLAYABLE_TEXT_LENGTH- Parameters:
hyperlink- hyperlinkcolorfulText- false if text should be without colors, true if where possible, text should be colorful- Returns:
- hyperlink text information
-
getDisplayableHyperlinkText
public static HyperlinkUtils.DisplayableHyperlinkText getDisplayableHyperlinkText(@CheckForNull Hyperlink hyperlink, boolean colorfulText, boolean trimShortText) Return information about hyperlink text.- Parameters:
hyperlink- hyperlinkcolorfulText- false if text should be without colors, true if where possible, text should be colorfultrimShortText- if true, will trim the short text to size ofMAX_DISPLAYABLE_TEXT_LENGTH- Returns:
- hyperlink text information
-
removeHyperlink
Remove given hyperlink from the element.- Parameters:
element- elementhyperlink- hyperlink
-
addHyperlink
Adds given hyperlink as tagged value to the element. Checks if it has tagDefinition, taggedValue, taggedValue value- Parameters:
element- elementhyperlink- hyperlink to add- Returns:
- true if hyperlink was added, false if such hyperlink already exist on the element
-
hasHyperlinks
-