How do I dynamically add menu items to a context menu?

Hi.
I want to dynamically add menu items to a context menu.
For example, I want to add menu items for child nodes to the context menu of a parent node.
image
How can I do this?

Hey @kubomann,

I’m not sure this is easily accomplished. Context menus in Theia are spawned from commands that are registered through the CommandRegistry and are given a menu path that corresponds to a specific widget. See also the createContextMenu method.

This is quite a static (but extensible) approach to building menus. Your use case is very much dynamic, and I don’t believe that the existing context menus can be easily adapted to fit that use case. The obvious solution would be to create temporary commands for each entry in a directory and use a smart when clause on when to display these commands, but that seems overengineered. Not entirely sure what to recommend here.

Hi @msujew .

Thank you for your response.
I found it to be a difficult request.