From d9ba4d9130cb4e3ab2ec5ae066672fc25b6fa109 Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Wed, 7 Nov 2018 11:25:24 -0800 Subject: [PATCH] profiler improvements (#3151) * profiler improvements * fix for issue 3114 --- .../dialogs/profilerCreateSessionDialog.ts | 8 ++- extensions/profiler/package.json | 2 +- resources/xlf/sqlops-core/sql.xlf | 17 ++---- resources/xlf/vscode-extensions/profiler.xlf | 3 -- .../base/browser/ui/taskbar/media/taskbar.css | 2 +- src/sql/media/icons/check.svg | 1 + src/sql/media/icons/check_inverse.svg | 1 + src/sql/media/icons/common-icons.css | 45 ++++++++++++++++ src/sql/media/icons/continue.svg | 1 + src/sql/media/icons/continue_inverse.svg | 1 + src/sql/media/icons/pause.svg | 1 + src/sql/media/icons/pause_inverse.svg | 1 + src/sql/media/icons/start.svg | 1 + src/sql/media/icons/start_inverse.svg | 1 + src/sql/media/icons/stop.svg | 1 + src/sql/media/icons/stop_inverse.svg | 1 + .../viewlet/serverTreeActionProvider.ts | 1 - .../parts/profiler/contrib/profilerActions.ts | 40 +++++++++----- .../contrib/profilerWorkbenchActions.ts | 52 ------------------- .../parts/profiler/editor/profilerEditor.ts | 39 ++++++++------ .../parts/profiler/editor/profilerInput.ts | 22 ++++---- src/sql/workbench/common/taskUtilities.ts | 4 ++ 22 files changed, 129 insertions(+), 116 deletions(-) create mode 100644 src/sql/media/icons/check.svg create mode 100644 src/sql/media/icons/check_inverse.svg create mode 100644 src/sql/media/icons/continue.svg create mode 100644 src/sql/media/icons/continue_inverse.svg create mode 100644 src/sql/media/icons/pause.svg create mode 100644 src/sql/media/icons/pause_inverse.svg create mode 100644 src/sql/media/icons/start.svg create mode 100644 src/sql/media/icons/start_inverse.svg create mode 100644 src/sql/media/icons/stop.svg create mode 100644 src/sql/media/icons/stop_inverse.svg delete mode 100644 src/sql/parts/profiler/contrib/profilerWorkbenchActions.ts diff --git a/extensions/profiler/client/src/dialogs/profilerCreateSessionDialog.ts b/extensions/profiler/client/src/dialogs/profilerCreateSessionDialog.ts index 3d92a0fcfc..d4d0193f49 100644 --- a/extensions/profiler/client/src/dialogs/profilerCreateSessionDialog.ts +++ b/extensions/profiler/client/src/dialogs/profilerCreateSessionDialog.ts @@ -12,10 +12,7 @@ import { CreateSessionData } from '../data/createSessionData'; const localize = nls.loadMessageBundle(); export class CreateSessionDialog { - private readonly _providerType: string; - // Top level - private readonly DialogTitle: string = localize('createSessionDialog.newSession', 'New Session'); private readonly CancelButtonText: string = localize('createSessionDialog.cancel', 'Cancel'); private readonly CreateButtonText: string = localize('createSessionDialog.create', 'Create'); private readonly DialogTitleText: string = localize('createSessionDialog.title', 'Create New Profiler Session'); @@ -26,6 +23,7 @@ export class CreateSessionDialog { private sessionNameBox: sqlops.InputBoxComponent; private model: CreateSessionData; + private readonly _providerType: string; private _onSuccess: vscode.EventEmitter = new vscode.EventEmitter(); public readonly onSuccess: vscode.Event = this._onSuccess.event; @@ -46,7 +44,7 @@ export class CreateSessionDialog { } public async showDialog(): Promise { - this.dialog = sqlops.window.modelviewdialog.createDialog(this.DialogTitle); + this.dialog = sqlops.window.modelviewdialog.createDialog(this.DialogTitleText); this.initializeContent(); this.dialog.okButton.onClick(() => this.execute()); this.dialog.cancelButton.onClick(() => { }); @@ -81,7 +79,7 @@ export class CreateSessionDialog { title: localize('createSessionDialog.enterSessionName', "Enter session name:") }], - title: this.DialogTitleText + title: '' }]).withLayout({ width: '100%' }).component(); await view.initializeModel(formModel); diff --git a/extensions/profiler/package.json b/extensions/profiler/package.json index 2f2b2bf87e..da0636ec60 100644 --- a/extensions/profiler/package.json +++ b/extensions/profiler/package.json @@ -29,7 +29,7 @@ "commands": [ { "command": "profiler.newProfiler", - "title": "New Profiler", + "title": "Launch Profiler", "category": "Profiler" }, { diff --git a/resources/xlf/sqlops-core/sql.xlf b/resources/xlf/sqlops-core/sql.xlf index bc2469d8b8..a1791f64c6 100644 --- a/resources/xlf/sqlops-core/sql.xlf +++ b/resources/xlf/sqlops-core/sql.xlf @@ -1520,9 +1520,6 @@ - - Connect - Disconnect @@ -1533,16 +1530,13 @@ Start - Create - - - Pause Capture + New Session - Resume Capture + Resume - Pause Capture + Pause Stop @@ -1550,9 +1544,6 @@ Clear Data - - Auto Scroll: On - Auto Scroll: On @@ -1572,7 +1563,7 @@ Find Previous String - New Profiler + Launch Profiler diff --git a/resources/xlf/vscode-extensions/profiler.xlf b/resources/xlf/vscode-extensions/profiler.xlf index 58859dffdc..726ae550e3 100644 --- a/resources/xlf/vscode-extensions/profiler.xlf +++ b/resources/xlf/vscode-extensions/profiler.xlf @@ -1,9 +1,6 @@ - - New Session - Cancel diff --git a/src/sql/base/browser/ui/taskbar/media/taskbar.css b/src/sql/base/browser/ui/taskbar/media/taskbar.css index c257a2b065..2773aa3cf5 100644 --- a/src/sql/base/browser/ui/taskbar/media/taskbar.css +++ b/src/sql/base/browser/ui/taskbar/media/taskbar.css @@ -23,7 +23,7 @@ .carbon-taskbar.monaco-toolbar .monaco-action-bar.animated .actions-container { justify-content: flex-start; - padding-left: 15px; + padding: 5px 5px 5px 15px; flex-wrap: wrap; } diff --git a/src/sql/media/icons/check.svg b/src/sql/media/icons/check.svg new file mode 100644 index 0000000000..3f365c4800 --- /dev/null +++ b/src/sql/media/icons/check.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/sql/media/icons/check_inverse.svg b/src/sql/media/icons/check_inverse.svg new file mode 100644 index 0000000000..c225b2f597 --- /dev/null +++ b/src/sql/media/icons/check_inverse.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/sql/media/icons/common-icons.css b/src/sql/media/icons/common-icons.css index 3062a6eee7..8a762d2bf7 100644 --- a/src/sql/media/icons/common-icons.css +++ b/src/sql/media/icons/common-icons.css @@ -227,6 +227,51 @@ background: url('unpin.svg') center center no-repeat; } +.vs .sql.icon.pause { + background-image: url('pause.svg') +} + +.vs-dark .sql.icon.pause, +.hc-black .sql.icon.pause { + background-image: url('pause_inverse.svg') +} + +.vs .sql.icon.continue { + background-image: url('continue.svg') +} + +.vs-dark .sql.icon.continue, +.hc-black .sql.icon.continue { + background-image: url('continue_inverse.svg') +} + +.vs .sql.icon.checked { + background-image: url('check.svg') +} + +.vs-dark .sql.icon.checked, +.hc-black .sql.icon.checked { + background-image: url('check_inverse.svg') +} + +.vs .sql.icon.start { + background-image: url('start.svg') +} + +.vs-dark .sql.icon.start, +.hc-black .sql.icon.start { + background-image: url('start_inverse.svg') +} + +.vs .sql.icon.stop { + background-image: url('stop.svg') +} + +.vs-dark .sql.icon.stop, +.hc-black .sql.icon.stop { + background-image: url('stop_inverse.svg') +} + .small { width: 16px; height: 16px; diff --git a/src/sql/media/icons/continue.svg b/src/sql/media/icons/continue.svg new file mode 100644 index 0000000000..ca0f30e628 --- /dev/null +++ b/src/sql/media/icons/continue.svg @@ -0,0 +1 @@ +continue \ No newline at end of file diff --git a/src/sql/media/icons/continue_inverse.svg b/src/sql/media/icons/continue_inverse.svg new file mode 100644 index 0000000000..2aab216f07 --- /dev/null +++ b/src/sql/media/icons/continue_inverse.svg @@ -0,0 +1 @@ +continue \ No newline at end of file diff --git a/src/sql/media/icons/pause.svg b/src/sql/media/icons/pause.svg new file mode 100644 index 0000000000..0875d60cb8 --- /dev/null +++ b/src/sql/media/icons/pause.svg @@ -0,0 +1 @@ +pause \ No newline at end of file diff --git a/src/sql/media/icons/pause_inverse.svg b/src/sql/media/icons/pause_inverse.svg new file mode 100644 index 0000000000..5072d2f8cd --- /dev/null +++ b/src/sql/media/icons/pause_inverse.svg @@ -0,0 +1 @@ +pause \ No newline at end of file diff --git a/src/sql/media/icons/start.svg b/src/sql/media/icons/start.svg new file mode 100644 index 0000000000..9ef467f2c0 --- /dev/null +++ b/src/sql/media/icons/start.svg @@ -0,0 +1 @@ +continue \ No newline at end of file diff --git a/src/sql/media/icons/start_inverse.svg b/src/sql/media/icons/start_inverse.svg new file mode 100644 index 0000000000..3be0c24f6f --- /dev/null +++ b/src/sql/media/icons/start_inverse.svg @@ -0,0 +1 @@ +continue \ No newline at end of file diff --git a/src/sql/media/icons/stop.svg b/src/sql/media/icons/stop.svg new file mode 100644 index 0000000000..57c29044b1 --- /dev/null +++ b/src/sql/media/icons/stop.svg @@ -0,0 +1 @@ +stop \ No newline at end of file diff --git a/src/sql/media/icons/stop_inverse.svg b/src/sql/media/icons/stop_inverse.svg new file mode 100644 index 0000000000..c8e3720287 --- /dev/null +++ b/src/sql/media/icons/stop_inverse.svg @@ -0,0 +1 @@ +stop \ No newline at end of file diff --git a/src/sql/parts/objectExplorer/viewlet/serverTreeActionProvider.ts b/src/sql/parts/objectExplorer/viewlet/serverTreeActionProvider.ts index cceb97003f..0c63ac8307 100644 --- a/src/sql/parts/objectExplorer/viewlet/serverTreeActionProvider.ts +++ b/src/sql/parts/objectExplorer/viewlet/serverTreeActionProvider.ts @@ -24,7 +24,6 @@ import { TreeNode } from 'sql/parts/objectExplorer/common/treeNode'; import { NodeType } from 'sql/parts/objectExplorer/common/nodeType'; import { ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup'; import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile'; -import { NewProfilerAction } from 'sql/parts/profiler/contrib/profilerActions'; import { TreeUpdateUtils } from 'sql/parts/objectExplorer/viewlet/treeUpdateUtils'; import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement'; import { MenuId, IMenuService } from 'vs/platform/actions/common/actions'; diff --git a/src/sql/parts/profiler/contrib/profilerActions.ts b/src/sql/parts/profiler/contrib/profilerActions.ts index 80ff675f23..9b35c2e766 100644 --- a/src/sql/parts/profiler/contrib/profilerActions.ts +++ b/src/sql/parts/profiler/contrib/profilerActions.ts @@ -10,7 +10,6 @@ import { IProfilerController } from 'sql/parts/profiler/editor/controller/interf import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput'; import { BaseActionContext } from 'sql/workbench/common/actions'; import { Task } from 'sql/platform/tasks/common/tasks'; -import { ObjectExplorerActionsContext } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions'; import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile'; import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType } from 'sql/parts/connection/common/connectionManagement'; import { IConnectionProfile } from 'sql/parts/connection/common/interfaces'; @@ -25,8 +24,11 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati import { INotificationService } from 'vs/platform/notification/common/notification'; export class ProfilerConnect extends Action { + private static readonly ConnectText = nls.localize('profilerAction.connect', 'Connect'); + private static readonly DisconnectText = nls.localize('profilerAction.disconnect', 'Disconnect'); + public static ID = 'profiler.connect'; - public static LABEL = nls.localize('profiler.connect', "Connect"); + public static LABEL = ProfilerConnect.ConnectText; private _connected: boolean = false; @@ -59,7 +61,7 @@ export class ProfilerConnect extends Action { public set connected(value: boolean) { this._connected = value; this._setClass(value ? 'disconnect' : 'connect'); - this._setLabel(value ? nls.localize('profilerAction.disconnect', 'Disconnect') : nls.localize('profilerAction.connect', "Connect")); + this._setLabel(value ? ProfilerConnect.DisconnectText : ProfilerConnect.ConnectText); } public get connected(): boolean { @@ -75,7 +77,7 @@ export class ProfilerStart extends Action { id: string, label: string, @IProfilerService private _profilerService: IProfilerService ) { - super(id, label, 'start'); + super(id, label, 'sql start'); } public run(input: ProfilerInput): TPromise { @@ -86,7 +88,7 @@ export class ProfilerStart extends Action { export class ProfilerCreate extends Action { public static ID = 'profiler.create'; - public static LABEL = nls.localize('create', "Create"); + public static LABEL = nls.localize('create', "New Session"); constructor( id: string, label: string, @@ -105,8 +107,13 @@ export class ProfilerCreate extends Action { } export class ProfilerPause extends Action { + private static readonly PauseText = nls.localize('profilerAction.pauseCapture', 'Pause'); + private static readonly ResumeText = nls.localize('profilerAction.resumeCapture', 'Resume'); + private static readonly PauseCssClass = 'sql pause'; + private static readonly ResumeCssClass = 'sql continue'; + public static ID = 'profiler.pause'; - public static LABEL = nls.localize('profiler.capture', "Pause Capture"); + public static LABEL = ProfilerPause.PauseText; private _paused: boolean = false; @@ -114,7 +121,7 @@ export class ProfilerPause extends Action { id: string, label: string, @IProfilerService private _profilerService: IProfilerService ) { - super(id, label, 'stop'); + super(id, label, ProfilerPause.PauseCssClass); } public run(input: ProfilerInput): TPromise { @@ -127,8 +134,8 @@ export class ProfilerPause extends Action { public set paused(value: boolean) { this._paused = value; - this._setClass(value ? 'start' : 'stop'); - this._setLabel(value ? nls.localize('profilerAction.resumeCapture', "Resume Capture") : nls.localize('profilerAction.pauseCapture', "Pause Capture")); + this._setClass(value ? ProfilerPause.ResumeCssClass : ProfilerPause.PauseCssClass); + this._setLabel(value ? ProfilerPause.ResumeText : ProfilerPause.PauseText); } public get paused(): boolean { @@ -144,7 +151,7 @@ export class ProfilerStop extends Action { id: string, label: string, @IProfilerService private _profilerService: IProfilerService ) { - super(id, label, 'stop'); + super(id, label, 'sql stop'); } public run(input: ProfilerInput): TPromise { @@ -167,16 +174,21 @@ export class ProfilerClear extends Action { } export class ProfilerAutoScroll extends Action { + private static readonly AutoScrollOnText = nls.localize('profilerAction.autoscrollOn', 'Auto Scroll: On'); + private static readonly AutoScrollOffText = nls.localize('profilerAction.autoscrollOff', 'Auto Scroll: Off'); + private static readonly CheckedCssClass = 'sql checked'; + public static ID = 'profiler.autoscroll'; - public static LABEL = nls.localize('profiler.autoscrollOn', "Auto Scroll: On"); + public static LABEL = ProfilerAutoScroll.AutoScrollOnText; constructor(id: string, label: string) { - super(id, label); + super(id, label, ProfilerAutoScroll.CheckedCssClass); } run(input: ProfilerInput): TPromise { this.checked = !this.checked; - this._setLabel(this.checked ? nls.localize('profilerAction.autoscrollOn', "Auto Scroll: On") : nls.localize('profilerAction.autoscrollOff', "Auto Scroll: Off")); + this._setLabel(this.checked ? ProfilerAutoScroll.AutoScrollOnText : ProfilerAutoScroll.AutoScrollOffText); + this._setClass(this.checked ? ProfilerAutoScroll.CheckedCssClass : ''); input.state.change({ autoscroll: this.checked }); return TPromise.as(true); } @@ -256,7 +268,7 @@ export class ProfilerFindPrevious implements IEditorAction { export class NewProfilerAction extends Task { public static readonly ID = 'profiler.newProfiler'; - public static readonly LABEL = nls.localize('profilerAction.newProfiler', 'New Profiler'); + public static readonly LABEL = nls.localize('profilerAction.newProfiler', 'Launch Profiler'); public static readonly ICON = 'profile'; private _connectionProfile: ConnectionProfile; diff --git a/src/sql/parts/profiler/contrib/profilerWorkbenchActions.ts b/src/sql/parts/profiler/contrib/profilerWorkbenchActions.ts deleted file mode 100644 index 02e913132a..0000000000 --- a/src/sql/parts/profiler/contrib/profilerWorkbenchActions.ts +++ /dev/null @@ -1,52 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -'use strict'; -import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput'; - -import { TPromise } from 'vs/base/common/winjs.base'; -import { Action } from 'vs/base/common/actions'; -import * as nls from 'vs/nls'; - -import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement'; -import { IConnectionProfile } from 'sql/parts/connection/common/interfaces'; - -export class GlobalNewProfilerAction extends Action { - public static ID = 'explorer.newProfiler'; - public static LABEL = nls.localize('profilerWorkbenchAction.newProfiler', "New Profiler"); - - constructor( - id: string, label: string, - @IEditorService private _editorService: IEditorService, - @IInstantiationService private _instantiationService: IInstantiationService, - @IConnectionManagementService private _connectionService: IConnectionManagementService - ) { - super(id, label); - } - - run(context?: any): TPromise { - // TODO: for test-only, grab the first MSSQL active connection for the profiler session - // TODO: when finishing the feature the connection should come from the launch context - let connectionProfile: IConnectionProfile; - if (context && context.connectionProfile) { - connectionProfile = context.connectionProfile; - } else { - let activeConnections = this._connectionService.getActiveConnections(); - if (activeConnections) { - for (let i = 0; i < activeConnections.length; ++i) { - if (activeConnections[i].providerName === 'MSSQL') { - connectionProfile = activeConnections[i]; - break; - } - } - } - } - - let profilerInput = this._instantiationService.createInstance(ProfilerInput, connectionProfile); - return this._editorService.openEditor(profilerInput, { pinned: true }, ACTIVE_GROUP).then(() => TPromise.as(true)); - } -} diff --git a/src/sql/parts/profiler/editor/profilerEditor.ts b/src/sql/parts/profiler/editor/profilerEditor.ts index d59a941b6f..349ab72b7f 100644 --- a/src/sql/parts/profiler/editor/profilerEditor.ts +++ b/src/sql/parts/profiler/editor/profilerEditor.ts @@ -122,7 +122,6 @@ export class ProfilerEditor extends BaseEditor { private _viewTemplates: Array; private _sessionSelector: SelectBox; private _sessionsList: Array; - private _connectionInfoText: HTMLElement; // Actions private _connectAction: Actions.ProfilerConnect; @@ -211,6 +210,7 @@ export class ProfilerEditor extends BaseEditor { this._viewTemplates = this._profilerService.getViewTemplates(); this._viewTemplateSelector = new SelectBox(this._viewTemplates.map(i => i.name), 'Standard View', this._contextViewService); + this._viewTemplateSelector.setAriaLabel(nls.localize('profiler.viewSelectAccessibleName', 'Select View')); this._register(this._viewTemplateSelector.onDidSelect(e => { if (this.input) { this.input.viewTemplate = this._viewTemplates.find(i => i.name === e.selected); @@ -223,6 +223,7 @@ export class ProfilerEditor extends BaseEditor { this._sessionsList = ['']; this._sessionSelector = new SelectBox(this._sessionsList, '', this._contextViewService); + this._sessionSelector.setAriaLabel(nls.localize('profiler.sessionSelectAccessibleName', 'Select Session')); this._register(this._sessionSelector.onDidSelect(e => { if (this.input) { this.input.sessionName = e.selected; @@ -233,32 +234,36 @@ export class ProfilerEditor extends BaseEditor { sessionsContainer.style.paddingRight = '5px'; this._sessionSelector.render(sessionsContainer); - this._connectionInfoText = document.createElement('div'); - this._connectionInfoText.style.paddingRight = '5px'; - this._connectionInfoText.innerText = ''; - this._connectionInfoText.style.textAlign = 'center'; - this._connectionInfoText.style.display = 'flex'; - this._connectionInfoText.style.alignItems = 'center'; - this._register(attachSelectBoxStyler(this._viewTemplateSelector, this.themeService)); this._register(attachSelectBoxStyler(this._sessionSelector, this.themeService)); this._actionBar.setContent([ - { action: this._startAction }, - { action: this._stopAction }, - { element: sessionsContainer }, { action: this._createAction }, { element: Taskbar.createTaskbarSeparator() }, + { element: this._createTextElement(nls.localize('profiler.sessionSelectLabel', 'Select Session:')) }, + { element: sessionsContainer }, + { action: this._startAction }, + { action: this._stopAction }, { action: this._pauseAction }, - { action: this._autoscrollAction }, - { action: this._instantiationService.createInstance(Actions.ProfilerClear, Actions.ProfilerClear.ID, Actions.ProfilerClear.LABEL) }, { element: Taskbar.createTaskbarSeparator() }, + { element: this._createTextElement(nls.localize('profiler.viewSelectLabel', 'Select View:')) }, { element: viewTemplateContainer }, { element: Taskbar.createTaskbarSeparator() }, - { element: this._connectionInfoText } + { action: this._autoscrollAction }, + { action: this._instantiationService.createInstance(Actions.ProfilerClear, Actions.ProfilerClear.ID, Actions.ProfilerClear.LABEL) } ]); } + private _createTextElement(text: string): HTMLDivElement { + let textElement = document.createElement('div'); + textElement.style.paddingRight = '10px'; + textElement.innerText = text; + textElement.style.textAlign = 'center'; + textElement.style.display = 'flex'; + textElement.style.alignItems = 'center'; + return textElement; + } + private _createProfilerTable(): HTMLElement { let profilerTableContainer = document.createElement('div'); profilerTableContainer.className = 'profiler-table monaco-editor'; @@ -417,7 +422,6 @@ export class ProfilerEditor extends BaseEditor { autoscroll: true, isPanelCollapsed: true }); - this._connectionInfoText.innerText = input.connectionName; this._profilerTableEditor.updateState(); this._splitView.layout(); this._profilerTableEditor.focus(); @@ -529,6 +533,11 @@ export class ProfilerEditor extends BaseEditor { if ((this.input.sessionName === undefined || this.input.sessionName === '') && this._sessionsList.length > 0) { this.input.sessionName = this._sessionsList[0]; } + + if (this.input.sessionName) { + this._sessionSelector.selectWithOptionName(this.input.sessionName); + } + }); } } diff --git a/src/sql/parts/profiler/editor/profilerInput.ts b/src/sql/parts/profiler/editor/profilerInput.ts index 29b1884167..6d8e0d8bf6 100644 --- a/src/sql/parts/profiler/editor/profilerInput.ts +++ b/src/sql/parts/profiler/editor/profilerInput.ts @@ -41,7 +41,7 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { public onColumnsChanged: Event[]> = this._onColumnsChanged.event; constructor( - private _connection: IConnectionProfile, + public connection: IConnectionProfile, @IInstantiationService private _instantiationService: IInstantiationService, @IProfilerService private _profilerService: IProfilerService, @INotificationService private _notificationService: INotificationService, @@ -58,7 +58,7 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { autoscroll: true }); - this._profilerService.registerSession(generateUuid(), _connection, this).then((id) => { + this._profilerService.registerSession(generateUuid(), connection, this).then((id) => { this._id = id; this.state.change({ isConnected: true }); }); @@ -92,7 +92,7 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { } public get providerType(): string { - return this._connection ? this._connection.providerName : undefined; + return this.connection ? this.connection.providerName : undefined; } public set viewTemplate(template: IProfilerViewTemplate) { @@ -137,10 +137,10 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { public getName(): string { let name: string = nls.localize('profilerInput.profiler', 'Profiler'); - if (!this._connection) { + if (!this.connection) { return name; } - name += ': ' + this._connection.serverName.substring(0, 20); + name += ': ' + this.connection.serverName.substring(0, 20); return name; } @@ -182,11 +182,11 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { } public get connectionName(): string { - if (!types.isUndefinedOrNull(this._connection)) { - if (this._connection.databaseName) { - return `${this._connection.serverName} ${this._connection.databaseName}`; + if (!types.isUndefinedOrNull(this.connection)) { + if (this.connection.databaseName) { + return `${this.connection.serverName} ${this.connection.databaseName}`; } else { - return `${this._connection.serverName}`; + return `${this.connection.serverName}`; } } else { @@ -203,7 +203,7 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { } public onSessionStopped(notification: sqlops.ProfilerSessionStoppedParams) { - this._notificationService.error(nls.localize("profiler.sessionStopped", "XEvent Profiler Session stopped unexpectedly on the server {0}.", this._connection.serverName)); + this._notificationService.error(nls.localize("profiler.sessionStopped", "XEvent Profiler Session stopped unexpectedly on the server {0}.", this.connection.serverName)); this.state.change({ isStopped: true, @@ -244,7 +244,7 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { public onMoreRows(eventMessage: sqlops.ProfilerSessionEvents) { if (eventMessage.eventsLost) { - this._notificationService.warn(nls.localize("profiler.eventsLost", "The XEvent Profiler session for {0} has lost events.", this._connection.serverName)); + this._notificationService.warn(nls.localize("profiler.eventsLost", "The XEvent Profiler session for {0} has lost events.", this.connection.serverName)); } for (let i: number = 0; i < eventMessage.events.length && i < 500; ++i) { diff --git a/src/sql/workbench/common/taskUtilities.ts b/src/sql/workbench/common/taskUtilities.ts index 05f3469fde..415d1b72ac 100644 --- a/src/sql/workbench/common/taskUtilities.ts +++ b/src/sql/workbench/common/taskUtilities.ts @@ -28,6 +28,7 @@ import { IObjectExplorerService } from 'sql/parts/objectExplorer/common/objectEx import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { QueryInput } from 'sql/parts/query/common/queryInput'; import { DashboardInput } from 'sql/parts/dashboard/dashboardInput'; +import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput'; // map for the version of SQL Server (default is 140) const scriptCompatibilityOptionMap = { @@ -400,6 +401,9 @@ export function getCurrentGlobalConnection(objectExplorerService: IObjectExplore if (activeInput instanceof QueryInput || activeInput instanceof EditDataInput || activeInput instanceof DashboardInput) { connection = connectionManagementService.getConnectionProfile(activeInput.uri); } + else if (activeInput instanceof ProfilerInput) { + connection = activeInput.connection; + } } return connection;