Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Papyrus/Neon Work Description/Improvements/Navigation"

(Overview)
(Hyperlink API)
 
(75 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Overview ==
+
== Overview and Video ==
  
Papyrus has a navigation system where the user can navigate to different diagrams, and Model Explorer semantic elements, when some notation elements are clicked. The navigation system also offers the possibility to add hyperlinks to notation elements. Some noticeable characteristics of the current navigation system are the following:
+
This page describes the navigation feature of Papyrus implemented in Neon. [https://youtu.be/OsOnOLu8dXk The YouTube video] guides you step-by-step in using the navigation feature. Sections below only describe succinctly the navigation feature.
  
* Hyperlinks appear in diagram assistant
+
== Navigation Menus ==
* Hyperlinks management button appears in diagram assistant
+
* Double Click on a notation element goes to its default hyperlink(s), if there are any
+
* Hyperlinks management menu lets the user create hyperlinks, assign default hyperlinks, and assign heuristics to "try" to "go somewhere" (?) when a notation element without default hyperlinks is double clicked. (Note that the heuristic functionality is broken and not clearly defined currently.)
+
* Alt+Click on a notation element goes to its navigable element (e.g. return type for an Operation)
+
  
The following section describes the planned changes to this navigation system.
+
By alt-hovering over an element, in a diagram or the model explorer, a menu pops up. This menu is called the alt-menu. The menu shows commands to navigate to some targets, which are related element or the hovered element itself (in another representation). When clicking on a command, corresponding to a target, we navigate to: (1) first representation of the target found in a(nother) diagram, or (2) the target in the model explorer if the first rule found nothing. The alt-menu also shows user-defined hyperlinks pointing to diagrams, local documents, or websites. The figure below shows the alt-menu:
  
== Planned Changes ==
 
  
The navigation system is integrated through three menus, arbitrarily named "Alt Menu", "Right Click Menu", and "Double Click Menu". There are also some UI enhancements.
+
[[File:papyrus_nav_alt_menu.png|frame|center|alt=Papyrus Navigation Alt-Menu]]
  
=== Alt Menu ===
 
''(This work is done.)''
 
  
The Alt Menu is a popup menu. It is shown when the user Alt+Hovers over a notation element in a diagram, and it is contextual. Navigation and hyperlink systems are integrated into this menu, instead of the diagram assistant. The figure below shows the three kinds of items in the Alt Menu:
 
  
[[File:papyrus_nav_alt_menu.png|thumb|center|507px|alt=Papyrus Navigation Alt Menu]]
 
  
Here Operation "op1" of "MyClass" is Alt+Hovered over. The menu shows an item to go to the navigable element of "op1" (i.e. its return type), a hyperlink created for "op1" (points to an ActivityDiagram), and default item to create hyperlinks for "op1".
+
The goal of the alt-menu is to navigate quickly to a target, with the user having to go through too many choices. The user may also navigate by right-clicking on an element in a diagram or the model explorer. This opens up a context menu. He can then choose where to navigate to for a selected target. The figure below shows the context menu:
  
When the first item is clicked, the following sub-menu appears:
 
  
[[File:papyrus_nav_alt_submenu.png|thumb|center|463px|alt=Papyrus Navigation Alt Sub-Menu]]
 
  
The sub-menu shows two kinds of item: a default item to show the navigable element in the Model Explorer, and 1-* items that show opened diagrams where the navigable item appears. Here the sub-menu shows two items. The first item shows the return type of "op1" in the Model Explorer. The second item shows the return type of "op1", named "MyEnumeration", which appears in "ClassDiagram2".
+
[[File:papyrus_nav_popup_menu.png|frame|center|alt=Papyrus Navigation Context Menu]]
  
=== Right Click Menu ===
 
  
The Right Click Menu should show a "Go to" item. This "Go to" item has a sub-menu with the following items:
 
  
* Children: children of the semantic element corresponding to the notation element
 
* Parents: parents of the semantic element corresponding to the notation element
 
* Typed by: UML elements typed by the semantic element corresponding to the notation element
 
* Diagrams: Diagrams showing the semantic element corresponding to the notation element
 
  
All of these items have sub-menus themselves. These sub-menus are populated dynamically. "Children", "Parents", and "Typed by" show semantic elements. When they are clicked on, they are shown in the Model Explorer. "Diagrams" shows diagrams. When they are clicked on, they open.
+
The user may choose the available navigation targets in the preferences menu. The figure below shows some implemented targets:
  
=== Double Click Menu ===
 
  
Currently the user can double click on a notation element to go to its default hyperlink(s). If there aren't any default hyperlink(s), a menu should appear. This menu should propose the user to add default hyperlink(s) to the notation element. The menu proposes existing hyperlinks (not defined as default), as well as other hyperlinks through a heuristic algorithm. There will be some default heuristic algorithms, along with those that the user can define in the existing heuristic menu of the hyperlinks management menu. This menu will be redone since it is currently broken.
 
  
=== UI Enhancements ===
+
[[File:papyrus_navigation_preferences.png|frame|center|alt=Papyrus Navigation Target Preferences]]
  
Some UI enhancements that will be implemented are:
+
== Hyperlinks Proposition ==
  
* Arrows to navigate between Papyrus diagram tabs, according to the history of opened tabs. The arrows can be emulated by the keyboard. Ctrl+Tab should also go to the next diagram, Ctrl+Shift+Tab should go to the last diagram. This is the behavior in Firefox for example.
+
When the user double-clicks on an element in a diagram, we navigate to its default hyperlink. If there aren't any default hyperlink(s), hyperlinks are proposed according to some pre-defined strategies. If there is only one proposed hyperlink, we navigate to it. If there are several, the user may choose one. The figure below shows the menu to choose a proposed hyperlink:
* When navigating to a unopened diagram, the user can chose if he/she prefers to open the diagram in a new tab, or in the current tab. See modern web browser behavior for tabs
+
 
* Alt+Click, in Property View, on a referenced field (e.g. OwnedParameters of Operation) to navigate
+
 
* Several global Papyrus preferences to configure navigation behaviors
+
 
 +
[[File:papyrus_hyperlink_menu.png|frame|center|alt=Papyrus Proposed Hyperlinks Menu]]
 +
 
 +
 
 +
 
 +
The user may choose the hyperlinks proposition strategies in the preferences menu. The figure below shows some implemented strategies:
 +
 
 +
 
 +
 
 +
[[File:papyrus_hyperlink_preferences.png|frame|center|alt=Papyrus Hyperlink Preferences]]
 +
 
 +
== Misc. UI Enhancements ==
 +
 
 +
Some other UI enhancements are implemented:
 +
 
 +
* Integration in Eclipse history to navigate to the previous/next diagram (even in different models) in the order they were opened ([https://git.eclipse.org/r/#/c/46228/ Gerrit 46228])
 +
* Toolbar arrows to navigate between opened Papyrus diagram tabs ([https://git.eclipse.org/r/#/c/51264/ Gerrit 51264])
 +
* Key bindings (CTRL+(SHIFT+)TAB) to navigate between opened Papyrus diagram tabs ([https://git.eclipse.org/r/#/c/46192/ Gerrit 46192])
 +
* Diagram shortcuts show a preview of the diagram on mouse hover ([https://git.eclipse.org/r/#/c/47035/ Gerrit 47035])
 +
* Clicking on a search result that's a semantic element, navigates to the element in the model explorer ([https://git.eclipse.org/r/#/c/52726/ Gerrit 52726])
 +
* Hyperlink pointing to a document (resp. website) has the document's default icon (resp. website's favicon) (in navigation alt menu patch)
 +
 
 +
== Developer Documentation ==
 +
 
 +
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:
 +
* Interface org.eclipse.papyrus.infra.services.navigation.service.ExtendedNavigableElement
 +
** Classes that implement this interface are navigable elements, i.e. something that wraps a semantic element, that let us navigate to some other object
 +
** You probably shouldn't implement this directly, but the following class:
 +
* Class org.eclipse.papyrus.uml.navigation.navigableElement.GenericNavigableElement
 +
** A generic navigable element. Your own navigable element should probably extend this class, unless you know what you are doing. :)
 +
* Extension point org.eclipse.papyrus.infra.services.navigation.navigationContributor
 +
** Specify extensions that will contribute navigable elements
 +
* Interface org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor
 +
** Classes that implement this interface contribute navigable elements
 +
** The "getNavigableElements(Object)" method returns navigable elements according to the context represented by the object passed as parameter. (You do not need to handle how to pass the object, only what to do with it)
 +
 
 +
==== Step-by-step Guide ====
 +
 
 +
The following instructions allow you to create a new hyperlink contributor:
 +
* Create a plugin
 +
* Add the following dependencies to MANIFEST.MF:
 +
<syntaxhighlight lang="java">
 +
org.eclipse.papyrus.infra.gmfdiag.navigation
 +
org.eclipse.papyrus.uml.navigation
 +
</syntaxhighlight>
 +
* Create a navigable element:
 +
<syntaxhighlight lang="java">
 +
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
 +
}
 +
</syntaxhighlight>
 +
* Create a navigation contributor:
 +
<syntaxhighlight lang="java">
 +
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;
 +
  }
 +
}
 +
</syntaxhighlight>
 +
* In plugin.xml, add the following extension:
 +
<syntaxhighlight lang="java">
 +
org.eclipse.papyrus.infra.services.navigation.navigationContributor
 +
</syntaxhighlight>
 +
* Right click > New > contributor
 +
* Fill info
 +
** Id: an arbitrary string
 +
** Contributor: reference to the class that will contribute navigable elements. Example: "SpecialTargetNavigationContributor" created beforehand.
 +
** Label: how this contributor is displayed in preferences (for activation/deactivation)
 +
** Description: tooltip displayed when the mouse hovers over this contributor in the preferences
 +
* (Optional) Activate/deactivate a hyperlink contributor programmatically (example for "SpecialTargetNavigationContributor" whose id is "oep.specialTargetNavigationContributor"):
 +
<syntaxhighlight lang="java">
 +
IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();
 +
String key = "oep.specialTargetNavigationContributor" + ".isActive";
 +
preferences.setValue(key, true); // or false  to deactivate
 +
</syntaxhighlight>
 +
 
 +
==== 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.
 +
* /org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/TargetNavigableElement.java
 +
* /org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/RelationshipNavigationContributor.java
 +
* /org.eclipse.papyrus.uml.navigation/plugin.xml (line 48)
 +
 
 +
=== Hyperlink API ===
 +
 
 +
==== API Overview ====
 +
 
 +
The hyperlink API has the following:
 +
* Extension point org.eclipse.papyrus.infra.hyperlink.hyperlinkContributor
 +
** Specify extensions that will contribute hyperlinks
 +
* Interface org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor
 +
** Classes that implement this interface may contribute hyperlinks
 +
** The "getHyperlink(Object)" method returns a list of hyperlinks according to the context represented by the object that is passed as parameter. (You do not need to handle how to pass the object, only what to do with it)
 +
 
 +
==== Step-by-step Guide ====
 +
 
 +
The following instructions allow you to create a new hyperlink contributor:
 +
* Create a plugin
 +
* Add the following dependency to MANIFEST.MF:
 +
<syntaxhighlight lang="java">org.eclipse.papyrus.infra.gmfdiag.hyperlink</syntaxhighlight>
 +
* Create a hyperlink contributor:
 +
<syntaxhighlight lang="java">
 +
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;
 +
  }
 +
}
 +
</syntaxhighlight>
 +
* In plugin.xml, add the following extension:
 +
<syntaxhighlight lang="java">org.eclipse.papyrus.infra.hyperlink.hyperlinkContributor</syntaxhighlight>
 +
* Right click > New > contributor
 +
* Fill info
 +
** Id: an arbitrary text
 +
** Contributor: reference to the class that will contribute hyperlinks. Example: "MyHyperlinkContributor" created beforehand.
 +
** Label: how this contributor is displayed in preferences (for activation/deactivation)
 +
** Description: tooltip displayed when the mouse hovers over this contributor in the preferences
 +
* (Optional) Activate/deactivate a hyperlink contributor programmatically (example for MyHyperlinkContributor whose id is "oep.myHyperlinkContributor"):
 +
<syntaxhighlight lang="java">
 +
IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();
 +
String key = "oep.myHyperlinkContributor" + ".isActive";
 +
preferences.setValue(key, true) // or false  to deactivate
 +
</syntaxhighlight>
 +
 
 +
==== 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.
 +
* /org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/hyperlink/InnerClassHyperlinkContributor.java
 +
* /org.eclipse.papyrus.uml.diagram.clazz/plugin.xml (line 1733)
  
 
== Bugzilla References ==
 
== Bugzilla References ==
 +
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=463589 Bug 463589 - Navigation Alt Menu]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=462005 Bug 462005 - Navigation to baseclass and subclass missing]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=462005 Bug 462005 - Navigation to baseclass and subclass missing]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461746 Bug 461746 - The navigation service should browse all available diagrams - not only the current one]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461746 Bug 461746 - The navigation service should browse all available diagrams - not only the current one]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=407733 Bug 407733 - Papyrus shall support navigation history with back and next buttons]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=407733 Bug 407733 - Papyrus shall support navigation history with back and next buttons]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=463687 Bug 463687 - Not possible to see and click-to-navigate to opposite elements across links in Model Explorer]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=471697 Bug 471697 - Toolbar buttons to go to next/previous diagram in active window]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=465122 Bug 465122 - Keys to traverse opened tabs in editor]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=465886 Bug 465886 - Double-click default action]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=466294 Bug 466294 - Preview on mouse hover]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467017 Bug 467017 - Local file URI should be relative]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=473763 Bug 473763 - Clicking on a ModelMatch should navigate to the Model Explorer rather than a View]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=465697 Bug 465697 - AbstractNattableWidgetManager does not compare real objects in revealElement]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=473763 Bug 473763 - Clicking on a ModelMatch should navigate to the Model Explorer rather than a View]
 +
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=491077 Bug 491077 - Make the current alt-navigation menu easier to access]

