Class HyperlinkUtils


  • @OpenApiAll
    public class HyperlinkUtils
    extends java.lang.Object
    Hyperlink utilities.
    • Field Detail

      • MAX_DISPLAYABLE_TEXT_LENGTH

        private static final int MAX_DISPLAYABLE_TEXT_LENGTH
        See Also:
        Constant Field Values
      • DISPLAYABLE_TEXT_LENGTH_SHIFT

        private static final int DISPLAYABLE_TEXT_LENGTH_SHIFT
        See Also:
        Constant Field Values
      • 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
      • addHyperlink

        private static java.util.Collection<Hyperlink> addHyperlink​(@CheckForNull
                                                                    java.util.Collection<Hyperlink> hyperlinksList,
                                                                    Hyperlink hyperlink)
      • 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

        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 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,
                                                @CheckForNull
                                                java.lang.String url)
        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,
                                                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
      • removeHyperlink

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

        private static void removeHyperlinkValue​(TaggedValue taggedValue,
                                                 @CheckForNull
                                                 java.lang.Object value)
      • 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 - 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)
      • getMainTaggedValue

        @CheckForNull
        private static TaggedValue getMainTaggedValue​(Element owner)