-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first cut of option-less open, #13807
- Loading branch information
Showing
6 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/vs/workbench/api/electron-browser/mainThreadDialogs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import { TPromise } from 'vs/base/common/winjs.base'; | ||
import { isFalsyOrEmpty } from 'vs/base/common/arrays'; | ||
import { MainThreadDiaglogsShape, MainContext, IExtHostContext } from '../node/extHost.protocol'; | ||
import { extHostNamedCustomer } from "vs/workbench/api/electron-browser/extHostCustomers"; | ||
import { IWindowService } from "vs/platform/windows/common/windows"; | ||
|
||
@extHostNamedCustomer(MainContext.MainThreadDialogs) | ||
export class MainThreadDialogs implements MainThreadDiaglogsShape { | ||
|
||
constructor( | ||
context: IExtHostContext, | ||
@IWindowService private readonly _windowService: IWindowService | ||
) { | ||
// | ||
} | ||
|
||
dispose(): void { | ||
// | ||
} | ||
|
||
$showOpenDialog(): TPromise<string[]> { | ||
return new TPromise<string[]>(resolve => { | ||
this._windowService.showOpenDialog({ | ||
|
||
}, filenames => { | ||
// TODO@joh what about remote dev setup? | ||
resolve(isFalsyOrEmpty(filenames) ? undefined : filenames); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import { MainContext, MainThreadDiaglogsShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol'; | ||
import URI from "vs/base/common/uri"; | ||
|
||
export class ExtHostDialogs { | ||
|
||
private readonly _proxy: MainThreadDiaglogsShape; | ||
|
||
constructor(mainContext: IMainContext) { | ||
this._proxy = mainContext.get(MainContext.MainThreadDialogs); | ||
} | ||
|
||
showOpenDialog(): Thenable<URI[]> { | ||
return this._proxy.$showOpenDialog().then(filepaths => { | ||
if (!filepaths) { | ||
return undefined; | ||
} | ||
return filepaths.map(URI.file); | ||
}); | ||
} | ||
} |