IWindowsService.openWorkspace()

This commit is contained in:
Benjamin Pasero
2017-07-11 18:21:25 +02:00
parent 73a8e4f395
commit 3ec53bfaa7
7 changed files with 29 additions and 14 deletions
@@ -11,6 +11,7 @@ import Event from 'vs/base/common/event';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { IWorkspace } from "vs/platform/workspaces/common/workspaces";
export const IWindowsService = createDecorator<IWindowsService>('windowsService');
@@ -46,6 +47,8 @@ export interface IWindowsService {
quit(): TPromise<void>;
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void>;
openWorkspace(windowId: number, workspace: IWorkspace): TPromise<void>;
// Shared process
whenSharedProcessReady(): TPromise<void>;
toggleSharedProcess(): TPromise<void>;
@@ -10,6 +10,7 @@ import Event, { buffer } from 'vs/base/common/event';
import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc';
import { IWindowsService } from './windows';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspace } from "vs/platform/workspaces/common/workspaces";
export interface IWindowsChannel extends IChannel {
call(command: 'event:onWindowOpen'): TPromise<number>;
@@ -42,6 +43,7 @@ export interface IWindowsChannel extends IChannel {
call(command: 'getWindows'): TPromise<{ id: number; path: string; title: string; }[]>;
call(command: 'getWindowCount'): TPromise<number>;
call(command: 'relaunch', arg: { addArgs?: string[], removeArgs?: string[] }): TPromise<number>;
call(command: 'openWorkspace', arg: [number, IWorkspace]): TPromise<void>;
call(command: 'whenSharedProcessReady'): TPromise<void>;
call(command: 'toggleSharedProcess'): TPromise<void>;
call(command: 'log', arg: [string, string[]]): TPromise<void>;
@@ -94,6 +96,7 @@ export class WindowsChannel implements IWindowsChannel {
case 'getWindows': return this.service.getWindows();
case 'getWindowCount': return this.service.getWindowCount();
case 'relaunch': return this.service.relaunch(arg[0]);
case 'openWorkspace': return this.service.openWorkspace(arg[0], arg[1]);
case 'whenSharedProcessReady': return this.service.whenSharedProcessReady();
case 'toggleSharedProcess': return this.service.toggleSharedProcess();
case 'quit': return this.service.quit();
@@ -215,6 +218,10 @@ export class WindowsChannelClient implements IWindowsService {
return this.channel.call('relaunch', [options]);
}
openWorkspace(windowId: number, workspace: IWorkspace): TPromise<void> {
return this.channel.call('openWorkspace', [windowId, workspace]);
}
whenSharedProcessReady(): TPromise<void> {
return this.channel.call('whenSharedProcessReady');
}
@@ -20,6 +20,7 @@ import { ILifecycleService } from "vs/platform/lifecycle/electron-main/lifecycle
import { IWindowsMainService, ISharedProcess } from "vs/platform/windows/electron-main/windows";
import { IHistoryMainService } from "vs/platform/history/electron-main/historyMainService";
import { findExtensionDevelopmentWindow } from "vs/code/node/windowsFinder";
import { IWorkspace } from "vs/platform/workspaces/common/workspaces";
export class WindowsService implements IWindowsService, IDisposable {
@@ -322,6 +323,16 @@ export class WindowsService implements IWindowsService, IDisposable {
return TPromise.as(null);
}
openWorkspace(windowId: number, workspace: IWorkspace): TPromise<void> {
const codeWindow = this.windowsMainService.getWindowById(windowId);
if (codeWindow) {
this.windowsMainService.open({ context: OpenContext.API, cli: this.environmentService.args, pathsToOpen: [workspace.workspaceConfigPath], windowToUse: codeWindow });
}
return TPromise.as(null);
}
whenSharedProcessReady(): TPromise<void> {
return this.sharedProcess.whenReady();
}
@@ -30,5 +30,4 @@ export interface IWorkspacesService {
_serviceBrand: any;
createWorkspace(folders?: string[]): TPromise<IWorkspace>;
openWorkspace(workspace: IWorkspace): void;
}
@@ -11,7 +11,6 @@ import { IWorkspacesService, IWorkspace } from 'vs/platform/workspaces/common/wo
export interface IWorkspacesChannel extends IChannel {
call(command: 'createWorkspace', arg: [string[]]): TPromise<string>;
call(command: 'openWorkspace', arg: [IWorkspace]): TPromise<string>;
call(command: string, arg?: any): TPromise<any>;
}
@@ -22,7 +21,6 @@ export class WorkspacesChannel implements IWorkspacesChannel {
call(command: string, arg?: any): TPromise<any> {
switch (command) {
case 'createWorkspace': return this.service.createWorkspace(arg);
case 'openWorkspace': this.service.openWorkspace(arg);
}
return void 0;
@@ -38,8 +36,4 @@ export class WorkspacesChannelClient implements IWorkspacesService {
createWorkspace(folders?: string[]): TPromise<IWorkspace> {
return this.channel.call('createWorkspace', folders);
}
openWorkspace(workspace: IWorkspace): void {
this.channel.call('openWorkspace', workspace);
}
}
@@ -45,10 +45,6 @@ export class WorkspacesMainService implements IWorkspacesMainService {
});
}
public openWorkspace(workspace: IWorkspace): void {
}
private nextWorkspaceId(): string {
return (Date.now() + Math.round(Math.random() * 1000)).toString();
}
@@ -27,7 +27,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IEditorInput, IEditorOptions, Position, Direction, IEditor, IResourceInput, ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { IMessageService, IConfirmation } from 'vs/platform/message/common/message';
import { ILegacyWorkspace, IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace';
import { ILegacyWorkspace, IWorkspaceContextService, IWorkspace as IWorkbenchWorkspace } from 'vs/platform/workspace/common/workspace';
import { ILifecycleService, ShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { EditorStacksModel } from 'vs/workbench/common/editor/editorStacksModel';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
@@ -54,6 +54,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { isLinux } from 'vs/base/common/platform';
import { generateUuid } from 'vs/base/common/uuid';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { IWorkspace } from "vs/platform/workspaces/common/workspaces";
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
return instantiationService.createInstance(FileEditorInput, resource, void 0);
@@ -64,7 +65,7 @@ export const TestEnvironmentService = new EnvironmentService(parseArgs(process.a
export class TestContextService implements IWorkspaceContextService {
public _serviceBrand: any;
private workspace: IWorkspace;
private workspace: IWorkbenchWorkspace;
private id: string;
private options: any;
@@ -93,7 +94,7 @@ export class TestContextService implements IWorkspaceContextService {
return this.workspace ? { resource: this.workspace.roots[0] } : void 0;
}
public getWorkspace(): IWorkspace {
public getWorkspace(): IWorkbenchWorkspace {
return this.workspace;
}
@@ -1061,6 +1062,10 @@ export class TestWindowsService implements IWindowsService {
return TPromise.as(void 0);
}
openWorkspace(windowId: number, workspace: IWorkspace): TPromise<void> {
return TPromise.as(void 0);
}
whenSharedProcessReady(): TPromise<void> {
return TPromise.as(void 0);
}