eclipse-rcpeclipse-emfeclipse-pdeeclipse-gefeclipse-gmf

How to highlight a node in GMF based editor?


I am in the process of implementing search functionality in my GMF editor. So what i am planning to do is utilize EMF Search plugin to search within the EMF objects. But when I click on the search result I will be opening the diagram with the node pre-selected.

Is there a way in which I can traverse through all the nodes in a GMF based diagram and highlight a node based on some parameters?


Solution

  • I figured out how to do this. Found the solution in this forum post -

    http://www.eclipse.org/forums/index.php/m/734758/

    Quote

    I did something similar for the YAKINDU Statechart Tools version 2.0. It is a Statechart Tool where you can execute the statechart model, the active states are highlighted in the diagram editor then. (see http://muelder.blogspot.com/2011/09/new-features-in-sct-2-milestone-5.html) for a screenshot.

    Technically, all the highlighting stuff is encapsulated in a single class called HighlightingSupportAdapter. Maybe you want to have a look in the code, it is open source. It is a generic HighlightingAdapter, that can be applied to every GMF based editor. A semantic element is passed to the adapter as well as the higlighting color and the highlighting time. Maybe this is a good start for your use case!