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

dialogs - add logging

上级 3aed2331
......@@ -148,7 +148,7 @@ export class WindowsManager implements IWindowsMainService {
this.windowsState.openedWindows = [];
}
this.dialogs = new Dialogs(environmentService, telemetryService, stateService, this);
this.dialogs = new Dialogs(environmentService, telemetryService, stateService, this, this.logService);
this.workspacesManager = new WorkspacesManager(workspacesMainService, backupMainService, environmentService, this);
}
......@@ -1564,7 +1564,8 @@ class Dialogs {
private environmentService: IEnvironmentService,
private telemetryService: ITelemetryService,
private stateService: IStateService,
private windowsMainService: IWindowsMainService
private windowsMainService: IWindowsMainService,
private logService: ILogService
) {
this.mapWindowToDialogQueue = new Map<number, Queue<any>>();
this.noWindowDialogQueue = new Queue<any>();
......@@ -1644,22 +1645,33 @@ class Dialogs {
private getDialogQueue(window?: ICodeWindow): Queue<any> {
if (!window) {
this.logService.info('getDialogQueue: using NO WINDOW queue. size: ', this.noWindowDialogQueue.size);
return this.noWindowDialogQueue;
}
let windowDialogQueue = this.mapWindowToDialogQueue.get(window.id);
if (!windowDialogQueue) {
this.logService.info('getDialogQueue: creating window dialog queue for window:', window.id);
windowDialogQueue = new Queue<any>();
this.mapWindowToDialogQueue.set(window.id, windowDialogQueue);
} else {
this.logService.info('getDialogQueue: found existing window dialog queue for window:', window.id);
}
this.logService.info('getDialogQueue: size: ', windowDialogQueue.size);
return windowDialogQueue;
}
public showMessageBox(options: Electron.MessageBoxOptions, window?: ICodeWindow): TPromise<IMessageBoxResult> {
this.logService.info('showMessageBox begin: ', options, window ? window.id : 'No Window');
return this.getDialogQueue(window).queue(() => {
return new TPromise((c, e) => {
dialog.showMessageBox(window ? window.win : void 0, options, (response: number, checkboxChecked: boolean) => c({ button: response, checkboxChecked }));
this.logService.info('showMessageBox opening');
dialog.showMessageBox(window ? window.win : void 0, options, (response: number, checkboxChecked: boolean) => {
this.logService.info('showMessageBox closed, response: ', response, checkboxChecked);
c({ button: response, checkboxChecked });
});
});
});
}
......@@ -1673,9 +1685,14 @@ class Dialogs {
return path;
}
this.logService.info('showSaveDialog begin: ', options, window ? window.id : 'No Window');
return this.getDialogQueue(window).queue(() => {
return new TPromise((c, e) => {
dialog.showSaveDialog(window ? window.win : void 0, options, path => c(normalizePath(path)));
this.logService.info('showSaveDialog opening');
dialog.showSaveDialog(window ? window.win : void 0, options, path => {
this.logService.info('showSaveDialog closed, response: ', path);
c(normalizePath(path));
});
});
});
}
......@@ -1689,9 +1706,14 @@ class Dialogs {
return paths;
}
this.logService.info('showOpenDialog begin: ', options, window ? window.id : 'No Window');
return this.getDialogQueue(window).queue(() => {
return new TPromise((c, e) => {
dialog.showOpenDialog(window ? window.win : void 0, options, paths => c(normalizePaths(paths)));
this.logService.info('showOpenDialog opening');
dialog.showOpenDialog(window ? window.win : void 0, options, paths => {
this.logService.info('showOpenDialog closed, response: ', paths);
c(normalizePaths(paths));
});
});
});
}
......
......@@ -11,6 +11,7 @@ import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorksp
import { IRecentlyOpened } from 'vs/platform/history/common/history';
import { ICommandAction } from 'vs/platform/actions/common/actions';
import { IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
import { ILogService } from 'vs/platform/log/common/log';
export class WindowService implements IWindowService {
......@@ -21,7 +22,8 @@ export class WindowService implements IWindowService {
constructor(
private windowId: number,
private configuration: IWindowConfiguration,
@IWindowsService private windowsService: IWindowsService
@IWindowsService private windowsService: IWindowsService,
@ILogService private logService: ILogService
) {
const onThisWindowFocus = mapEvent(filterEvent(windowsService.onWindowFocus, id => id === windowId), _ => true);
const onThisWindowBlur = mapEvent(filterEvent(windowsService.onWindowBlur, id => id === windowId), _ => false);
......@@ -39,24 +41,32 @@ export class WindowService implements IWindowService {
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
options.windowId = this.windowId;
this.logService.info('pickFileFolderAndOpen: begin');
return this.windowsService.pickFileFolderAndOpen(options);
}
pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
options.windowId = this.windowId;
this.logService.info('pickFileAndOpen: begin');
return this.windowsService.pickFileAndOpen(options);
}
pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
options.windowId = this.windowId;
this.logService.info('pickFolderAndOpen: begin');
return this.windowsService.pickFolderAndOpen(options);
}
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
options.windowId = this.windowId;
this.logService.info('pickWorkspaceAndOpen: begin');
return this.windowsService.pickWorkspaceAndOpen(options);
}
......@@ -121,15 +131,27 @@ export class WindowService implements IWindowService {
}
showMessageBox(options: Electron.MessageBoxOptions): TPromise<IMessageBoxResult> {
return this.windowsService.showMessageBox(this.windowId, options);
this.logService.info('showMessageBox begin: ', options);
return this.windowsService.showMessageBox(this.windowId, options).then(result => {
this.logService.info('showMessageBox closed, response: ', result);
return result;
});
}
showSaveDialog(options: Electron.SaveDialogOptions): TPromise<string> {
return this.windowsService.showSaveDialog(this.windowId, options);
this.logService.info('showSaveDialog begin: ', options);
return this.windowsService.showSaveDialog(this.windowId, options).then(result => {
this.logService.info('showSaveDialog begin: ', result);
return result;
});
}
showOpenDialog(options: Electron.OpenDialogOptions): TPromise<string[]> {
return this.windowsService.showOpenDialog(this.windowId, options);
this.logService.info('showOpenDialog begin: ', options);
return this.windowsService.showOpenDialog(this.windowId, options).then(result => {
this.logService.info('showOpenDialog closed: ', result);
return result;
});
}
updateTouchBar(items: ICommandAction[][]): TPromise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册