提交 8c8e2a88 编写于 作者: B Benjamin Pasero

debt - make dialog handlers a workbench core piece

//cc @sbatten
上级 c58384b8
......@@ -13,11 +13,12 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { IDialogsModel, IDialogViewItem } from 'vs/workbench/common/dialogs';
import { HTMLDialogHandler } from 'vs/workbench/contrib/dialogs/browser/dialogHandler';
import { BrowserDialogHandler } from 'vs/workbench/browser/parts/dialogs/dialogHandler';
import { DialogService } from 'vs/workbench/services/dialogs/common/dialogService';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Disposable } from 'vs/base/common/lifecycle';
export class DialogHandlerContribution implements IWorkbenchContribution {
export class DialogHandlerContribution extends Disposable implements IWorkbenchContribution {
private impl: IDialogHandler;
private model: IDialogsModel;
......@@ -32,15 +33,17 @@ export class DialogHandlerContribution implements IWorkbenchContribution {
@IProductService productService: IProductService,
@IClipboardService clipboardService: IClipboardService
) {
this.impl = new HTMLDialogHandler(logService, layoutService, themeService, keybindingService, productService, clipboardService);
super();
this.impl = new BrowserDialogHandler(logService, layoutService, themeService, keybindingService, productService, clipboardService);
this.model = (this.dialogService as DialogService).model;
this.model.onDidShowDialog(() => {
this._register(this.model.onDidShowDialog(() => {
if (!this.currentDialog) {
this.processDialogs();
}
});
}));
this.processDialogs();
}
......@@ -71,4 +74,3 @@ export class DialogHandlerContribution implements IWorkbenchContribution {
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(DialogHandlerContribution, LifecyclePhase.Starting);
......@@ -19,7 +19,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { fromNow } from 'vs/base/common/date';
export class HTMLDialogHandler implements IDialogHandler {
export class BrowserDialogHandler implements IDialogHandler {
private static readonly ALLOWABLE_COMMANDS = [
'copy',
......@@ -88,7 +88,7 @@ export class HTMLDialogHandler implements IDialogHandler {
keyEventProcessor: (event: StandardKeyboardEvent) => {
const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
if (resolved && resolved.commandId) {
if (HTMLDialogHandler.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
if (BrowserDialogHandler.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
EventHelper.stop(event, true);
}
}
......
......@@ -15,14 +15,15 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { IDialogsModel, IDialogViewItem } from 'vs/workbench/common/dialogs';
import { HTMLDialogHandler } from 'vs/workbench/contrib/dialogs/browser/dialogHandler';
import { NativeDialogHandler } from 'vs/workbench/contrib/dialogs/electron-sandbox/dialogHandler';
import { BrowserDialogHandler } from 'vs/workbench/browser/parts/dialogs/dialogHandler';
import { NativeDialogHandler } from 'vs/workbench/electron-sandbox/parts/dialogs/dialogHandler';
import { DialogService } from 'vs/workbench/services/dialogs/common/dialogService';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Disposable } from 'vs/base/common/lifecycle';
export class DialogHandlerContribution implements IWorkbenchContribution {
export class DialogHandlerContribution extends Disposable implements IWorkbenchContribution {
private nativeImpl: IDialogHandler;
private customImpl: IDialogHandler;
private browserImpl: IDialogHandler;
private model: IDialogsModel;
private currentDialog: IDialogViewItem | undefined;
......@@ -38,16 +39,18 @@ export class DialogHandlerContribution implements IWorkbenchContribution {
@IClipboardService clipboardService: IClipboardService,
@INativeHostService nativeHostService: INativeHostService
) {
this.customImpl = new HTMLDialogHandler(logService, layoutService, themeService, keybindingService, productService, clipboardService);
super();
this.browserImpl = new BrowserDialogHandler(logService, layoutService, themeService, keybindingService, productService, clipboardService);
this.nativeImpl = new NativeDialogHandler(logService, nativeHostService, productService, clipboardService);
this.model = (this.dialogService as DialogService).model;
this.model.onDidShowDialog(() => {
this._register(this.model.onDidShowDialog(() => {
if (!this.currentDialog) {
this.processDialogs();
}
});
}));
this.processDialogs();
}
......@@ -59,16 +62,16 @@ export class DialogHandlerContribution implements IWorkbenchContribution {
let result: IDialogResult | undefined = undefined;
if (this.currentDialog.args.confirmArgs) {
const args = this.currentDialog.args.confirmArgs;
result = this.useCustomDialog ? await this.customImpl.confirm(args.confirmation) : await this.nativeImpl.confirm(args.confirmation);
result = this.useCustomDialog ? await this.browserImpl.confirm(args.confirmation) : await this.nativeImpl.confirm(args.confirmation);
} else if (this.currentDialog.args.inputArgs) {
const args = this.currentDialog.args.inputArgs;
result = this.useCustomDialog ?
await this.customImpl.input(args.severity, args.message, args.buttons, args.inputs, args.options) :
await this.browserImpl.input(args.severity, args.message, args.buttons, args.inputs, args.options) :
await this.nativeImpl.input(args.severity, args.message, args.buttons, args.inputs, args.options);
} else if (this.currentDialog.args.showArgs) {
const args = this.currentDialog.args.showArgs;
result = this.useCustomDialog ?
await this.customImpl.show(args.severity, args.message, args.buttons, args.options) :
await this.browserImpl.show(args.severity, args.message, args.buttons, args.options) :
await this.nativeImpl.show(args.severity, args.message, args.buttons, args.options);
} else {
await this.nativeImpl.about();
......@@ -86,4 +89,3 @@ export class DialogHandlerContribution implements IWorkbenchContribution {
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(DialogHandlerContribution, LifecyclePhase.Starting);
......@@ -31,12 +31,8 @@ interface IMassagedMessageBoxOptions {
buttonIndexMap: number[];
}
export class NativeDialogHandler implements IDialogHandler {
declare readonly _serviceBrand: undefined;
constructor(
@ILogService private readonly logService: ILogService,
@INativeHostService private readonly nativeHostService: INativeHostService,
......
......@@ -132,9 +132,6 @@ import 'vs/workbench/contrib/debug/node/debugHelperService';
// Webview
import 'vs/workbench/contrib/webview/electron-browser/webview.contribution';
// Dialogs
import 'vs/workbench/contrib/dialogs/electron-sandbox/dialog.contribution';
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
......
......@@ -16,10 +16,12 @@ import 'vs/workbench/workbench.common.main';
//#endregion
import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
import { UserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataAutoSyncService';
registerSingleton(IUserDataAutoSyncEnablementService, UserDataAutoSyncEnablementService);
//#region --- workbench parts
import 'vs/workbench/electron-sandbox/parts/dialogs/dialog.contribution';
//#endregion
//#region --- workbench services
......@@ -51,9 +53,12 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ITimerService } from 'vs/workbench/services/timer/browser/timerService';
import { TimerService } from 'vs/workbench/services/timer/electron-sandbox/timerService';
import { IUserDataInitializationService, UserDataInitializationService } from 'vs/workbench/services/userData/browser/userDataInit';
import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
import { UserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataAutoSyncService';
registerSingleton(ITimerService, TimerService);
registerSingleton(IUserDataInitializationService, UserDataInitializationService);
registerSingleton(IUserDataAutoSyncEnablementService, UserDataAutoSyncEnablementService);
//#endregion
......
......@@ -18,6 +18,13 @@ import 'vs/workbench/workbench.common.main';
//#endregion
//#region --- workbench parts
import 'vs/workbench/browser/parts/dialogs/dialog.web.contribution';
//#endregion
//#region --- workbench (web main)
import 'vs/workbench/browser/web.main';
......@@ -116,9 +123,6 @@ import 'vs/workbench/contrib/debug/browser/extensionHostDebugService';
// Webview
import 'vs/workbench/contrib/webview/browser/webview.web.contribution';
// Dialog
import 'vs/workbench/contrib/dialogs/browser/dialog.contribution';
// Terminal
import 'vs/workbench/contrib/terminal/browser/terminal.web.contribution';
import 'vs/workbench/contrib/terminal/browser/terminalInstanceService';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册