How to enable duplication of theia widgets

Now there are several widgets in theia like explorer, outline, output, problem, terminal, git, etc. Let’s consider the output widget example here. It’s not visible by default(On load), but can be opened on the bottom panel area by clicking on View menu-> Output submenu. Now, once it’s opened, if I click on View menu->Output submenu again, nothing happens. But I want another instance of Output widget in the same bottom panel area. How do I achieve that?

[original thread by rhendricks]

[Hanksha]

It’s based on the id of the widget. If you set a different id to the widget every time it is opened you’ll be able to duplicate it.

By default as a user you cannot there can be only one output view by design. If you are developing a custom product then you can follow an advice from @hanksha and define own widget factory supporting multiple instances of the output widget.

[rhendricks]

@hanksha @anton-kosyakov now I have multiple widgets open in the main panel. I want to set the closable option on the widget to false if there is only one instance and true if there are multiple instances. I need to have at least one widget enabled at all times. How can I achieve that?

[Hanksha]

You can have something like a WidgetTitleManager that you inject in each widget, the widget would call titleManager.manage(this) in the constructor/init. The manager would then update the title of each registered widget when one is created or disposed. Or you can also make the WidgetTitleManager just listen to WidgetManager.onDidCreateWidget on startup so it can manage the widgets from the outside.