Open workspace dialog

Is there a way to add an extension that will open the open-workspace dialog on a specific folder?

[original thread by Limor Erez]

Are you looking to providing an extension which contributes a new command to open a workspace at a specific folder? We have the method showOpenDialog which allows you to open the workspace dialog with respect of a given folder.

@limor-erez Theia or VS Code extension?

[Limor Erez]

@anton-kosyakov Is it possible to do it with VS Code extension? The open-workspace dialog looks like a Theia specific dialog.

[Limor Erez]

@vince-fugnitto Yes I would like to provide an extension. I am new in the Theia extension world. Could you please send an example on how to use the ‘showOpenDialog’?

@limor-erez check vscode.window.openDialog or something like that

Theia is capable of running VS Code extensions

[Limor Erez]

@anton-kosyakov yes I know but I would like to change the behavior of the open-workspace dialog which, to my understanding, is a Theia specific dialog. In viscose when there is no project /folder open you p

[Limor Erez]

@anton-kosyakov I VS code when there is no open/folder open you open window open-folder dialog.

ok, in this case Theia extenison is indeed a good choice

@limor-erez I’ve created a small example extension which provides and registers a new command which when executed, triggers file-dialog-service to open a dialog https://github.com/vince-fugnitto/theia-open-dialog

If you require more examples, you can check for occurrences in the main Theia repo for other examples: https://github.com/theia-ide/theia/search?q=showOpenDialog&unscoped_q=showOpenDialog

[Limor Erez]

@vince-fugnitto Thanks a lot for the example. But I would like to change the current behaviour of the Open-Workspace command not creating a new command.

You should subclass WorkspaceFrontendContribution, change implementation of doOpenWorkspace: https://github.com/theia-ide/theia/blob/bc5ef144f35c4b16771ed171021ae44fb907e963/packages/workspace/src/browser/workspace-frontend-contribution.ts#L273-L285

and then rebind WorkspaceFrontendContribution symbol to your subclass

[Limor Erez]

@anton-kosyakov I implemented it the way you’ve recommended but I was wondering if it possible to avoid overwrite the doOpenWorkspace method and to change ( contribute ) this function and add an optional parameter folder (folder?: FileStat)?

@limor-erez what will be the motivation? Would you be able to avoid subclassing WorkspaceFrontendContribution with it?

[Limor Erez]

yes. I would like to avoid copy-paste of code if the only thing I need is to pass the initial folder location

[Limor Erez]

@anton-kosyakov yes. I would like to avoid copy-paste of code if the only thing I need is to pass the initial folder location

if it is not much effort just open a PR, we can review and consider applying