提交 891e6843 编写于 作者: J Johannes Rieken

first cut of option-less open, #13807

上级 d51605be
......@@ -7,6 +7,11 @@
declare module 'vscode' {
export namespace window {
export function showOpenDialog(): Thenable<Uri[]>;
}
// todo@joh discover files etc
export interface FileSystemProvider {
// todo@joh -> added, deleted, renamed, changed
......
......@@ -20,6 +20,7 @@ import './mainThreadConfiguration';
import './mainThreadCredentials';
import './mainThreadDebugService';
import './mainThreadDiagnostics';
import './mainThreadDialogs';
import './mainThreadDocumentContentProviders';
import './mainThreadDocuments';
import './mainThreadDocumentsAndEditors';
......
/*---------------------------------------------------------------------------------------------
* 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);
});
});
}
}
......@@ -52,6 +52,7 @@ import * as languageConfiguration from 'vs/editor/common/modes/languageConfigura
import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions';
import { ExtHostThreadService } from "vs/workbench/services/thread/node/extHostThreadService";
import { ProxyIdentifier } from "vs/workbench/services/thread/common/threadService";
import { ExtHostDialogs } from "vs/workbench/api/node/extHostDialogs";
export interface IExtensionApiFactory {
(extension: IExtensionDescription): typeof vscode;
......@@ -105,6 +106,7 @@ export function createApiFactory(
// Other instances
const extHostMessageService = new ExtHostMessageService(threadService);
const extHostDialogs = new ExtHostDialogs(threadService);
const extHostStatusBar = new ExtHostStatusBar(threadService);
const extHostProgress = new ExtHostProgress(threadService.get(MainContext.MainThreadProgress));
const extHostOutputService = new ExtHostOutputService(threadService);
......@@ -368,6 +370,9 @@ export function createApiFactory(
sampleFunction: proposedApiFunction(extension, () => {
return extHostMessageService.showMessage(extension.id, Severity.Info, 'Hello Proposed Api!', {}, []);
}),
showOpenDialog: proposedApiFunction(extension, () => {
return extHostDialogs.showOpenDialog();
})
};
// namespace: workspace
......
......@@ -113,6 +113,10 @@ export interface MainThreadDiagnosticsShape extends IDisposable {
$clear(owner: string): TPromise<any>;
}
export interface MainThreadDiaglogsShape extends IDisposable {
$showOpenDialog(): TPromise<string[]>;
}
export interface MainThreadDocumentContentProvidersShape extends IDisposable {
$registerTextContentProvider(handle: number, scheme: string): void;
$unregisterTextContentProvider(handle: number): void;
......@@ -532,6 +536,7 @@ export const MainContext = {
MainThreadConfiguration: createMainId<MainThreadConfigurationShape>('MainThreadConfiguration'),
MainThreadDebugService: createMainId<MainThreadDebugServiceShape>('MainThreadDebugService'),
MainThreadDiagnostics: createMainId<MainThreadDiagnosticsShape>('MainThreadDiagnostics'),
MainThreadDialogs: createMainId<MainThreadDiaglogsShape>('MainThreadDiaglogs'),
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments'),
MainThreadDocumentContentProviders: createMainId<MainThreadDocumentContentProvidersShape>('MainThreadDocumentContentProviders'),
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors'),
......
/*---------------------------------------------------------------------------------------------
* 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);
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册