Implement Navigate To Source in a Diagram
Hello
I've implemented a diagram using com.intellij.diagram.* and would like to add navigation to source. Meaning, press F4 on a node and the corresponding PsiElement should be opened in the editor.
I tried a bit but it was not successfull.
I tried to use DiagramExtras to register extra actions
public class ReferenceDiagramExtras extends DiagramExtras<ReferenceElement> {
@Override
public List getExtraActions() {
return Arrays.asList(new ViewSourceAction());
}
}
But then, the BaseNavigateToSourceAction cannot resolve Navigatables and the following returns null:@Nullable
protected Navigatable[] getNavigatables(DataContext var1) {
return (Navigatable[])CommonDataKeys.NAVIGATABLE_ARRAY.getData(var1);
}
As I tried to subclass ViewSourceAction and to return Navigatables for my own, then, suprisingly, the overwritten method getNavigatables() was not called.
Has anybody an idea?
Or are there any open source plugins out there using the diagram framework com.intellij.diagram? I just can find the IntelliJ Diagram Demo on GitHub https://github.com/bulenkov/IntelliJIdeaDiagramDemo.
Cheers
Stefan
Please sign in to leave a comment.
Hi again
I actually figured it out for my self.
Apparently, the goto source action is already configured. But the missing part is, that the action system needs a representation of the node that is understandable, i.e. a VirtualFile or as in my case a PsiElement.
That is done by DiagramExtras#getData.