How to open and close tabs programatically

  1. I want to know all tabs currently open

  2. an event when a tab opens and also an event when a tab closes

  3. want to open and close the tab with uri

[original thread by Harshith Mullapudi]

[Harshith Mullapudi]

I looked through editor manager which has open function and similarly is there a close function ? and how do I do the above 1 and 2

  • There is ApplicationShell which can provide you with information about opened areas, tabs, widgets and relationships between them.

Each widget has close function to close it.

I would need to check but i think tabs are widgets as well.

yes, it is, so you just call close on TabBar

[Harshith Mullapudi]

Yeah I already checked that can you help in adding tabs if I know the uri

[Harshith Mullapudi]

I meant opening tabs

You shoud use OpenerService to open an URI, as a second argument you can provide options where a new widget should be opened, i.e. which area, should it open relatively to other widgets somehow and so on

https://github.com/theia-ide/theia/blob/01a70870cba95b8ef86e477aee90e8df5a052a88/packages/core/src/browser/opener-service.ts#L80 - OpenerService

https://github.com/theia-ide/theia/blob/01a70870cba95b8ef86e477aee90e8df5a052a88/packages/core/src/browser/widget-open-handler.ts#L28 - WidgetOpenerOptions