Latest revision as of 08:25, 18 January 2017

Overview and Video

This page describes the navigation feature of Papyrus implemented in Neon. The YouTube video guides you step-by-step in using the navigation feature. Sections below only describe succinctly the navigation feature.

Navigation Menus

By alt-hovering over an element, in a diagram or the model explorer, a menu pops up. This menu is called the alt-menu. The menu shows commands to navigate to some targets, which are related element or the hovered element itself (in another representation). When clicking on a command, corresponding to a target, we navigate to: (1) first representation of the target found in a(nother) diagram, or (2) the target in the model explorer if the first rule found nothing. The alt-menu also shows user-defined hyperlinks pointing to diagrams, local documents, or websites. The figure below shows the alt-menu:


Papyrus Navigation Alt-Menu



The goal of the alt-menu is to navigate quickly to a target, with the user having to go through too many choices. The user may also navigate by right-clicking on an element in a diagram or the model explorer. This opens up a context menu. He can then choose where to navigate to for a selected target. The figure below shows the context menu:


Papyrus Navigation Context Menu



The user may choose the available navigation targets in the preferences menu. The figure below shows some implemented targets:


Papyrus Navigation Target Preferences

Hyperlinks Proposition

When the user double-clicks on an element in a diagram, we navigate to its default hyperlink. If there aren't any default hyperlink(s), hyperlinks are proposed according to some pre-defined strategies. If there is only one proposed hyperlink, we navigate to it. If there are several, the user may choose one. The figure below shows the menu to choose a proposed hyperlink:


