Package com.nomagic.magicdraw.hyperlinks
Class HyperlinkUtils
java.lang.Object
com.nomagic.magicdraw.hyperlinks.HyperlinkUtils
Hyperlink utilities.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Value holder for hyperlink text -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addHyperlink
(Element element, Hyperlink hyperlink) Adds given hyperlink as tagged value to the element.static Hyperlink
createHyperlink
(String text, BaseElement element) Creates hyperlink to given elementstatic Hyperlink
createHyperlink
(String text, String url) Deprecated.Uses the active project to resolve element hyperlinks.static Hyperlink
createHyperlink
(String text, String url, Project context) Creates hyperlink from given string url in the given project.static Hyperlink
Creates hyperlink from given string url in the given project.static Hyperlink
getActiveHyperlink
(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.static Icon
Return hyperlink iconstatic String
getURL
(BaseElement element) Get URL of mdel:// protocol for a given element.static String
getURLWithVersion
(BaseElement element) Get URL of mdel:// protocol for a given element.static boolean
hasActiveHyperlink
(Element element) Returns active hyperlink of the elementstatic boolean
hasHyperlink
(Element element) Check if element has hyperlink(s).static boolean
hasHyperlinks
(Element element) static boolean
isActiveHyperlink
(Element element, Hyperlink hyperlink) Check given hyperlink is marked as active on the given elementstatic void
makeActive
(Element element, Hyperlink hyperlink) Make given hyperlink as active on a given elementstatic void
removeActive
(Element element) Remove active hyperlink from a given elementstatic void
removeHyperlink
(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.- Parameters:
hyperlink
- hyperlink- Returns:
- hyperlink text information
-
getDisplayableHyperlinkText
public static HyperlinkUtils.DisplayableHyperlinkText getDisplayableHyperlinkText(@CheckForNull Hyperlink hyperlink, boolean colorfulText) Return information about hyperlink text.- Parameters:
hyperlink
- hyperlinkcolorfulText
- false if text should be without colors, true if where possible, text should be colorful- 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
-