Class HyperlinkUtils

java.lang.Object
com.nomagic.magicdraw.hyperlinks.HyperlinkUtils

@OpenApiAll public class HyperlinkUtils extends Object
Hyperlink utilities.
  • Field Details

  • Constructor Details

    • HyperlinkUtils

      public HyperlinkUtils()
  • Method Details

    • getURL

      public static 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 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 Collection<Hyperlink> getAllHyperlinks(Element element)
      Returns hyperlinks of the element.
      Parameters:
      element - given element
      Returns:
      a collection of all hyperlinks
    • getAllHyperlinksToElement

      public static 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 String text, @CheckForNull 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 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 text
      url - hyperlink url
      context - 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 text
      url - hyperlink url
      context - project as context
      attributes - additional attributes
      Returns:
      hyperlink
    • createHyperlink

      public static Hyperlink createHyperlink(@CheckForNull 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 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)