Structure View questions


Hi, all! I would like to amend a bit Structure View tab and add possibility to copy/paste/move methods using that tool. Currently I've found only StructureViewPopupMenu which apears by right click on element. But I've not found how I could add new button to StructureView panel. Is it possible?

If so, how can I enable/disable that button if selection is empty?

Also I've found the way to obtain PsiElement from AnAction event, which is related to current selection in StructureView, but how can I get list of provided elements?

And last but not least) How can I override standard action from menu?

Thx )



  1. You can't add a new button to the existing structure view toolbars. The only option would be to create the custom StructureViewComponent and override createActionGroup() method. See e.g.
  2. Do you mean multiple selected elements or all the elements in the structure view? If the first, use:
    If the latter, then you may try to find it in the data context by using some keys from CommonDataKeys class (e.g. NAVIGATABLE) and inspecting available objects for the data you need.
  3. There is no way of replacing existing actions for one popup invocation. Actions replacing is possible with ActionManager.replaceAction(), but it will be global, persistent, and is definitely not recommended for built-in actions.
    You can customize menu in the popup with PopupHandler.installPopupMenu:
    PopupHandler.installPopupMenu(getTree(), customPopupGroup, IdeActions.GROUP_STRUCTURE_VIEW_POPUP);
    But this requires custom structure view implementation again. See example:

Thx a lot for your answers!


Please sign in to leave a comment.