提交 62bb9b3d 编写于 作者: B Benjamin Pasero

shared process - adopt toggle method from management service

上级 65582ba3
......@@ -14,6 +14,4 @@ export interface ISharedProcessService {
getChannel(channelName: string): IChannel;
registerChannel(channelName: string, channel: IServerChannel<string>): void;
toggleWindow(): Promise<void>;
}
......@@ -128,5 +128,6 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
export const CATEGORIES = {
View: { value: localize('view', "View"), original: 'View' },
Help: { value: localize('help', "Help"), original: 'Help' },
Preferences: { value: localize('preferences', "Preferences"), original: 'Preferences' },
Developer: { value: localize({ key: 'developer', comment: ['A developer on Code itself or someone diagnosing issues in Code'] }, "Developer"), original: 'Developer' }
};
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { CATEGORIES } from 'vs/workbench/common/actions';
class ToggleSharedProcessAction extends Action2 {
constructor() {
super({
id: 'workbench.action.toggleSharedProcess',
title: { value: nls.localize('toggleSharedProcess', "Toggle Shared Process"), original: 'Toggle Shared Process' },
category: CATEGORIES.Developer,
f1: true
});
}
async run(accessor: ServicesAccessor): Promise<void> {
return accessor.get(ISharedProcessService).toggleWindow();
}
}
registerAction2(ToggleSharedProcessAction);
......@@ -3,48 +3,82 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Action } from 'vs/base/common/actions';
import * as nls from 'vs/nls';
import { localize } from 'vs/nls';
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { Action2, MenuId } from 'vs/platform/actions/common/actions';
import { CATEGORIES } from 'vs/workbench/common/actions';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ISharedProcessManagementService } from 'vs/platform/sharedProcess/common/sharedProcessManagement';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IsDevelopmentContext } from 'vs/platform/contextkey/common/contextkeys';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
export class ToggleDevToolsAction extends Action {
export class ToggleDevToolsAction extends Action2 {
static readonly ID = 'workbench.action.toggleDevTools';
static readonly LABEL = nls.localize('toggleDevTools', "Toggle Developer Tools");
constructor(
id: string,
label: string,
@INativeHostService private readonly nativeHostService: INativeHostService
) {
super(id, label);
constructor() {
super({
id: 'workbench.action.toggleDevTools',
title: { value: localize('toggleDevTools', "Toggle Developer Tools"), original: 'Toggle Developer Tools' },
category: CATEGORIES.Developer,
f1: true,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib + 50,
when: IsDevelopmentContext,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_I,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_I }
},
menu: {
id: MenuId.MenubarHelpMenu,
group: '5_tools',
order: 1
}
});
}
run(): Promise<void> {
return this.nativeHostService.toggleDevTools();
async run(accessor: ServicesAccessor): Promise<void> {
const nativeHostService = accessor.get(INativeHostService);
return nativeHostService.toggleDevTools();
}
}
export class ConfigureRuntimeArgumentsAction extends Action {
static readonly ID = 'workbench.action.configureRuntimeArguments';
static readonly LABEL = nls.localize('configureRuntimeArguments', "Configure Runtime Arguments");
export class ConfigureRuntimeArgumentsAction extends Action2 {
constructor(
id: string,
label: string,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@IEditorService private readonly editorService: IEditorService
) {
super(id, label);
constructor() {
super({
id: 'workbench.action.configureRuntimeArguments',
title: { value: localize('configureRuntimeArguments', "Configure Runtime Arguments"), original: 'Configure Runtime Arguments' },
category: CATEGORIES.Preferences,
f1: true
});
}
async run(): Promise<void> {
await this.editorService.openEditor({
resource: this.environmentService.argvResource,
async run(accessor: ServicesAccessor): Promise<void> {
const editorService = accessor.get(IEditorService);
const environmentService = accessor.get(IWorkbenchEnvironmentService);
await editorService.openEditor({
resource: environmentService.argvResource,
options: { pinned: true }
});
}
}
export class ToggleSharedProcessAction extends Action2 {
constructor() {
super({
id: 'workbench.action.toggleSharedProcess',
title: { value: localize('toggleSharedProcess', "Toggle Shared Process"), original: 'Toggle Shared Process' },
category: CATEGORIES.Developer,
f1: true
});
}
async run(accessor: ServicesAccessor): Promise<void> {
return accessor.get(ISharedProcessManagementService).toggleWindow();
}
}
......@@ -71,10 +71,6 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe
registerChannel(channelName: string, channel: IServerChannel<string>): void {
this.withSharedProcessConnection.then(connection => connection.registerChannel(channelName, channel));
}
toggleWindow(): Promise<void> {
return this.sharedProcessManagementService.toggleWindow();
}
}
registerSingleton(ISharedProcessService, SharedProcessService, true);
......@@ -151,8 +151,6 @@ export class TestSharedProcessService implements ISharedProcessService {
getChannel(channelName: string): any { return undefined; }
registerChannel(channelName: string, channel: any): void { }
async toggleWindow(): Promise<void> { }
}
export class TestNativeHostService implements INativeHostService {
......
......@@ -23,13 +23,6 @@ import 'vs/workbench/workbench.sandbox.main';
//#endregion
//#region --- workbench actions
import 'vs/workbench/electron-browser/actions/developerActions';
//#endregion
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// NOTE: Please do NOT register services here. Use `registerSingleton()`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册