Papyrus Banner

Sections below show how to use the API to contribute to the navigation menus and hyperlinks proposition strategies.

Navigation API

The navigation API has the following:

Step-by-step Guide

The following instructions allow you to create a new hyperlink contributor:

org.eclipse.papyrus.infra.gmfdiag.navigation
org.eclipse.papyrus.uml.navigation

public class SpecialTargetNavigableElement extends GenericNavigableElement {
  public SpecialTargetNavigableElement(/*...*/) { // Write a constructor that will call "super(Element elt)" where "elt" is the semantic element that this navigable element wraps
    super(/*...*/);
  }

  @Override
  public String getLabel() {
    return "Go to special target" + getElementLabel() + "..."; // The convention is to return a string like this
  }

  @Override
  public String getDescription() {
    return "Go to the special target:" + getElementLabel(); // The convention is to return a string like this
  }

  // You can also overwrite other methods of GenericNavigableElement
}

public class SpecialTargetNavigationContributor implements NavigationContributor {
  public List<NavigableElement> getNavigableElements(Object fromElement) {
    List<NavigableElement> result = new LinkedList<NavigableElement>();

    /* You can check if fromElement is a particular UML type for example.
       You can then add instances of "SpecialTargetNavigableElement" to the list
       of navigable elements that will be returned. What you wrap with
       the navigable element is up to you. Usually we wrap an element related to
       fromElement. */
    
    return result;
  }
}

org.eclipse.papyrus.infra.services.navigation.navigationContributor

IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();
String key = "oep.specialTargetNavigationContributor" + ".isActive";
preferences.setValue(key, true); // or false  to deactivate

Real Example

An example of a hyperlink contributor is available below. This contributor creates automatic hyperlinks for a class that has inner classes shown in its inner class diagrams.

Hyperlink API

API Overview

The hyperlink API has the following:

Step-by-step Guide

The following instructions allow you to create a new hyperlink contributor:

org.eclipse.papyrus.infra.gmfdiag.hyperlink
public class MyHyperlinkContributor implements HyperlinkContributor {
  public List<HyperLinkObject> getHyperlinks(Object fromElement) {
    ArrayList<HyperLinkObject> hyperlinks = new ArrayList<HyperLinkObject>();
    /* You can check if fromElement is a particular UML type for example.
       You can use the org.eclipse.papyrus.infra.services.viewersearch.impl.ViewerSearchService
       to search views containing a particular semantic element.
       See Real Example section for an example on how to use the ViewerSearchService */
    return hyperlinks;
  }
}

org.eclipse.papyrus.infra.hyperlink.hyperlinkContributor
IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();
String key = "oep.myHyperlinkContributor" + ".isActive";
preferences.setValue(key, true) // or false  to deactivate

Real Example

An example of a hyperlink contributor is available below. This contributor creates automatic hyperlinks for a class that has inner classes shown in its inner class diagrams.

Bugzilla References