mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -3,15 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as os from 'os';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import product from 'vs/platform/node/product';
|
||||
import { IWindowsService, OpenContext, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IDevToolsOptions } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowsService, OpenContext, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IDevToolsOptions, INewWindowOptions } from 'vs/platform/windows/common/windows';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { shell, crashReporter, app, Menu, clipboard } from 'electron';
|
||||
import { Event, fromNodeEventEmitter, mapEvent, filterEvent, anyEvent, latch } from 'vs/base/common/event';
|
||||
@@ -23,7 +22,7 @@ import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorksp
|
||||
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { mnemonicButtonLabel } from 'vs/base/common/labels';
|
||||
import { isWindows, isMacintosh } from 'vs/base/common/platform';
|
||||
import { isMacintosh, isLinux } from 'vs/base/common/platform';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
export class WindowsService implements IWindowsService, IURLHandler, IDisposable {
|
||||
@@ -35,15 +34,14 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
private _activeWindowId: number | undefined;
|
||||
|
||||
readonly onWindowOpen: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-created', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowBlur: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-blur', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowMaximize: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-maximize', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowUnmaximize: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-unmaximize', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowFocus: Event<number> = anyEvent(
|
||||
mapEvent(filterEvent(mapEvent(this.windowsMainService.onWindowsCountChanged, () => this.windowsMainService.getLastActiveWindow()), w => !!w), w => w.id),
|
||||
filterEvent(fromNodeEventEmitter(app, 'browser-window-focus', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id))
|
||||
);
|
||||
|
||||
readonly onWindowBlur: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-blur', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowMaximize: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-maximize', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowUnmaximize: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-unmaximize', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
|
||||
readonly onRecentlyOpenedChange: Event<void> = this.historyService.onRecentlyOpenedChange;
|
||||
|
||||
constructor(
|
||||
@@ -90,21 +88,21 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
showMessageBox(windowId: number, options: Electron.MessageBoxOptions): TPromise<IMessageBoxResult> {
|
||||
showMessageBox(windowId: number, options: Electron.MessageBoxOptions): Thenable<IMessageBoxResult> {
|
||||
this.logService.trace('windowsService#showMessageBox', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
return this.windowsMainService.showMessageBox(options, codeWindow);
|
||||
}
|
||||
|
||||
showSaveDialog(windowId: number, options: Electron.SaveDialogOptions): TPromise<string> {
|
||||
showSaveDialog(windowId: number, options: Electron.SaveDialogOptions): Thenable<string> {
|
||||
this.logService.trace('windowsService#showSaveDialog', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
return this.windowsMainService.showSaveDialog(options, codeWindow);
|
||||
}
|
||||
|
||||
showOpenDialog(windowId: number, options: Electron.OpenDialogOptions): TPromise<string[]> {
|
||||
showOpenDialog(windowId: number, options: Electron.OpenDialogOptions): Thenable<string[]> {
|
||||
this.logService.trace('windowsService#showOpenDialog', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
@@ -139,7 +137,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
|
||||
if (codeWindow) {
|
||||
const contents = codeWindow.win.webContents;
|
||||
if (isMacintosh && codeWindow.hasHiddenTitleBarStyle() && !codeWindow.win.isFullScreen() && !contents.isDevToolsOpened()) {
|
||||
if (isMacintosh && codeWindow.hasHiddenTitleBarStyle() && !codeWindow.isFullScreen() && !contents.isDevToolsOpened()) {
|
||||
contents.openDevTools({ mode: 'undocked' }); // due to https://github.com/electron/electron/issues/3647
|
||||
} else {
|
||||
contents.toggleDevTools();
|
||||
@@ -226,14 +224,14 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
addRecentlyOpened(files: string[]): TPromise<void> {
|
||||
addRecentlyOpened(files: URI[]): TPromise<void> {
|
||||
this.logService.trace('windowsService#addRecentlyOpened');
|
||||
this.historyService.addRecentlyOpened(void 0, files);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | string)[]): TPromise<void> {
|
||||
removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string)[]): TPromise<void> {
|
||||
this.logService.trace('windowsService#removeFromRecentlyOpened');
|
||||
this.historyService.removeFromRecentlyOpened(paths);
|
||||
|
||||
@@ -258,6 +256,14 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
return TPromise.as(this.historyService.getRecentlyOpened());
|
||||
}
|
||||
|
||||
newWindowTab(): TPromise<void> {
|
||||
this.logService.trace('windowsService#newWindowTab');
|
||||
|
||||
this.windowsMainService.openNewTabbedWindow(OpenContext.API);
|
||||
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
showPreviousWindowTab(): TPromise<void> {
|
||||
this.logService.trace('windowsService#showPreviousWindowTab');
|
||||
Menu.sendActionToFirstResponder('selectPreviousTab:');
|
||||
@@ -411,9 +417,11 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
openNewWindow(): TPromise<void> {
|
||||
this.logService.trace('windowsService#openNewWindow');
|
||||
this.windowsMainService.openNewWindow(OpenContext.API);
|
||||
openNewWindow(options?: INewWindowOptions): TPromise<void> {
|
||||
this.logService.trace('windowsService#openNewWindow ' + JSON.stringify(options));
|
||||
|
||||
this.windowsMainService.openNewWindow(OpenContext.API, options);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
@@ -495,23 +503,33 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
this.logService.trace('windowsService#openAboutDialog');
|
||||
const lastActiveWindow = this.windowsMainService.getFocusedWindow() || this.windowsMainService.getLastActiveWindow();
|
||||
|
||||
let version = app.getVersion();
|
||||
|
||||
if (product.target) {
|
||||
version = `${version} (${product.target} setup)`;
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
const detail = nls.localize('aboutDetail',
|
||||
"Version {0}\nCommit {1}\nDate {2}\nVS Code {8}\nShell {3}\nRenderer {4}\nNode {5}\nV8: {6}\nArchitecture {7}",
|
||||
app.getVersion(),
|
||||
"Version: {0}\nCommit: {1}\nDate: {2}\nVS Code {8}\nElectron: {3}\nChrome: {4}\nNode.js: {5}\nV8: {6}\nOS: {7}",
|
||||
version,
|
||||
product.commit || 'Unknown',
|
||||
product.date || 'Unknown',
|
||||
process.versions['electron'],
|
||||
process.versions['chrome'],
|
||||
process.versions['node'],
|
||||
process.versions['v8'],
|
||||
process.arch,
|
||||
`${os.type()} ${os.arch()} ${os.release()}`,
|
||||
product.vscodeVersion
|
||||
);
|
||||
|
||||
const buttons = [nls.localize('okButton', "OK")];
|
||||
if (isWindows) {
|
||||
buttons.push(mnemonicButtonLabel(nls.localize({ key: 'copy', comment: ['&& denotes a mnemonic'] }, "&&Copy"))); // https://github.com/Microsoft/vscode/issues/37608
|
||||
const ok = nls.localize('okButton', "OK");
|
||||
const copy = mnemonicButtonLabel(nls.localize({ key: 'copy', comment: ['&& denotes a mnemonic'] }, "&&Copy"));
|
||||
let buttons: string[];
|
||||
if (isLinux) {
|
||||
buttons = [copy, ok];
|
||||
} else {
|
||||
buttons = [ok, copy];
|
||||
}
|
||||
|
||||
this.windowsMainService.showMessageBox({
|
||||
@@ -520,9 +538,10 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
message: product.nameLong,
|
||||
detail: `\n${detail}`,
|
||||
buttons,
|
||||
noLink: true
|
||||
noLink: true,
|
||||
defaultId: buttons.indexOf(ok)
|
||||
}, lastActiveWindow).then(result => {
|
||||
if (isWindows && result.button === 1) {
|
||||
if (buttons[result.button] === copy) {
|
||||
clipboard.writeText(detail);
|
||||
}
|
||||
});
|
||||
@@ -548,6 +567,19 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
return TPromise.wrap(true);
|
||||
}
|
||||
|
||||
resolveProxy(windowId: number, url: string): Promise<string | undefined> {
|
||||
return new Promise(resolve => {
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
if (codeWindow) {
|
||||
codeWindow.win.webContents.session.resolveProxy(url, proxy => {
|
||||
resolve(proxy);
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user