How to render specific options in Theia's context menu?

I am currently working on a project where I programmed a context menu to appear when I right click on the elements of a folder tree structure.For the tree structure I used the one provided by Theia. Now I need to render specific options in the context menu based on the element clicked.

I already know that I can show and hide options using the isVisible option in command.ts How to access the properties of the selected element to show/hide them in the context menu.

[original thread by Nithin Rauj]

[Hanksha]

You can use the SelectionService from @theia/core to get the current selection. Inject it in your handler and then call this.selectionService.selection. For a TreeWidget the type of selection is TreeWidgetSelection which is an array of the selected tree nodes and the source TreeWidget.