mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
More Layering (#9139)
* move handling generated files to the serilization classes * remove unneeded methods * add more folders to strictire compile, add more strict compile options * update ci * wip * add more layering and fix issues * add more strictness * remove unnecessary assertion * add missing checks * fix indentation * wip * remove jsdoc * fix layering * fix compile * fix compile errors * wip * wip * finish layering * fix css * more layering * rip * reworking results serializer * move some files around * move capabilities to platform wip * implement capabilities register provider * fix capabilities service * fix usage of the regist4ry * add contribution * wip * wip * wip * remove no longer good parts * fix strict-nulls * fix issues with startup * another try * fix startup * fix imports * fix tests * fix tests * fix more tests * fix tests * fix more tests * fix broken test * fix tabbing * fix naming * wip * finished layering * fix imports * fix valid layers * fix layers
This commit is contained in:
@@ -17,7 +17,7 @@ import { removeAnsiEscapeCodes } from 'vs/base/common/strings';
|
||||
import { IGridDataProvider } from 'sql/workbench/services/query/common/gridDataProvider';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import QueryRunner from 'sql/workbench/services/query/common/queryRunner';
|
||||
import { GridTableState } from 'sql/workbench/contrib/query/common/gridPanelState';
|
||||
import { GridTableState } from 'sql/workbench/common/editor/query/gridPanelState';
|
||||
import * as Constants from 'sql/workbench/contrib/extensions/common/constants';
|
||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
|
||||
@@ -44,7 +44,7 @@ import { localize } from 'vs/nls';
|
||||
import { IGridDataProvider } from 'sql/workbench/services/query/common/gridDataProvider';
|
||||
import { formatDocumentWithSelectedProvider, FormattingMode } from 'vs/editor/contrib/format/format';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { GridPanelState, GridTableState } from 'sql/workbench/contrib/query/common/gridPanelState';
|
||||
import { GridPanelState, GridTableState } from 'sql/workbench/common/editor/query/gridPanelState';
|
||||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { SaveFormat } from 'sql/workbench/services/query/common/resultSerializer';
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import * as ConnectionConstants from 'sql/platform/connection/common/constants';
|
||||
import { EditDataEditor } from 'sql/workbench/contrib/editData/browser/editDataEditor';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
import { QueryEditorInput } from 'sql/workbench/common/editor/query/queryEditorInput';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
const singleQuote = '\'';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import 'vs/css!./media/messagePanel';
|
||||
import { IMessagesActionContext, CopyMessagesAction, CopyAllMessagesAction } from './actions';
|
||||
import QueryRunner, { IQueryMessage } from 'sql/workbench/services/query/common/queryRunner';
|
||||
import { IExpandableTree } from 'sql/workbench/contrib/objectExplorer/browser/treeUpdateUtils';
|
||||
import { IExpandableTree } from 'sql/workbench/services/objectExplorer/browser/treeUpdateUtils';
|
||||
|
||||
import { ISelectionData } from 'azdata';
|
||||
|
||||
@@ -28,7 +28,7 @@ import { $, Dimension, createStyleSheet } from 'vs/base/browser/dom';
|
||||
import { QueryEditor } from 'sql/workbench/contrib/query/browser/queryEditor';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { resultsErrorColor } from 'sql/platform/theme/common/colors';
|
||||
import { MessagePanelState } from 'sql/workbench/contrib/query/common/messagePanelState';
|
||||
import { MessagePanelState } from 'sql/workbench/common/editor/query/messagePanelState';
|
||||
|
||||
export interface IResultMessageIntern extends IQueryMessage {
|
||||
id?: string;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IPanelView, IPanelTab } from 'sql/base/browser/ui/panel/panel';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { bootstrapAngular } from 'sql/workbench/services/bootstrap/browser/bootstrapService';
|
||||
import { QueryModelViewTabModule } from 'sql/workbench/contrib/query/browser/modelViewTab/queryModelViewTab.module';
|
||||
import { QueryModelViewState } from 'sql/workbench/contrib/query/common/modelViewTab/modelViewState';
|
||||
import { QueryModelViewState } from 'sql/workbench/common/editor/query/modelViewState';
|
||||
|
||||
export class QueryModelViewTab implements IPanelTab {
|
||||
public identifier = 'QueryModelViewTab_';
|
||||
|
||||
@@ -17,7 +17,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
|
||||
import { QueryEditor } from 'sql/workbench/contrib/query/browser/queryEditor';
|
||||
import { QueryResultsEditor } from 'sql/workbench/contrib/query/browser/queryResultsEditor';
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
|
||||
import * as queryContext from 'sql/workbench/contrib/query/common/queryContext';
|
||||
import {
|
||||
RunQueryKeyboardAction, RunCurrentQueryKeyboardAction, CancelQueryKeyboardAction, RefreshIntellisenseKeyboardAction, ToggleQueryResultsKeyboardAction,
|
||||
@@ -35,10 +35,10 @@ import { SqlFlavorStatusbarItem, ChangeFlavorAction } from 'sql/workbench/contri
|
||||
import { IEditorInputFactoryRegistry, Extensions as EditorInputFactoryExtensions } from 'vs/workbench/common/editor';
|
||||
import { FileQueryEditorInput } from 'sql/workbench/contrib/query/common/fileQueryEditorInput';
|
||||
import { FileQueryEditorInputFactory, UntitledQueryEditorInputFactory, QueryEditorLanguageAssociation } from 'sql/workbench/contrib/query/common/queryInputFactory';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/untitledQueryEditorInput';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
|
||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { NewQueryTask, OE_NEW_QUERY_ACTION_ID, DE_NEW_QUERY_COMMAND_ID } from 'sql/workbench/contrib/query/browser/queryActions';
|
||||
import { TreeNodeContextKey } from 'sql/workbench/contrib/objectExplorer/common/treeNodeContextKey';
|
||||
import { TreeNodeContextKey } from 'sql/workbench/services/objectExplorer/common/treeNodeContextKey';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ManageActionContext } from 'sql/workbench/browser/actions';
|
||||
|
||||
@@ -37,7 +37,7 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { getCurrentGlobalConnection } from 'sql/workbench/browser/taskUtilities';
|
||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { OEAction } from 'sql/workbench/contrib/objectExplorer/browser/objectExplorerActions';
|
||||
import { OEAction } from 'sql/workbench/services/objectExplorer/browser/objectExplorerActions';
|
||||
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
|
||||
@@ -31,7 +31,7 @@ import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileE
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IFileService, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
|
||||
import { QueryEditorInput, IQueryEditorStateChange } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
import { QueryEditorInput, IQueryEditorStateChange } from 'sql/workbench/common/editor/query/queryEditorInput';
|
||||
import { QueryResultsEditor } from 'sql/workbench/contrib/query/browser/queryResultsEditor';
|
||||
import * as queryContext from 'sql/workbench/contrib/query/common/queryContext';
|
||||
import { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
|
||||
@@ -15,7 +15,7 @@ import * as DOM from 'vs/base/browser/dom';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
|
||||
import { QueryResultsView } from 'sql/workbench/contrib/query/browser/queryResultsView';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
|
||||
import { TabbedPanel, IPanelTab, IPanelView } from 'sql/base/browser/ui/panel/panel';
|
||||
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
|
||||
import QueryRunner from 'sql/workbench/services/query/common/queryRunner';
|
||||
@@ -13,8 +13,8 @@ import { ChartTab } from 'sql/workbench/contrib/charts/browser/chartTab';
|
||||
import { QueryPlanTab } from 'sql/workbench/contrib/queryPlan/browser/queryPlan';
|
||||
import { TopOperationsTab } from 'sql/workbench/contrib/queryPlan/browser/topOperations';
|
||||
import { QueryModelViewTab } from 'sql/workbench/contrib/query/browser/modelViewTab/queryModelViewTab';
|
||||
import { MessagePanelState } from 'sql/workbench/contrib/query/common/messagePanelState';
|
||||
import { GridPanelState } from 'sql/workbench/contrib/query/common/gridPanelState';
|
||||
import { MessagePanelState } from 'sql/workbench/common/editor/query/messagePanelState';
|
||||
import { GridPanelState } from 'sql/workbench/common/editor/query/gridPanelState';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { localize } from 'vs/nls';
|
||||
import QueryRunner from 'sql/workbench/services/query/common/queryRunner';
|
||||
import { parseNumAsTimeString } from 'sql/platform/connection/common/utils';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
import { QueryEditorInput } from 'sql/workbench/common/editor/query/queryEditorInput';
|
||||
import { IStatusbarService, IStatusbarEntryAccessor, StatusbarAlignment } from 'vs/workbench/services/statusbar/common/statusbar';
|
||||
|
||||
export class TimeElapsedStatusBarContributions extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { QueryEditorInput } from 'sql/workbench/common/editor/query/queryEditorInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
export class GridPanelState {
|
||||
public tableStates: GridTableState[] = [];
|
||||
public scrollPosition: number;
|
||||
|
||||
dispose() {
|
||||
dispose(this.tableStates);
|
||||
}
|
||||
}
|
||||
|
||||
export class GridTableState extends Disposable {
|
||||
|
||||
private _maximized: boolean;
|
||||
|
||||
private _onMaximizedChange = this._register(new Emitter<boolean>());
|
||||
public onMaximizedChange: Event<boolean> = this._onMaximizedChange.event;
|
||||
|
||||
private _onCanBeMaximizedChange = this._register(new Emitter<boolean>());
|
||||
public onCanBeMaximizedChange: Event<boolean> = this._onCanBeMaximizedChange.event;
|
||||
|
||||
private _canBeMaximized: boolean;
|
||||
|
||||
/* The top row of the current scroll */
|
||||
public scrollPositionY = 0;
|
||||
public scrollPositionX = 0;
|
||||
public columnSizes?: number[] = undefined;
|
||||
public selection: Slick.Range[];
|
||||
public activeCell: Slick.Cell;
|
||||
|
||||
constructor(public readonly resultId: number, public readonly batchId: number) {
|
||||
super();
|
||||
}
|
||||
|
||||
public get canBeMaximized(): boolean {
|
||||
return this._canBeMaximized;
|
||||
}
|
||||
|
||||
public set canBeMaximized(val: boolean) {
|
||||
if (val === this._canBeMaximized) {
|
||||
return;
|
||||
}
|
||||
this._canBeMaximized = val;
|
||||
this._onCanBeMaximizedChange.fire(val);
|
||||
}
|
||||
|
||||
public get maximized(): boolean {
|
||||
return this._maximized;
|
||||
}
|
||||
|
||||
public set maximized(val: boolean) {
|
||||
if (val === this._maximized) {
|
||||
return;
|
||||
}
|
||||
this._maximized = val;
|
||||
this._onMaximizedChange.fire(val);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export class MessagePanelState {
|
||||
public scrollPosition: number;
|
||||
|
||||
dispose() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export class QueryModelViewState {
|
||||
public componentId: string;
|
||||
public dispose() {
|
||||
}
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { EditorInput, GroupIdentifier, IRevertOptions, ISaveOptions, IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
import { IConnectionManagementService, IConnectableInput, INewConnectionParams, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
|
||||
|
||||
import { ISelectionData, ExecutionPlanOptions } from 'azdata';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
const MAX_SIZE = 13;
|
||||
|
||||
function trimTitle(title: string): string {
|
||||
const length = title.length;
|
||||
const diff = length - MAX_SIZE;
|
||||
|
||||
if (diff <= 0) {
|
||||
return title;
|
||||
} else {
|
||||
const start = (length / 2) - (diff / 2);
|
||||
return title.slice(0, start) + '...' + title.slice(start + diff, length);
|
||||
}
|
||||
}
|
||||
|
||||
export interface IQueryEditorStateChange {
|
||||
connectedChange?: boolean;
|
||||
resultsVisibleChange?: boolean;
|
||||
executingChange?: boolean;
|
||||
connectingChange?: boolean;
|
||||
sqlCmdModeChanged?: boolean;
|
||||
}
|
||||
|
||||
export class QueryEditorState extends Disposable {
|
||||
private _connected = false;
|
||||
private _isSqlCmdMode = false;
|
||||
private _resultsVisible = false;
|
||||
private _executing = false;
|
||||
private _connecting = false;
|
||||
|
||||
private _onChange = this._register(new Emitter<IQueryEditorStateChange>());
|
||||
public onChange = this._onChange.event;
|
||||
|
||||
public set connected(val: boolean) {
|
||||
if (val !== this._connected) {
|
||||
this._connected = val;
|
||||
this._onChange.fire({ connectedChange: true });
|
||||
}
|
||||
}
|
||||
|
||||
public get connected(): boolean {
|
||||
return this._connected;
|
||||
}
|
||||
|
||||
public set connecting(val: boolean) {
|
||||
if (val !== this._connecting) {
|
||||
this._connecting = val;
|
||||
this._onChange.fire({ connectingChange: true });
|
||||
}
|
||||
}
|
||||
|
||||
public get connecting(): boolean {
|
||||
return this._connecting;
|
||||
}
|
||||
|
||||
public set resultsVisible(val: boolean) {
|
||||
if (val !== this._resultsVisible) {
|
||||
this._resultsVisible = val;
|
||||
this._onChange.fire({ resultsVisibleChange: true });
|
||||
}
|
||||
}
|
||||
|
||||
public get resultsVisible(): boolean {
|
||||
return this._resultsVisible;
|
||||
}
|
||||
|
||||
public set executing(val: boolean) {
|
||||
if (val !== this._executing) {
|
||||
this._executing = val;
|
||||
this._onChange.fire({ executingChange: true });
|
||||
}
|
||||
}
|
||||
|
||||
public get executing(): boolean {
|
||||
return this._executing;
|
||||
}
|
||||
|
||||
public set isSqlCmdMode(val: boolean) {
|
||||
if (val !== this._isSqlCmdMode) {
|
||||
this._isSqlCmdMode = val;
|
||||
this._onChange.fire({ sqlCmdModeChanged: true });
|
||||
}
|
||||
}
|
||||
|
||||
public get isSqlCmdMode(): boolean {
|
||||
return this._isSqlCmdMode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Input for the QueryEditor. This input is simply a wrapper around a QueryResultsInput for the QueryResultsEditor
|
||||
* and a UntitledEditorInput for the SQL File Editor.
|
||||
*/
|
||||
export abstract class QueryEditorInput extends EditorInput implements IConnectableInput, IDisposable {
|
||||
|
||||
public static SCHEMA: string = 'sql';
|
||||
|
||||
private _state = this._register(new QueryEditorState());
|
||||
public get state(): QueryEditorState { return this._state; }
|
||||
|
||||
constructor(
|
||||
private _description: string,
|
||||
protected _text: EditorInput,
|
||||
protected _results: QueryResultsInput,
|
||||
@IConnectionManagementService private readonly connectionManagementService: IConnectionManagementService,
|
||||
@IQueryModelService private readonly queryModelService: IQueryModelService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(this._text);
|
||||
this._register(this._results);
|
||||
|
||||
this._text.onDidChangeDirty(() => this._onDidChangeDirty.fire());
|
||||
|
||||
this._register(
|
||||
this.queryModelService.onRunQueryStart(uri => {
|
||||
if (this.uri === uri) {
|
||||
this.onRunQuery();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
this._register(
|
||||
this.queryModelService.onRunQueryComplete(uri => {
|
||||
if (this.uri === uri) {
|
||||
this.onQueryComplete();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
this._register(this.connectionManagementService.onDisconnect(result => {
|
||||
if (result.connectionUri === this.uri) {
|
||||
this.onDisconnect();
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectedKeys.indexOf('sql.showConnectionInfoInTitle') > -1) {
|
||||
this._onDidChangeLabel.fire();
|
||||
}
|
||||
}));
|
||||
|
||||
this.connectionManagementService.ensureDefaultLanguageFlavor(this.uri);
|
||||
|
||||
this.onDisconnect();
|
||||
this.onQueryComplete();
|
||||
}
|
||||
|
||||
// Getters for private properties
|
||||
public get uri(): string { return this.getResource().toString(true); }
|
||||
public get text(): EditorInput { return this._text; }
|
||||
public get results(): QueryResultsInput { return this._results; }
|
||||
// Description is shown beside the tab name in the combobox of open editors
|
||||
public getDescription(): string { return this._description; }
|
||||
public supportsSplitEditor(): boolean { return false; }
|
||||
public revert(group: GroupIdentifier, options?: IRevertOptions): Promise<boolean> {
|
||||
return this._text.revert(group, options);
|
||||
}
|
||||
|
||||
public isReadonly(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public matches(otherInput: any): boolean {
|
||||
// we want to be able to match against our underlying input as well, bascially we are our underlying input
|
||||
if (otherInput instanceof QueryEditorInput) {
|
||||
return this._text.matches(otherInput._text);
|
||||
} else {
|
||||
return this._text.matches(otherInput);
|
||||
}
|
||||
}
|
||||
|
||||
// Forwarding resource functions to the inline sql file editor
|
||||
public isDirty(): boolean { return this._text.isDirty(); }
|
||||
public getResource(): URI { return this._text.getResource(); }
|
||||
|
||||
public matchInputInstanceType(inputType: any): boolean {
|
||||
return (this._text instanceof inputType);
|
||||
}
|
||||
|
||||
public getName(longForm?: boolean): string {
|
||||
if (this.configurationService.getValue('sql.showConnectionInfoInTitle')) {
|
||||
let profile = this.connectionManagementService.getConnectionProfile(this.uri);
|
||||
let title = '';
|
||||
if (this._description && this._description !== '') {
|
||||
title = this._description + ' ';
|
||||
}
|
||||
if (profile) {
|
||||
if (profile.userName) {
|
||||
title += `${profile.serverName}.${profile.databaseName} (${profile.userName})`;
|
||||
} else {
|
||||
title += `${profile.serverName}.${profile.databaseName} (${profile.authenticationType})`;
|
||||
}
|
||||
} else {
|
||||
title += localize('disconnected', "disconnected");
|
||||
}
|
||||
return this._text.getName() + (longForm ? (' - ' + title) : ` - ${trimTitle(title)}`);
|
||||
} else {
|
||||
return this._text.getName();
|
||||
}
|
||||
}
|
||||
|
||||
save(group: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||
return this.text.save(group, options);
|
||||
}
|
||||
|
||||
saveAs(group: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||
return this.text.saveAs(group, options);
|
||||
}
|
||||
|
||||
// Called to get the tooltip of the tab
|
||||
public getTitle(): string {
|
||||
return this.getName(true);
|
||||
}
|
||||
|
||||
// State update funtions
|
||||
public runQuery(selection?: ISelectionData, executePlanOptions?: ExecutionPlanOptions): void {
|
||||
this.queryModelService.runQuery(this.uri, selection, executePlanOptions);
|
||||
this.state.executing = true;
|
||||
}
|
||||
|
||||
public runQueryStatement(selection?: ISelectionData): void {
|
||||
this.queryModelService.runQueryStatement(this.uri, selection);
|
||||
this.state.executing = true;
|
||||
}
|
||||
|
||||
public runQueryString(text: string): void {
|
||||
this.queryModelService.runQueryString(this.uri, text);
|
||||
this.state.executing = true;
|
||||
}
|
||||
|
||||
public onConnectStart(): void {
|
||||
this.state.connecting = true;
|
||||
this.state.connected = false;
|
||||
}
|
||||
|
||||
public onConnectReject(): void {
|
||||
this.state.connecting = false;
|
||||
this.state.connected = false;
|
||||
}
|
||||
|
||||
public onConnectCanceled(): void {
|
||||
// If we're currently connecting and then cancel, set connected state to false
|
||||
// Otherwise, keep connected state as it was
|
||||
if (this.state.connecting) {
|
||||
this.state.connected = false;
|
||||
}
|
||||
this.state.connecting = false;
|
||||
}
|
||||
|
||||
public onConnectSuccess(params?: INewConnectionParams): void {
|
||||
this.state.connected = true;
|
||||
this.state.connecting = false;
|
||||
|
||||
let isRunningQuery = this.queryModelService.isRunningQuery(this.uri);
|
||||
if (!isRunningQuery && params && params.runQueryOnCompletion) {
|
||||
let selection: ISelectionData | undefined = params ? params.querySelection : undefined;
|
||||
if (params.runQueryOnCompletion === RunQueryOnConnectionMode.executeCurrentQuery) {
|
||||
this.runQueryStatement(selection);
|
||||
} else if (params.runQueryOnCompletion === RunQueryOnConnectionMode.executeQuery) {
|
||||
this.runQuery(selection);
|
||||
} else if (params.runQueryOnCompletion === RunQueryOnConnectionMode.estimatedQueryPlan) {
|
||||
this.runQuery(selection, { displayEstimatedQueryPlan: true });
|
||||
} else if (params.runQueryOnCompletion === RunQueryOnConnectionMode.actualQueryPlan) {
|
||||
this.runQuery(selection, { displayActualQueryPlan: true });
|
||||
}
|
||||
}
|
||||
this._onDidChangeLabel.fire();
|
||||
}
|
||||
|
||||
public onDisconnect(): void {
|
||||
this.state.connected = false;
|
||||
this._onDidChangeLabel.fire();
|
||||
}
|
||||
|
||||
public onRunQuery(): void {
|
||||
this.state.executing = true;
|
||||
this.state.resultsVisible = true;
|
||||
}
|
||||
|
||||
public onQueryComplete(): void {
|
||||
this.state.executing = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color that should be displayed
|
||||
*/
|
||||
public get tabColor(): string {
|
||||
return this.connectionManagementService.getTabColorForUri(this.uri);
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this.queryModelService.disposeQuery(this.uri);
|
||||
this.connectionManagementService.disconnectEditor(this, true);
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public get isSharedSession(): boolean {
|
||||
return !!(this.uri && startsWith(this.uri, 'vsls:'));
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,14 @@
|
||||
import { IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions, IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
|
||||
import { FILE_EDITOR_INPUT_ID } from 'vs/workbench/contrib/files/common/files';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/untitledQueryEditorInput';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
|
||||
import { FileQueryEditorInput } from 'sql/workbench/contrib/query/common/fileQueryEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { ILanguageAssociation } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
import { QueryEditorInput } from 'sql/workbench/common/editor/query/queryEditorInput';
|
||||
import { getCurrentGlobalConnection } from 'sql/workbench/browser/taskUtilities';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType } from 'sql/platform/connection/common/connectionManagement';
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { EditorInput } from 'vs/workbench/common/editor';
|
||||
|
||||
import { TopOperationsState } from 'sql/workbench/contrib/queryPlan/common/topOperationsState';
|
||||
import { ChartState } from 'sql/workbench/contrib/charts/common/interfaces';
|
||||
import { QueryPlanState } from 'sql/workbench/contrib/queryPlan/common/queryPlanState';
|
||||
import { MessagePanelState } from 'sql/workbench/contrib/query/common/messagePanelState';
|
||||
import { GridPanelState } from 'sql/workbench/contrib/query/common/gridPanelState';
|
||||
import { QueryModelViewState } from 'sql/workbench/contrib/query/common/modelViewTab/modelViewState';
|
||||
|
||||
export class ResultsViewState {
|
||||
public readonly gridPanelState: GridPanelState = new GridPanelState();
|
||||
public readonly messagePanelState: MessagePanelState = new MessagePanelState();
|
||||
public readonly chartState: ChartState = new ChartState();
|
||||
public readonly queryPlanState: QueryPlanState = new QueryPlanState();
|
||||
public readonly topOperationsState = new TopOperationsState();
|
||||
public readonly dynamicModelViewTabsState: Map<string, QueryModelViewState> = new Map<string, QueryModelViewState>();
|
||||
|
||||
public activeTab: string;
|
||||
public readonly visibleTabs: Set<string> = new Set<string>();
|
||||
|
||||
dispose() {
|
||||
this.gridPanelState.dispose();
|
||||
this.messagePanelState.dispose();
|
||||
this.chartState.dispose();
|
||||
this.queryPlanState.dispose();
|
||||
this.dynamicModelViewTabsState.forEach((state: QueryModelViewState, identifier: string) => {
|
||||
state.dispose();
|
||||
});
|
||||
this.dynamicModelViewTabsState.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Input for the QueryResultsEditor. This input helps with logic for the viewing and editing of
|
||||
* data in the results grid.
|
||||
*/
|
||||
export class QueryResultsInput extends EditorInput {
|
||||
|
||||
private _state?= new ResultsViewState();
|
||||
|
||||
public get state(): ResultsViewState | undefined {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
constructor(private _uri: string) {
|
||||
super();
|
||||
}
|
||||
|
||||
getTypeId(): string {
|
||||
return QueryResultsInput.ID;
|
||||
}
|
||||
|
||||
getName(): string {
|
||||
return localize('extensionsInputName', "Extension");
|
||||
}
|
||||
|
||||
matches(other: any): boolean {
|
||||
if (other instanceof QueryResultsInput) {
|
||||
return (other._uri === this._uri);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
resolve(refresh?: boolean): Promise<any> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
supportsSplitEditor(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
//// Properties
|
||||
|
||||
static get ID() {
|
||||
return 'workbench.query.queryResultsInput';
|
||||
}
|
||||
|
||||
get uri(): string {
|
||||
return this._uri;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
|
||||
|
||||
import { IEncodingSupport, EncodingMode } from 'vs/workbench/common/editor';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { IUntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
|
||||
|
||||
export class UntitledQueryEditorInput extends QueryEditorInput implements IEncodingSupport {
|
||||
|
||||
public static readonly ID = 'workbench.editorInput.untitledQueryInput';
|
||||
|
||||
constructor(
|
||||
description: string,
|
||||
text: UntitledTextEditorInput,
|
||||
results: QueryResultsInput,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IQueryModelService queryModelService: IQueryModelService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
super(description, text, results, connectionManagementService, queryModelService, configurationService);
|
||||
}
|
||||
|
||||
public resolve(): Promise<IUntitledTextEditorModel & IResolvedTextEditorModel> {
|
||||
return this.text.resolve();
|
||||
}
|
||||
|
||||
public get text(): UntitledTextEditorInput {
|
||||
return this._text as UntitledTextEditorInput;
|
||||
}
|
||||
|
||||
public get hasAssociatedFilePath(): boolean {
|
||||
return this.text.model.hasAssociatedFilePath;
|
||||
}
|
||||
|
||||
public setMode(mode: string): void {
|
||||
this.text.setMode(mode);
|
||||
}
|
||||
|
||||
public getMode(): string {
|
||||
return this.text.getMode();
|
||||
}
|
||||
|
||||
public getTypeId(): string {
|
||||
return UntitledQueryEditorInput.ID;
|
||||
}
|
||||
|
||||
public getEncoding(): string {
|
||||
return this.text.getEncoding();
|
||||
}
|
||||
|
||||
public setEncoding(encoding: string, mode: EncodingMode): void {
|
||||
this.text.setEncoding(encoding, mode);
|
||||
}
|
||||
|
||||
isUntitled(): boolean {
|
||||
// Subclasses need to explicitly opt-in to being untitled.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
import { TestStorageService, TestFileService, workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/untitledQueryEditorInput';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { TestQueryModelService } from 'sql/workbench/services/query/test/common/testQueryModelService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
@@ -7,7 +7,7 @@ import { InstantiationService } from 'vs/platform/instantiation/common/instantia
|
||||
import { IEditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
import { QueryResultsInput } from 'sql/workbench/contrib/query/common/queryResultsInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
|
||||
import { INewConnectionParams, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionManagementService } from 'sql/workbench/services/connection/browser/connectionManagementService';
|
||||
import { RunQueryAction, ListDatabasesActionItem } from 'sql/workbench/contrib/query/browser/queryActions';
|
||||
@@ -20,7 +20,7 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { TestStorageService, workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/untitledQueryEditorInput';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
|
||||
import { TestQueryModelService } from 'sql/workbench/services/query/test/common/testQueryModelService';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
|
||||
@@ -18,7 +18,7 @@ import { TestConnectionManagementService } from 'sql/platform/connection/test/co
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, IConnectionCallbacks, IConnectionResult } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/untitledQueryEditorInput';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user