Class HyperlinkUtils


  • @OpenApiAll
    public class HyperlinkUtils
    extends java.lang.Object
    Hyperlink utilities.
    • 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
    • Constructor Detail

      • HyperlinkUtils

        public HyperlinkUtils()
    • 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 to getURL(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 element
        hyperlink - given hyperlink
      • createHyperlink

        @Deprecated
        public static Hyperlink createHyperlink​(@CheckForNull
                                                java.lang.String text,
                                                @CheckForNull
                                                java.lang.String url)
        Deprecated.
        Uses the active project to resolve element hyperlinks. Use createHyperlink(String, String, Project) and pass the correct context project.
        Creates hyperlink from given string url.
        Parameters:
        text - given text
        url - hyperlink url
        Returns:
        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. 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 text
        url - hyperlink url
        context - 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 text
        url - hyperlink url
        context - project as context
        attributes - additional attributes
        Returns:
        hyperlink
      • createHyperlink

        public static Hyperlink createHyperlink​(@CheckForNull
                                                java.lang.String text,
                                                BaseElement element)
        Creates hyperlink to given element
        Parameters:
        text - given text
        element - 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 - element
        hyperlink - 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
      • getDisplayableHyperlinkText

        public static HyperlinkUtils.DisplayableHyperlinkText getDisplayableHyperlinkText​(@CheckForNull
                                                                                          Hyperlink hyperlink,
                                                                                          boolean colorfulText)
        Return information about hyperlink text.
        Parameters:
        hyperlink - hyperlink
        colorfulText - false if text should be without colors, true if where possible, text should be colorful
        Returns:
        hyperlink text information
      • removeHyperlink

        public static void removeHyperlink​(Element element,
                                           Hyperlink hyperlink)
        Remove given hyperlink from the element.
        Parameters:
        element - element
        hyperlink - hyperlink
      • addHyperlink

        public static boolean addHyperlink​(Element element,
                                           Hyperlink hyperlink)
        Adds given hyperlink as tagged value to the element. Checks if it has tagDefinition, taggedValue, taggedValue value
        Parameters:
        element - element
        hyperlink - 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)