Package com.nomagic.magicdraw.hyperlinks
Class HyperlinkUtils
- java.lang.Object
-
- com.nomagic.magicdraw.hyperlinks.HyperlinkUtils
-
@OpenApiAll public class HyperlinkUtils extends java.lang.Object
Hyperlink utilities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HyperlinkUtils.DisplayableHyperlinkText
Value holder for hyperlink text
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
HYPERLINK_MODEL_ACTIVE_TAG
static java.lang.String
HYPERLINK_MODEL_TAG
static java.lang.String
HYPERLINK_OWNER
static java.lang.String
HYPERLINK_TEXT_ACTIVE_TAG
static java.lang.String
HYPERLINK_TEXT_TAG
-
Constructor Summary
Constructors Constructor Description HyperlinkUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
addHyperlink(Element element, Hyperlink hyperlink)
Adds given hyperlink as tagged value to the element.static Hyperlink
createHyperlink(java.lang.String text, BaseElement element)
Creates hyperlink to given elementstatic Hyperlink
createHyperlink(java.lang.String text, java.lang.String url)
Creates hyperlink from given string url.static Hyperlink
createHyperlink(java.lang.String text, java.lang.String url, Project context)
Creates hyperlink from given string url in the given project.static Hyperlink
createHyperlink(java.lang.String text, java.lang.String url, Project context, java.util.Map<java.lang.Object,java.lang.Object> attributes)
Creates hyperlink from given string url in the given project.static Hyperlink
getActiveHyperlink(Element element)
Returns active hyperlink of the elementstatic java.util.Collection<Hyperlink>
getAllHyperlinks(Element element)
Returns hyperlinks of the element.static java.util.Map<Element,Hyperlink>
getAllHyperlinksToElement(BaseElement targetElement)
Collects information about all hyperlinks pointing to the given target element.static HyperlinkUtils.DisplayableHyperlinkText
getDisplayableHyperlinkText(Hyperlink hyperlink)
Return information about hyperlink text.static javax.swing.Icon
getIcon(Hyperlink hyperlink)
Return hyperlink iconstatic java.lang.String
getURL(BaseElement element)
Get URL of mdel:// protocol for a given element.static java.lang.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 Detail
-
HYPERLINK_TEXT_TAG
public static final java.lang.String HYPERLINK_TEXT_TAG
- See Also:
- Constant Field Values
-
HYPERLINK_TEXT_ACTIVE_TAG
public static final java.lang.String HYPERLINK_TEXT_ACTIVE_TAG
- See Also:
- Constant Field Values
-
HYPERLINK_MODEL_TAG
public static final java.lang.String HYPERLINK_MODEL_TAG
- See Also:
- Constant Field Values
-
HYPERLINK_MODEL_ACTIVE_TAG
public static final java.lang.String HYPERLINK_MODEL_ACTIVE_TAG
- See Also:
- Constant Field Values
-
HYPERLINK_OWNER
public static final java.lang.String HYPERLINK_OWNER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getURL
public static java.lang.String getURL(BaseElement element)
Get URL of mdel:// protocol for a given element.- Parameters:
element
- the given element- Returns:
- URL of element.
-
getURLWithVersion
public static java.lang.String getURLWithVersion(BaseElement element)
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
public static java.util.Collection<Hyperlink> getAllHyperlinks(Element element)
Returns hyperlinks of the element.- Parameters:
element
- given element- Returns:
- a collection of all hyperlinks
-
getAllHyperlinksToElement
public static java.util.Map<Element,Hyperlink> getAllHyperlinksToElement(BaseElement targetElement)
Collects information about all hyperlinks pointing to the given target element.- Parameters:
targetElement
- targetElement- Returns:
- information about hyperlinks
-
removeActive
public static void removeActive(Element element)
Remove active hyperlink from a given element- Parameters:
element
- element
-
makeActive
public static void makeActive(Element element, Hyperlink hyperlink)
Make given hyperlink as active on a given element- Parameters:
element
- given elementhyperlink
- given hyperlink
-
createHyperlink
public static Hyperlink createHyperlink(@CheckForNull java.lang.String text, @CheckForNull java.lang.String url, @CheckForNull Project context)
Creates hyperlink from given string url in the given project.- Parameters:
text
- given texturl
- hyperlink urlcontext
- project as context- Returns:
- hyperlink
-
createHyperlink
public static Hyperlink createHyperlink(@CheckForNull java.lang.String text, @CheckForNull java.lang.String url, @CheckForNull Project context, java.util.Map<java.lang.Object,java.lang.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
public static Hyperlink createHyperlink(@CheckForNull java.lang.String text, @CheckForNull java.lang.String url)
Creates hyperlink from given string url.- Parameters:
text
- given texturl
- hyperlink url- Returns:
- hyperlink
-
createHyperlink
public static Hyperlink createHyperlink(@CheckForNull java.lang.String text, BaseElement element)
Creates hyperlink to given element- Parameters:
text
- given textelement
- element- Returns:
- hyperlink
-
getActiveHyperlink
@CheckForNull public static Hyperlink getActiveHyperlink(Element element)
Returns active hyperlink of the element- Parameters:
element
- given element- Returns:
- active hyperlink
-
hasActiveHyperlink
public static boolean hasActiveHyperlink(Element element)
Returns active hyperlink of the element- Parameters:
element
- given element- Returns:
- active hyperlink
-
hasHyperlink
public static boolean hasHyperlink(Element element)
Check if element has hyperlink(s).- Parameters:
element
- element- Returns:
- true if element has at least one hyperlink
-
isActiveHyperlink
public static boolean isActiveHyperlink(Element element, Hyperlink hyperlink)
Check given hyperlink is marked as active on the given element- Parameters:
element
- elementhyperlink
- hyperlink- Returns:
- true if hyperlink is active
-
getIcon
@CheckForNull public static javax.swing.Icon getIcon(Hyperlink hyperlink)
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
-
removeHyperlink
public static void removeHyperlink(Element element, Hyperlink hyperlink)
Remove given hyperlink from the element.- Parameters:
element
- elementhyperlink
- hyperlink
-
addHyperlink
public static boolean addHyperlink(Element element, Hyperlink hyperlink)
Adds given hyperlink as tagged value to the element. Checks if 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
public static boolean hasHyperlinks(@CheckForNull Element element)
-
-