diff --git a/src/vs/code/node/sharedProcessMain.ts b/src/vs/code/node/sharedProcessMain.ts index 36e367654aec025263568afd546ce8d6818290ca..a3ceb02679ebce8aaeedb6e5ca195c89d75d5d3e 100644 --- a/src/vs/code/node/sharedProcessMain.ts +++ b/src/vs/code/node/sharedProcessMain.ts @@ -30,8 +30,10 @@ import { TelemetryAppenderChannel } from 'vs/platform/telemetry/common/telemetry import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService'; import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender'; import { ISharedProcessInitData } from './sharedProcess'; +import {IChoiceService} from 'vs/platform/message/common/message'; +import {ChoiceChannelClient} from 'vs/platform/message/common/messageIpc'; import { WindowEventChannelClient } from 'vs/code/common/windowsIpc'; -import { IWindowEventService } from 'vs/code/common/windows'; +import { IWindowEventService, ActiveWindowManager } from 'vs/code/common/windows'; function quit(err?: Error) { if (err) { @@ -71,6 +73,13 @@ function main(server: Server, initData: ISharedProcessInitData): void { })); services.set(IWindowEventService, windowEventService); + const activeWindowManager = new ActiveWindowManager(windowEventService); + services.set(IChoiceService, new ChoiceChannelClient(server.getChannel('choice', { + routeCall: (command: any, arg: any) => { + return activeWindowManager.activeWindowId; + } + }))); + const instantiationService = new InstantiationService(services); instantiationService.invokeFunction(accessor => { @@ -146,7 +155,7 @@ function setupIPC(hook: string): TPromise { } catch (e) { return TPromise.wrapError(new Error('Error deleting the shared ipc hook.')); } - + return setup(false); } ); diff --git a/src/vs/workbench/services/message/common/messageIpc.ts b/src/vs/platform/message/common/messageIpc.ts similarity index 62% rename from src/vs/workbench/services/message/common/messageIpc.ts rename to src/vs/platform/message/common/messageIpc.ts index 1a7c86aaef427c9b4a56f381059a7a0942828fe4..c36980b2eaf1f5d14633d6550e822d0a4a70edf6 100644 --- a/src/vs/workbench/services/message/common/messageIpc.ts +++ b/src/vs/platform/message/common/messageIpc.ts @@ -7,12 +7,10 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { IChannel } from 'vs/base/parts/ipc/common/ipc'; -import { IChoiceService/*, Severity*/ } from 'vs/platform/message/common/message'; - -// TODO@Sandeep implement these guys +import { IChoiceService, Severity } from 'vs/platform/message/common/message'; export interface IChoiceChannel extends IChannel { - // call(command: 'getInstalled'): TPromise; + call(command: 'choose'): TPromise; call(command: string, arg: any): TPromise; } @@ -21,22 +19,22 @@ export class ChoiceChannel implements IChoiceChannel { constructor(private service: IChoiceService) { } - call(command: string, arg: any): TPromise { + call(command: string, args: any): TPromise { switch (command) { - // case 'getInstalled': return this.service.getInstalled(arg); + case 'choose': return this.service.choose(args[0], args[1], args[2]); } - return TPromise.wrapError('invalid command'); } } -export class ChoiceChannelClient /*implements IChoiceService*/ { +export class ChoiceChannelClient implements IChoiceService { _serviceBrand: any; constructor(private channel: IChoiceChannel) { } - // getInstalled(type: LocalExtensionType = null): TPromise { - // return this.channel.call('getInstalled', type); - // } + choose(severity: Severity, message: string, options: string[]): TPromise { + return this.channel.call('choose', [severity, message, options]); + } + } \ No newline at end of file diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index fecf173822e1fcaaf7be8ed2faeb78f308fbef4d..5aa5f5dad682f13b3227f133ecfa2624b726ef36 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -59,6 +59,7 @@ import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle'; import {IMarkerService} from 'vs/platform/markers/common/markers'; import {IEnvironmentService} from 'vs/platform/environment/common/environment'; import {IMessageService, IChoiceService, Severity} from 'vs/platform/message/common/message'; +import {ChoiceChannel} from 'vs/platform/message/common/messageIpc'; import {ISearchService} from 'vs/platform/search/common/search'; import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; import {ICommandService} from 'vs/platform/commands/common/commands'; @@ -228,6 +229,9 @@ export class WorkbenchShell { const sharedProcess = connectNet(this.environmentService.sharedIPCHandle, `window:${ this.windowService.getWindowId() }`); sharedProcess.done(client => { + + client.registerChannel('choice', new ChoiceChannel(this.messageService)); + client.onClose(() => { this.messageService.show(Severity.Error, { message: nls.localize('sharedProcessCrashed', "The shared process terminated unexpectedly. Please reload the window to recover."),