mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 10:38:31 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
@@ -20,10 +20,11 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { isWeb } from 'vs/base/common/platform';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
|
||||
export class FileDialogService implements IFileDialogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
constructor(
|
||||
@IWindowService private readonly windowService: IWindowService,
|
||||
@@ -32,7 +33,8 @@ export class FileDialogService implements IFileDialogService {
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IFileService private readonly fileService: IFileService
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IOpenerService private readonly openerService: IOpenerService
|
||||
) { }
|
||||
|
||||
defaultFilePath(schemeFilter = this.getSchemeFilterForWindow()): URI | undefined {
|
||||
@@ -85,10 +87,10 @@ export class FileDialogService implements IFileDialogService {
|
||||
};
|
||||
}
|
||||
|
||||
private shouldUseSimplified(schema: string): boolean {
|
||||
const setting = this.configurationService.getValue('files.simpleDialog.enable');
|
||||
private shouldUseSimplified(schema: string): { useSimplified: boolean, isSetting: boolean } {
|
||||
const setting = (this.configurationService.getValue('files.simpleDialog.enable') === true);
|
||||
|
||||
return (schema !== Schemas.file) || (setting === true);
|
||||
return { useSimplified: (schema !== Schemas.file) || setting, isSetting: (schema === Schemas.file) && setting };
|
||||
}
|
||||
|
||||
private addFileSchemaIfNeeded(schema: string): string[] {
|
||||
@@ -108,7 +110,8 @@ export class FileDialogService implements IFileDialogService {
|
||||
options.defaultUri = this.defaultFilePath(schema);
|
||||
}
|
||||
|
||||
if (this.shouldUseSimplified(schema)) {
|
||||
const shouldUseSimplified = this.shouldUseSimplified(schema);
|
||||
if (shouldUseSimplified.useSimplified) {
|
||||
const title = nls.localize('openFileOrFolder.title', 'Open File Or Folder');
|
||||
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
||||
|
||||
@@ -118,7 +121,11 @@ export class FileDialogService implements IFileDialogService {
|
||||
const stat = await this.fileService.resolve(uri);
|
||||
|
||||
const toOpen: IURIToOpen = stat.isDirectory ? { folderUri: uri } : { fileUri: uri };
|
||||
return this.windowService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow });
|
||||
if (stat.isDirectory || options.forceNewWindow || shouldUseSimplified.isSetting) {
|
||||
return this.windowService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow });
|
||||
} else {
|
||||
return this.openerService.open(uri);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -134,13 +141,18 @@ export class FileDialogService implements IFileDialogService {
|
||||
options.defaultUri = this.defaultFilePath(schema);
|
||||
}
|
||||
|
||||
if (this.shouldUseSimplified(schema)) {
|
||||
const shouldUseSimplified = this.shouldUseSimplified(schema);
|
||||
if (shouldUseSimplified.useSimplified) {
|
||||
const title = nls.localize('openFile.title', 'Open File');
|
||||
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
||||
|
||||
const uri = await this.pickRemoteResource({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems });
|
||||
if (uri) {
|
||||
return this.windowService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow });
|
||||
if (options.forceNewWindow || shouldUseSimplified.isSetting) {
|
||||
return this.windowService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow });
|
||||
} else {
|
||||
return this.openerService.open(uri);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -156,7 +168,7 @@ export class FileDialogService implements IFileDialogService {
|
||||
options.defaultUri = this.defaultFolderPath(schema);
|
||||
}
|
||||
|
||||
if (this.shouldUseSimplified(schema)) {
|
||||
if (this.shouldUseSimplified(schema).useSimplified) {
|
||||
const title = nls.localize('openFolder.title', 'Open Folder');
|
||||
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
||||
|
||||
@@ -178,7 +190,7 @@ export class FileDialogService implements IFileDialogService {
|
||||
options.defaultUri = this.defaultWorkspacePath(schema);
|
||||
}
|
||||
|
||||
if (this.shouldUseSimplified(schema)) {
|
||||
if (this.shouldUseSimplified(schema).useSimplified) {
|
||||
const title = nls.localize('openWorkspace.title', 'Open Workspace');
|
||||
const filters: FileFilter[] = [{ name: nls.localize('filterName.workspace', 'Workspace'), extensions: [WORKSPACE_EXTENSION] }];
|
||||
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
||||
@@ -196,7 +208,7 @@ export class FileDialogService implements IFileDialogService {
|
||||
|
||||
async pickFileToSave(options: ISaveDialogOptions): Promise<URI | undefined> {
|
||||
const schema = this.getFileSystemSchema(options);
|
||||
if (this.shouldUseSimplified(schema)) {
|
||||
if (this.shouldUseSimplified(schema).useSimplified) {
|
||||
if (!options.availableFileSystems) {
|
||||
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
||||
}
|
||||
@@ -225,7 +237,7 @@ export class FileDialogService implements IFileDialogService {
|
||||
|
||||
async showSaveDialog(options: ISaveDialogOptions): Promise<URI | undefined> {
|
||||
const schema = this.getFileSystemSchema(options);
|
||||
if (this.shouldUseSimplified(schema)) {
|
||||
if (this.shouldUseSimplified(schema).useSimplified) {
|
||||
if (!options.availableFileSystems) {
|
||||
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
||||
}
|
||||
@@ -243,7 +255,7 @@ export class FileDialogService implements IFileDialogService {
|
||||
|
||||
async showOpenDialog(options: IOpenDialogOptions): Promise<URI[] | undefined> {
|
||||
const schema = this.getFileSystemSchema(options);
|
||||
if (this.shouldUseSimplified(schema)) {
|
||||
if (this.shouldUseSimplified(schema).useSimplified) {
|
||||
if (!options.availableFileSystems) {
|
||||
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ export class RemoteFileDialog {
|
||||
}
|
||||
|
||||
public async showOpenDialog(options: IOpenDialogOptions = {}): Promise<URI | undefined> {
|
||||
this.scheme = this.getScheme(options.availableFileSystems);
|
||||
this.scheme = this.getScheme(options.availableFileSystems, options.defaultUri);
|
||||
this.userHome = await this.getUserHome();
|
||||
const newOptions = await this.getOptions(options);
|
||||
if (!newOptions) {
|
||||
@@ -112,7 +112,7 @@ export class RemoteFileDialog {
|
||||
}
|
||||
|
||||
public async showSaveDialog(options: ISaveDialogOptions): Promise<URI | undefined> {
|
||||
this.scheme = this.getScheme(options.availableFileSystems);
|
||||
this.scheme = this.getScheme(options.availableFileSystems, options.defaultUri);
|
||||
this.userHome = await this.getUserHome();
|
||||
this.requiresTrailing = true;
|
||||
const newOptions = await this.getOptions(options, true);
|
||||
@@ -157,8 +157,14 @@ export class RemoteFileDialog {
|
||||
return resources.toLocalResource(URI.from({ scheme: this.scheme, path }), this.scheme === Schemas.file ? undefined : this.remoteAuthority);
|
||||
}
|
||||
|
||||
private getScheme(available: string[] | undefined): string {
|
||||
return available ? available[0] : Schemas.file;
|
||||
private getScheme(available: string[] | undefined, defaultUri: URI | undefined): string {
|
||||
if (available) {
|
||||
if (defaultUri && (available.indexOf(defaultUri.scheme) >= 0)) {
|
||||
return defaultUri.scheme;
|
||||
}
|
||||
return available[0];
|
||||
}
|
||||
return Schemas.file;
|
||||
}
|
||||
|
||||
private async getRemoteAgentEnvironment(): Promise<IRemoteAgentEnvironment | null> {
|
||||
@@ -215,7 +221,7 @@ export class RemoteFileDialog {
|
||||
this.filePickBox.autoFocusOnList = false;
|
||||
this.filePickBox.ignoreFocusOut = true;
|
||||
this.filePickBox.ok = true;
|
||||
if (this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) {
|
||||
if ((this.scheme !== Schemas.file) && this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) {
|
||||
this.filePickBox.customButton = true;
|
||||
this.filePickBox.customLabel = nls.localize('remoteFileDialog.local', 'Show Local');
|
||||
let action;
|
||||
|
||||
@@ -9,7 +9,7 @@ import Severity from 'vs/base/common/severity';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { mnemonicButtonLabel } from 'vs/base/common/labels';
|
||||
import { IDialogService, IConfirmation, IConfirmationResult, IDialogOptions } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IDialogService, IConfirmation, IConfirmationResult, IDialogOptions, IShowResult } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { DialogService as HTMLDialogService } from 'vs/platform/dialogs/browser/dialogService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
@@ -36,7 +36,7 @@ interface IMassagedMessageBoxOptions {
|
||||
}
|
||||
|
||||
export class DialogService implements IDialogService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private impl: IDialogService;
|
||||
|
||||
@@ -63,14 +63,14 @@ export class DialogService implements IDialogService {
|
||||
confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
|
||||
return this.impl.confirm(confirmation);
|
||||
}
|
||||
show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions | undefined): Promise<number> {
|
||||
show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions | undefined): Promise<IShowResult> {
|
||||
return this.impl.show(severity, message, buttons, options);
|
||||
}
|
||||
}
|
||||
|
||||
class NativeDialogService implements IDialogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
constructor(
|
||||
@IWindowService private readonly windowService: IWindowService,
|
||||
@@ -129,7 +129,7 @@ class NativeDialogService implements IDialogService {
|
||||
return opts;
|
||||
}
|
||||
|
||||
async show(severity: Severity, message: string, buttons: string[], dialogOptions?: IDialogOptions): Promise<number> {
|
||||
async show(severity: Severity, message: string, buttons: string[], dialogOptions?: IDialogOptions): Promise<IShowResult> {
|
||||
this.logService.trace('DialogService#show', message);
|
||||
|
||||
const { options, buttonIndexMap } = this.massageMessageBoxOptions({
|
||||
@@ -137,11 +137,13 @@ class NativeDialogService implements IDialogService {
|
||||
buttons,
|
||||
type: (severity === Severity.Info) ? 'question' : (severity === Severity.Error) ? 'error' : (severity === Severity.Warning) ? 'warning' : 'none',
|
||||
cancelId: dialogOptions ? dialogOptions.cancelId : undefined,
|
||||
detail: dialogOptions ? dialogOptions.detail : undefined
|
||||
detail: dialogOptions ? dialogOptions.detail : undefined,
|
||||
checkboxLabel: dialogOptions && dialogOptions.checkbox ? dialogOptions.checkbox.label : undefined,
|
||||
checkboxChecked: dialogOptions && dialogOptions.checkbox ? dialogOptions.checkbox.checked : undefined
|
||||
});
|
||||
|
||||
const result = await this.windowService.showMessageBox(options);
|
||||
return buttonIndexMap[result.button];
|
||||
return { choice: buttonIndexMap[result.button], checkboxChecked: result.checkboxChecked };
|
||||
}
|
||||
|
||||
private massageMessageBoxOptions(options: Electron.MessageBoxOptions): IMassagedMessageBoxOptions {
|
||||
|
||||
Reference in New Issue
Block a user