mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 17:22:42 -05:00
editorReplacer -> editorOverride (#16041)
* editorReplacer -> editorOverride * Update lifecycle phsae * add back input factories * Add comment * add back tests * comments * fix log * comments
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
|
||||
import { EditDataInput } from 'sql/workbench/browser/editData/editDataInput';
|
||||
import { IConnectableInput, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionType, IConnectableInput, IConnectionCompletionOptions, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IQueryEditorService, INewSqlEditorOptions } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
|
||||
|
||||
@@ -20,7 +20,10 @@ import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/u
|
||||
import { UntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { IQueryEditorConfiguration } from 'sql/platform/query/common/query';
|
||||
|
||||
import { getCurrentGlobalConnection } from 'sql/workbench/browser/taskUtilities';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
const defaults: INewSqlEditorOptions = {
|
||||
open: true
|
||||
};
|
||||
@@ -37,7 +40,8 @@ export class QueryEditorService implements IQueryEditorService {
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IEditorService private _editorService: IEditorService,
|
||||
@IConfigurationService private _configurationService: IConfigurationService,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -63,10 +67,25 @@ export class QueryEditorService implements IQueryEditorService {
|
||||
|
||||
const queryResultsInput: QueryResultsInput = this._instantiationService.createInstance(QueryResultsInput, docUri.toString());
|
||||
let queryInput = this._instantiationService.createInstance(UntitledQueryEditorInput, options.description, fileInput, queryResultsInput);
|
||||
let profile: IConnectionProfile | undefined = undefined;
|
||||
// If we're told to connect then get the connection before opening the editor since it will try to get the connection for the current
|
||||
// active editor and so we need to get this before opening a new one.
|
||||
if (options.connectWithGlobal) {
|
||||
profile = getCurrentGlobalConnection(this._objectExplorerService, this._connectionManagementService, this._editorService);
|
||||
}
|
||||
if (options.open) {
|
||||
await this._editorService.openEditor(queryInput, { pinned: true });
|
||||
}
|
||||
|
||||
if (profile) {
|
||||
const options: IConnectionCompletionOptions = {
|
||||
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: undefined, input: queryInput },
|
||||
saveTheConnection: false,
|
||||
showDashboard: false,
|
||||
showConnectionDialogOnError: true,
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
this._connectionManagementService.connect(profile, queryInput.uri, options).catch(err => onUnexpectedError(err));
|
||||
}
|
||||
return queryInput;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user