Papyrus Proposed Hyperlinks Menu


The user may choose the hyperlinks proposition strategies in the preferences menu. The figure below shows some implemented strategies:


Papyrus Hyperlink Preferences

Misc. UI Enhancements

Some other UI enhancements are implemented:

  • Integration in Eclipse history to navigate to the previous/next diagram (even in different models) in the order they were opened (Gerrit 46228)
  • Toolbar arrows to navigate between opened Papyrus diagram tabs (Gerrit 51264)
  • Key bindings (CTRL+(SHIFT+)TAB) to navigate between opened Papyrus diagram tabs (Gerrit 46192)
  • Diagram shortcuts show a preview of the diagram on mouse hover (Gerrit 47035)
  • Clicking on a search result that's a semantic element, navigates to the element in the model explorer (Gerrit 52726)
  • Hyperlink pointing to a document (resp. website) has the document's default icon (resp. website's favicon) (in navigation alt menu patch)

Developer Documentation

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:

  • Interface org.eclipse.papyrus.infra.services.navigation.service.ExtendedNavigableElement
    • Classes that implement this interface are navigable elements, i.e. something that wraps a semantic element, that let us navigate to some other object
    • You probably shouldn't implement this directly, but the following class:
  • Class org.eclipse.papyrus.uml.navigation.navigableElement.GenericNavigableElement
    • A generic navigable element. Your own navigable element should probably extend this class, unless you know what you are doing. :)
  • Extension point org.eclipse.papyrus.infra.services.navigation.navigationContributor
    • Specify extensions that will contribute navigable elements
  • Interface org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor
    • Classes that implement this interface contribute navigable elements
    • The "getNavigableElements(Object)" method returns navigable elements according to the context represented by the object passed as parameter. (You do not need to handle how to pass the object, only what to do with it)

