Opening Folder in Explorer of Theia Custom IDE

I am implementing a custom IDE using Theia and I have a custom widget with a open folder button. When the button is clicked, I wanted to open a folder in the File explorer of the IDE (Similar to File -> Open Folder menu). Please let me know if there is any service that I can use to achieve this.

@Sreeranjani thank you for the discussion, if the open folder command is sufficient for you you can directly call the command yourself:

  1. inject the CommandService
  2. call this.commandService.executeCommand(WorkspaceCommands.OPEN_FOLDER.id)

Else, you can inspire yourself on how the open folder command is implemented:

1 Like

Thanks, I was able to get this working. But the folder is opening in new instance of the Theia (using electron app). Is it possible to make the folders open in the same instance?

@Sreeranjani do you mind providing additional details of what you want your use-case to achieve, as you’ve seen the open folder command will prompt users to select a folder to open as their new workspace (either as a new window or replacing the old workspace).

If you want the open folder to re-use the same workspace you’ll need to update the preference:

If it’s not an option for you to update the preference, then you’ll likely need to create your own method that does the opening similar to how it is done for open folder, without the need to use the preference.

1 Like

Thanks for the reply, I will check this out.

My use case is, I wanted to let the user select few options (maybe in a drop down) in a widget, build a path with that and open the corresponding folder.

Example:
If there are two drop downs “Name” and “Repo” user might select “Sree” and “Theia”, then I will build a path like “D:\Sree\Theia” and open it in the IDE.

The folder needs to be loaded in the same instance of the IDE but the workspace can be different. Currently new instance of IDE is opened and the selected folder gets opened as a new workspace there.