dialogs - add logging

This commit is contained in:
Benjamin Pasero
2017-12-20 10:53:04 +01:00
parent 3aed233178
commit 8ebaeee52e
2 changed files with 53 additions and 9 deletions
+27 -5
View File
@@ -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));
});
});
});
}