Step-by-step Guide

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

  • Create a plugin
  • Add the following dependencies to MANIFEST.MF:
org.eclipse.papyrus.infra.gmfdiag.navigation
org.eclipse.papyrus.uml.navigation
  • Create a navigable element:
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
}
  • Create a navigation contributor:
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;
  }
}
  • In plugin.xml, add the following extension:
org.eclipse.papyrus.infra.services.navigation.navigationContributor
  • Right click > New > contributor
  • Fill info
    • Id: an arbitrary string
    • Contributor: reference to the class that will contribute navigable elements. Example: "SpecialTargetNavigationContributor" created beforehand.
    • Label: how this contributor is displayed in preferences (for activation/deactivation)
    • Description: tooltip displayed when the mouse hovers over this contributor in the preferences
  • (Optional) Activate/deactivate a hyperlink contributor programmatically (example for "SpecialTargetNavigationContributor" whose id is "oep.specialTargetNavigationContributor"):
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.

  • /org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/TargetNavigableElement.java
  • /org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/RelationshipNavigationContributor.java
  • /org.eclipse.papyrus.uml.navigation/plugin.xml (line 48)

Hyperlink API

API Overview

The hyperlink API has the following:

  • Extension point org.eclipse.papyrus.infra.hyperlink.hyperlinkContributor
    • Specify extensions that will contribute hyperlinks
  • Interface org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor
    • Classes that implement this interface may contribute hyperlinks
    • The "getHyperlink(Object)" method returns a list of hyperlinks according to the context represented by the object that is passed as parameter. (You do not need to handle how to pass the object, only what to do with it)

Step-by-step Guide

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

  • Create a plugin
  • Add the following dependency to MANIFEST.MF:
org.eclipse.papyrus.infra.gmfdiag.hyperlink
  • Create a hyperlink contributor:
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;
  }
}
  • In plugin.xml, add the following extension:
org.eclipse.papyrus.infra.hyperlink.hyperlinkContributor
  • Right click > New > contributor
  • Fill info
    • Id: an arbitrary text
    • Contributor: reference to the class that will contribute hyperlinks. Example: "MyHyperlinkContributor" created beforehand.
    • Label: how this contributor is displayed in preferences (for activation/deactivation)
    • Description: tooltip displayed when the mouse hovers over this contributor in the preferences
  • (Optional) Activate/deactivate a hyperlink contributor programmatically (example for MyHyperlinkContributor whose id is "oep.myHyperlinkContributor"):
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.

  • /org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/hyperlink/InnerClassHyperlinkContributor.java
  • /org.eclipse.papyrus.uml.diagram.clazz/plugin.xml (line 1733)

Bugzilla References

Back to the top