LineMarkerProvider navigating to multiple targets
Hi Jetbrains,
In this post I learned that I could use com.intellij.database.view.DbNavigationUtils#navigateToData(com.intellij.database.psi.DbElement, boolean) to navigate to the database grid from my line marker provider. Awesome :)
I've been able to apply this to navigate to a single table in the table editor:val targets : Collection<DbTable> = [...]
if (targets.isEmpty())
return
val builder = NavigationGutterIconBuilder.create(Icons.TABLE)
.setTargets(targets)
.setTooltipText("...")
result.add(builder.createLineMarkerInfo(element) { _, _ ->
DbNavigationUtils.navigateToData(targets.first(), true)
})
However, I have a Collection of DbElement objects instead of a single one. I would like to show a popup with an entry for each element in targets
. Should I call createLineMarkerInfo()
multiple times? Or should I use a single RelatedItemLineMarkerInfo
and handle the popup in some other way?
I've tried the former:
targets.forEach {
result.add(builder.createLineMarkerInfo(element) { _, _ ->
DbNavigationUtils.navigateToData(it, true)
})
}
While this does give me a popup, all entries in the popup look exactly the same (presumably because they're all based on element
and not on the different items in targets
).
I've not had much luck coming up with a solution that uses a single RelatedItemLineMarkerInfo
.
What would be the best approach here?
Thanks,
Guno
Please sign in to leave a comment.
If you pass multiple targets via
setTargets()
you must automatically get a popup with all provided navigation targets.Note, you can customize/improve the rendering of the items in the popup via
setCellRenderer()
methods.You want to install _one_ linemarker gutter icon to navigate to all possible targets. Please try
createLineMarkerInfo()
without passing in your customGutterIconNavigationHandler
.Hi Yann Cebron,
Thanks for your response!
I added the
GutterIconNavigationHandler
as it was the only way I could manage to fit the custom navigation logic (DbNavigationUtils.navigateToData(it, true)
) in to my line marker provider. Without it, it would navigate to the database table's ddl instead of to the database table grid/editor.What would be the proper way to navigate from my line marker provider to the database table grid/editor, if not through a custom navigation handler?
Thanks,
Guno
One more idea, DO provide your custom
GutterIconNavigationHandler
and show popup chooser with all items from it viacom.intellij.openapi.ui.popup.JBPopupFactory#createPopupChooserBuilder()
, then perform explicit navigation code for DB items from itssetItemsChosenCallback
method.Yes, thank you, this does the trick!