relayer connection code; formatting (#5020)

This commit is contained in:
Anthony Dresser
2019-04-15 01:05:23 -07:00
committed by GitHub
parent 57242a2e13
commit 72e7e5e025
25 changed files with 56 additions and 89 deletions

View File

@@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { OptionsDialog } from 'sql/workbench/browser/modal/optionsDialog';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import * as azdata from 'azdata';
import { localize } from 'vs/nls';
import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys';
export class AdvancedPropertiesController {
private _advancedDialog: OptionsDialog;
private _options: { [name: string]: any };
constructor(private _onCloseAdvancedProperties: () => void,
@IInstantiationService private _instantiationService: IInstantiationService
) {
}
private handleOnOk(): void {
this._options = this._advancedDialog.optionValues;
}
public showDialog(providerOptions: azdata.ConnectionOption[], container: HTMLElement, options: { [name: string]: any }): void {
this._options = options;
var serviceOptions = providerOptions.map(option => AdvancedPropertiesController.connectionOptionToServiceOption(option));
this.advancedDialog.open(serviceOptions, this._options);
}
public get advancedDialog() {
if (!this._advancedDialog) {
this._advancedDialog = this._instantiationService.createInstance(
OptionsDialog, localize('connectionAdvancedProperties', 'Advanced Properties'), TelemetryKeys.ConnectionAdvancedProperties, { hasBackButton: true, cancelLabel: localize('advancedProperties.discard', 'Discard') });
this._advancedDialog.onCloseEvent(() => this._onCloseAdvancedProperties());
this._advancedDialog.onOk(() => this.handleOnOk());
this._advancedDialog.render();
}
return this._advancedDialog;
}
public set advancedDialog(dialog: OptionsDialog) {
this._advancedDialog = dialog;
}
public static connectionOptionToServiceOption(connectionOption: azdata.ConnectionOption): azdata.ServiceOption {
return {
name: connectionOption.name,
displayName: connectionOption.displayName,
description: connectionOption.description,
groupName: connectionOption.groupName,
valueType: connectionOption.valueType,
defaultValue: connectionOption.defaultValue,
objectType: undefined,
categoryValues: connectionOption.categoryValues,
isRequired: connectionOption.isRequired,
isArray: undefined,
};
}
}

View File

@@ -0,0 +1,78 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { AddServerGroupAction, AddServerAction } from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
import { ClearRecentConnectionsAction, GetCurrentConnectionStringAction } from 'sql/workbench/parts/connection/common/connectionActions';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { localize } from 'vs/nls';
// Connection Dashboard registration
const actionRegistry = <IWorkbenchActionRegistry>Registry.as(Extensions.WorkbenchActions);
// Connection Actions
actionRegistry.registerWorkbenchAction(
new SyncActionDescriptor(
ClearRecentConnectionsAction,
ClearRecentConnectionsAction.ID,
ClearRecentConnectionsAction.LABEL
),
ClearRecentConnectionsAction.LABEL
);
actionRegistry.registerWorkbenchAction(
new SyncActionDescriptor(
AddServerGroupAction,
AddServerGroupAction.ID,
AddServerGroupAction.LABEL
),
AddServerGroupAction.LABEL
);
actionRegistry.registerWorkbenchAction(
new SyncActionDescriptor(
AddServerAction,
AddServerAction.ID,
AddServerAction.LABEL
),
AddServerAction.LABEL
);
actionRegistry.registerWorkbenchAction(
new SyncActionDescriptor(
GetCurrentConnectionStringAction,
GetCurrentConnectionStringAction.ID,
GetCurrentConnectionStringAction.LABEL
),
GetCurrentConnectionStringAction.LABEL
);
const configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigExtensions.Configuration);
configurationRegistry.registerConfiguration({
'id': 'connection',
'title': 'Connection',
'type': 'object',
'properties': {
'sql.maxRecentConnections': {
'type': 'number',
'default': 25,
'description': localize('sql.maxRecentConnectionsDescription', 'The maximum number of recently used connections to store in the connection list.')
},
'sql.defaultEngine': {
'type': 'string',
'description': localize('sql.defaultEngineDescription', 'Default SQL Engine to use. This drives default language provider in .sql files and the default to use when creating a new connection. Valid option is currently MSSQL'),
'default': 'MSSQL'
},
'connection.parseClipboardForConnectionString': {
'type': 'boolean',
'default': true,
'description': localize('connection.parseClipboardForConnectionStringDescription', 'Attempt to parse the contents of the clipboard when the connection dialog is opened or a paste is performed.')
}
}
});

View File

@@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { $, append, show, hide } from 'vs/base/browser/dom';
import { IDisposable, combinedDisposable } from 'vs/base/common/lifecycle';
import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
import * as TaskUtilities from 'sql/workbench/common/taskUtilities';
// Connection status bar showing the current global connection
export class ConnectionStatusbarItem implements IStatusbarItem {
private _element: HTMLElement;
private _connectionElement: HTMLElement;
private _toDispose: IDisposable[];
constructor(
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
@IEditorService private _editorService: IEditorService,
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
) {
}
public render(container: HTMLElement): IDisposable {
this._element = append(container, $('.connection-statusbar-item'));
this._connectionElement = append(this._element, $('div.connection-statusbar-conninfo'));
hide(this._connectionElement);
this._toDispose = [];
this._toDispose.push(
this._connectionManagementService.onConnect(() => this._updateStatus()),
this._connectionManagementService.onConnectionChanged(() => this._updateStatus()),
this._connectionManagementService.onDisconnect(() => this._updateStatus()),
this._editorService.onDidActiveEditorChange(() => this._updateStatus()),
this._objectExplorerService.onSelectionOrFocusChange(() => this._updateStatus())
);
return combinedDisposable(this._toDispose);
}
// Update the connection status shown in the bar
private _updateStatus(): void {
let activeConnection = TaskUtilities.getCurrentGlobalConnection(this._objectExplorerService, this._connectionManagementService, this._editorService);
if (activeConnection) {
this._setConnectionText(activeConnection);
show(this._connectionElement);
} else {
hide(this._connectionElement);
}
}
// Set connection info to connection status bar
private _setConnectionText(connectionProfile: IConnectionProfile): void {
let text: string = connectionProfile.serverName;
if (text) {
if (connectionProfile.databaseName && connectionProfile.databaseName !== '') {
text = text + ' : ' + connectionProfile.databaseName;
} else {
text = text + ' : ' + '<default>';
}
}
let tooltip: string =
'Server: ' + connectionProfile.serverName + '\r\n' +
'Database: ' + (connectionProfile.databaseName ? connectionProfile.databaseName : '<default>') + '\r\n';
if (connectionProfile.userName && connectionProfile.userName !== '') {
tooltip = tooltip + 'Login: ' + connectionProfile.userName + '\r\n';
}
this._connectionElement.textContent = text;
this._connectionElement.title = tooltip;
}
}

View File

@@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { DefaultController, ICancelableEvent } from 'vs/base/parts/tree/browser/treeDefaults';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { ITree } from 'vs/base/parts/tree/browser/tree';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { ClearSingleRecentConnectionAction } from 'sql/workbench/parts/connection/common/connectionActions';
import { ContributableActionProvider } from 'vs/workbench/browser/actions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { IAction } from 'vs/base/common/actions';
import { Event, Emitter } from 'vs/base/common/event';
import mouse = require('vs/base/browser/mouseEvent');
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
export class RecentConnectionActionsProvider extends ContributableActionProvider {
private _onRecentConnectionRemoved = new Emitter<void>();
public onRecentConnectionRemoved: Event<void> = this._onRecentConnectionRemoved.event;
constructor(
@IInstantiationService private _instantiationService: IInstantiationService
) {
super();
}
private getRecentConnectionActions(tree: ITree, element: any): IAction[] {
let actions: IAction[] = [];
let clearSingleConnectionAction = this._instantiationService.createInstance(ClearSingleRecentConnectionAction, ClearSingleRecentConnectionAction.ID,
ClearSingleRecentConnectionAction.LABEL, <IConnectionProfile>element);
clearSingleConnectionAction.onRecentConnectionRemoved(() => this._onRecentConnectionRemoved.fire());
actions.push(clearSingleConnectionAction);
return actions;
}
public hasActions(tree: ITree, element: any): boolean {
return element instanceof ConnectionProfile;
}
/**
* Return actions given an element in the tree
*/
public getActions(tree: ITree, element: any): IAction[] {
if (element instanceof ConnectionProfile) {
return this.getRecentConnectionActions(tree, element);
}
return [];
}
}
export class RecentConnectionsActionsContext {
public connectionProfile: ConnectionProfile;
public container: HTMLElement;
public tree: ITree;
}
export class RecentConnectionTreeController extends DefaultController {
private _onRecentConnectionRemoved = new Emitter<void>();
public onRecentConnectionRemoved: Event<void> = this._onRecentConnectionRemoved.event;
constructor(
private clickcb: (element: any, eventish: ICancelableEvent, origin: string) => void,
private actionProvider: RecentConnectionActionsProvider,
private _connectionManagementService: IConnectionManagementService,
@IContextMenuService private _contextMenuService: IContextMenuService
) {
super();
}
protected onLeftClick(tree: ITree, element: any, eventish: ICancelableEvent, origin: string = 'mouse'): boolean {
this.clickcb(element, eventish, origin);
return super.onLeftClick(tree, element, eventish, origin);
}
protected onEnter(tree: ITree, event: IKeyboardEvent): boolean {
super.onEnter(tree, event);
this.clickcb(tree.getSelection()[0], event, 'keyboard');
return true;
}
protected onRightClick(tree: ITree, element: any, eventish: ICancelableEvent, origin: string = 'mouse'): boolean {
this.clickcb(element, eventish, origin);
this.showContextMenu(tree, element, event);
return true;
}
public onMouseDown(tree: ITree, element: any, event: mouse.IMouseEvent, origin: string = 'mouse'): boolean {
if (event.leftButton || event.middleButton) {
return this.onLeftClick(tree, element, event, origin);
} else {
return this.onRightClick(tree, element, event);
}
}
public onKeyDown(tree: ITree, event: IKeyboardEvent): boolean {
if (event.keyCode === 20) {
let element = tree.getFocus();
if (element instanceof ConnectionProfile) {
this._connectionManagementService.clearRecentConnection(element);
this._onRecentConnectionRemoved.fire();
return true;
}
}
return super.onKeyDown(tree, event);
}
public showContextMenu(tree: ITree, element: any, event: any): boolean {
var actionContext: any;
if (element instanceof ConnectionProfile) {
actionContext = new RecentConnectionsActionsContext();
actionContext.container = event.target;
actionContext.connectionProfile = <ConnectionProfile>element;
actionContext.tree = tree;
} else {
actionContext = element;
}
let anchor = { x: event.x + 1, y: event.y };
this._contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActions: () => this.actionProvider.getActions(tree, element),
onHide: (wasCancelled?: boolean) => {
if (wasCancelled) {
tree.domFocus();
}
},
getActionsContext: () => (actionContext)
});
return true;
}
}

View File

@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { DefaultController, ICancelableEvent } from 'vs/base/parts/tree/browser/treeDefaults';
import { ITree } from 'vs/base/parts/tree/browser/tree';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
export class SavedConnectionTreeController extends DefaultController {
constructor(private clickcb: (element: any, eventish: ICancelableEvent, origin: string) => void) {
super();
}
protected onLeftClick(tree: ITree, element: any, eventish: ICancelableEvent, origin: string = 'mouse'): boolean {
this.clickcb(element, eventish, origin);
return super.onLeftClick(tree, element, eventish, origin);
}
protected onEnter(tree: ITree, event: IKeyboardEvent): boolean {
super.onEnter(tree, event);
// grab the current selection for use later
let selection = tree.getSelection();
this.clickcb(selection[0], event, 'keyboard');
tree.toggleExpansion(selection[0]);
return true;
}
}

View File

@@ -0,0 +1,27 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// ------------------------------- < Cancel Connect Request > ---------------------------------------
/**
* Cancel connect request message format
*/
export class CancelConnectParams {
/**
* URI identifying the owner of the connection
*/
public ownerUri: string;
}
// ------------------------------- </ Cancel Connect Request > --------------------------------------
// ------------------------------- < Disconnect Request > -------------------------------------------
// Disconnect request message format
export class DisconnectParams {
// URI identifying the owner of the connection
public ownerUri: string;
}
// ------------------------------- </ Disconnect Request > ------------------------------------------

View File

@@ -0,0 +1,180 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import nls = require('vs/nls');
import { Action } from 'vs/base/common/actions';
import { Event, Emitter } from 'vs/base/common/event';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { INotificationService, INotificationActions } from 'vs/platform/notification/common/notification';
import Severity from 'vs/base/common/severity';
import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { QueryInput } from 'sql/parts/query/common/queryInput';
import { EditDataInput } from 'sql/parts/editData/common/editDataInput';
import { DashboardInput } from 'sql/workbench/parts/dashboard/dashboardInput';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
/**
* Workbench action to clear the recent connnections list
*/
export class ClearRecentConnectionsAction extends Action {
public static ID = 'clearRecentConnectionsAction';
public static LABEL = nls.localize('ClearRecentlyUsedLabel', 'Clear List');
public static ICON = 'search-action clear-search-results';
private _onRecentConnectionsRemoved = new Emitter<void>();
public onRecentConnectionsRemoved: Event<void> = this._onRecentConnectionsRemoved.event;
private _useConfirmationMessage = false;
constructor(
id: string,
label: string,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
@INotificationService private _notificationService: INotificationService,
@IQuickInputService private _quickInputService: IQuickInputService,
@IDialogService private _dialogService: IDialogService,
) {
super(id, label, ClearRecentConnectionsAction.ICON);
this.enabled = true;
}
public set useConfirmationMessage(value: boolean) {
this._useConfirmationMessage = value;
}
public run(): Promise<void> {
if (this._useConfirmationMessage) {
return this.promptConfirmationMessage().then(result => {
if (result.confirmed) {
this._connectionManagementService.clearRecentConnectionsList();
this._onRecentConnectionsRemoved.fire();
}
});
} else {
return this.promptQuickOpenService().then(result => {
if (result) {
this._connectionManagementService.clearRecentConnectionsList();
const actions: INotificationActions = { primary: [] };
this._notificationService.notify({
severity: Severity.Info,
message: nls.localize('ClearedRecentConnections', 'Recent connections list cleared'),
actions
});
this._onRecentConnectionsRemoved.fire();
}
});
}
}
private promptQuickOpenService(): Promise<boolean> {
const self = this;
return new Promise<boolean>((resolve, reject) => {
let choices: { key, value }[] = [
{ key: nls.localize('connectionAction.yes', 'Yes'), value: true },
{ key: nls.localize('connectionAction.no', 'No'), value: false }
];
self._quickInputService.pick(choices.map(x => x.key), { placeHolder: nls.localize('ClearRecentlyUsedLabel', 'Clear List'), ignoreFocusLost: true }).then((choice) => {
let confirm = choices.find(x => x.key === choice);
resolve(confirm && confirm.value);
});
});
}
private promptConfirmationMessage(): Promise<IConfirmationResult> {
let confirm: IConfirmation = {
message: nls.localize('clearRecentConnectionMessage', 'Are you sure you want to delete all the connections from the list?'),
primaryButton: nls.localize('connectionDialog.yes', 'Yes'),
secondaryButton: nls.localize('connectionDialog.no', 'No'),
type: 'question'
};
return new Promise<IConfirmationResult>((resolve, reject) => {
this._dialogService.confirm(confirm).then((confirmed) => {
resolve(confirmed);
});
});
}
}
/**
* Action to delete one recently used connection from the MRU
*/
export class ClearSingleRecentConnectionAction extends Action {
public static ID = 'clearSingleRecentConnectionAction';
public static LABEL = nls.localize('delete', 'Delete');
private _onRecentConnectionRemoved = new Emitter<void>();
public onRecentConnectionRemoved: Event<void> = this._onRecentConnectionRemoved.event;
constructor(
id: string,
label: string,
private _connectionProfile: IConnectionProfile,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
) {
super(id, label);
this.enabled = true;
}
public run(): Promise<void> {
return new Promise<void>((resolve, reject) => {
resolve(this._connectionManagementService.clearRecentConnection(this._connectionProfile));
this._onRecentConnectionRemoved.fire();
});
}
}
/**
* Action to retrieve the current connection string
*/
export class GetCurrentConnectionStringAction extends Action {
public static ID = 'getCurrentConnectionStringAction';
public static LABEL = nls.localize('connectionAction.GetCurrentConnectionString', "Get Current Connection String");
constructor(
id: string,
label: string,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
@IEditorService private _editorService: IEditorService,
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
@INotificationService private readonly _notificationService: INotificationService,
@IClipboardService private _clipboardService: IClipboardService,
) {
super(GetCurrentConnectionStringAction.ID, GetCurrentConnectionStringAction.LABEL);
this.enabled = true;
}
public run(): Promise<void> {
return new Promise<void>((resolve, reject) => {
let activeInput = this._editorService.activeEditor;
if (activeInput && (activeInput instanceof QueryInput || activeInput instanceof EditDataInput || activeInput instanceof DashboardInput)
&& this._connectionManagementService.isConnected(activeInput.uri)) {
let includePassword = false;
let connectionProfile = this._connectionManagementService.getConnectionProfile(activeInput.uri);
this._connectionManagementService.getConnectionString(connectionProfile.id, includePassword).then(result => {
//Copy to clipboard
this._clipboardService.writeText(result);
let message = result
? result
: nls.localize('connectionAction.connectionString', "Connection string not available");
this._notificationService.info(message);
});
} else {
let message = nls.localize('connectionAction.noConnection', "No active connection available");
this._notificationService.info(message);
}
});
}
}

View File

@@ -0,0 +1,47 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IConnectionProfile } from 'azdata';
export class ConnectionContextKey implements IContextKey<IConnectionProfile> {
static Provider = new RawContextKey<string>('connectionProvider', undefined);
static Server = new RawContextKey<string>('serverName', undefined);
static Database = new RawContextKey<string>('databaseName', undefined);
static Connection = new RawContextKey<IConnectionProfile>('connection', undefined);
private _providerKey: IContextKey<string>;
private _serverKey: IContextKey<string>;
private _databaseKey: IContextKey<string>;
private _connectionKey: IContextKey<IConnectionProfile>;
constructor(
@IContextKeyService contextKeyService: IContextKeyService
) {
this._providerKey = ConnectionContextKey.Provider.bindTo(contextKeyService);
this._serverKey = ConnectionContextKey.Server.bindTo(contextKeyService);
this._databaseKey = ConnectionContextKey.Database.bindTo(contextKeyService);
this._connectionKey = ConnectionContextKey.Connection.bindTo(contextKeyService);
}
set(value: IConnectionProfile) {
this._connectionKey.set(value);
this._providerKey.set(value && value.providerName);
this._serverKey.set(value && value.serverName);
this._databaseKey.set(value && value.databaseName);
}
reset(): void {
this._providerKey.reset();
this._serverKey.reset();
this._databaseKey.reset();
this._connectionKey.reset();
}
public get(): IConnectionProfile {
return this._connectionKey.get();
}
}

View File

@@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ConnectionSummary } from 'azdata';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import * as LocalizedConstants from 'sql/workbench/parts/connection/common/localizedConstants';
// Status when making connections from the viewlet
export class ConnectionGlobalStatus {
private _displayTime: number = 5000; // (in ms)
constructor(
@IStatusbarService private _statusBarService: IStatusbarService
) {
}
public setStatusToConnected(connectionSummary: ConnectionSummary): void {
if (this._statusBarService) {
let text: string;
let connInfo: string = connectionSummary.serverName;
if (connInfo) {
if (connectionSummary.databaseName && connectionSummary.databaseName !== '') {
connInfo = connInfo + ' : ' + connectionSummary.databaseName;
} else {
connInfo = connInfo + ' : ' + '<default>';
}
text = LocalizedConstants.onDidConnectMessage + ' ' + connInfo;
}
this._statusBarService.setStatusMessage(text, this._displayTime);
}
}
public setStatusToDisconnected(fileUri: string): void {
if (this._statusBarService) {
this._statusBarService.setStatusMessage(LocalizedConstants.onDidDisconnectMessage, this._displayTime);
}
}
}

View File

@@ -2,8 +2,9 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IViewlet } from 'vs/workbench/common/viewlet';
export interface IConnectionsViewlet extends IViewlet {
search(text: string): void;
}
import { localize } from 'vs/nls';
export const onDidConnectMessage = localize('onDidConnectMessage', 'Connected to');
export const onDidDisconnectMessage = localize('onDidDisconnectMessage', 'Disconnected');
export const unsavedGroupLabel = localize('unsavedGroupLabel', 'Unsaved Connections');

View File

@@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { ServerInfo } from 'azdata';
export class ServerInfoContextKey implements IContextKey<ServerInfo> {
static ServerInfo = new RawContextKey<ServerInfo>('serverInfo', undefined);
static ServerMajorVersion = new RawContextKey<string>('serverMajorVersion', undefined);
private _serverInfo: IContextKey<ServerInfo>;
private _serverMajorVersion: IContextKey<string>;
constructor(
@IContextKeyService contextKeyService: IContextKeyService
) {
this._serverInfo = ServerInfoContextKey.ServerInfo.bindTo(contextKeyService);
this._serverMajorVersion = ServerInfoContextKey.ServerMajorVersion.bindTo(contextKeyService);
}
set(value: ServerInfo) {
this._serverInfo.set(value);
let majorVersion = value && value.serverMajorVersion;
this._serverMajorVersion.set(majorVersion && `${majorVersion}`);
}
reset(): void {
this._serverMajorVersion.reset();
}
public get(): ServerInfo {
return this._serverInfo.get();
}
}

View File

@@ -3,33 +3,24 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./media/connectionViewlet';
import * as DOM from 'vs/base/browser/dom';
import { Viewlet } from 'vs/workbench/browser/viewlet';
import { IAction } from 'vs/base/common/actions';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachInputBoxStyler } from 'vs/platform/theme/common/styler';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import Severity from 'vs/base/common/severity';
import { VIEWLET_ID } from 'sql/platform/connection/common/connectionManagement';
import { ServerTreeView } from 'sql/parts/objectExplorer/viewlet/serverTreeView';
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ClearSearchAction, AddServerAction, AddServerGroupAction, ActiveConnectionsFilterAction } from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
import { AddServerAction, AddServerGroupAction, ActiveConnectionsFilterAction } from 'sql/parts/objectExplorer/viewlet/connectionTreeAction';
import { warn } from 'sql/base/common/log';
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IConnectionsViewlet } from 'sql/workbench/parts/connection/common/connectionViewlet';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet {
export class ConnectionViewlet extends Viewlet {
private _root: HTMLElement;
private _toDisposeViewlet: IDisposable[] = [];
@@ -40,16 +31,15 @@ export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet {
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IThemeService private _themeService: IThemeService,
@IThemeService themeService: IThemeService,
@IInstantiationService private _instantiationService: IInstantiationService,
@INotificationService private _notificationService: INotificationService,
@IObjectExplorerService private objectExplorerService: IObjectExplorerService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@IConfigurationService configurationService: IConfigurationService,
@IStorageService storageService: IStorageService
) {
super(VIEWLET_ID, configurationService, layoutService, telemetryService, _themeService, storageService);
super(VIEWLET_ID, configurationService, layoutService, telemetryService, themeService, storageService);
this._addServerAction = this._instantiationService.createInstance(AddServerAction,
AddServerAction.ID,
@@ -62,16 +52,6 @@ export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet {
this.objectExplorerService.registerServerTreeView(this._serverTreeView);
}
private onError(err: any): void {
if (isPromiseCanceledError(err)) {
return;
}
this._notificationService.notify({
severity: Severity.Error,
message: err
});
}
public create(parent: HTMLElement): void {
super.create(parent);
this._root = parent;

View File

@@ -0,0 +1,21 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { DashboardEditor } from 'sql/workbench/parts/dashboard/dashboardEditor';
import { DashboardInput } from 'sql/workbench/parts/dashboard/dashboardInput';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
import { Registry } from 'vs/platform/registry/common/platform';
import { localize } from 'vs/nls';
const dashboardEditorDescriptor = new EditorDescriptor(
DashboardEditor,
DashboardEditor.ID,
localize('dashboard.editor.label', "Dashboard")
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(dashboardEditorDescriptor, [new SyncDescriptor(DashboardInput)]);

View File

@@ -16,7 +16,7 @@ import { DashboardModule } from './dashboard.module';
import { bootstrapAngular } from 'sql/platform/bootstrap/node/bootstrapService';
import { IDashboardComponentParams } from 'sql/platform/bootstrap/node/bootstrapParams';
import { DASHBOARD_SELECTOR } from 'sql/workbench/parts/dashboard/dashboard.component';
import { ConnectionContextKey } from 'sql/parts/connection/common/connectionContextKey';
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
import { IDashboardService } from 'sql/platform/dashboard/browser/dashboardService';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ConnectionContextKey } from 'sql/parts/connection/common/connectionContextKey';
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
import { IOEShimService } from 'sql/parts/objectExplorer/common/objectExplorerViewTreeShim';
import { ITreeItem } from 'sql/workbench/common/views';
import { Disposable } from 'vs/base/common/lifecycle';

View File

@@ -7,7 +7,7 @@
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IConnectionComponentCallbacks, IConnectionComponentController, IConnectionValidateResult } from 'sql/workbench/services/connection/browser/connectionDialogService';
import { AdvancedPropertiesController } from 'sql/parts/connection/connectionDialog/advancedPropertiesController';
import { AdvancedPropertiesController } from 'sql/workbench/parts/connection/browser/advancedPropertiesController';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
import * as Constants from 'sql/platform/connection/common/constants';
@@ -193,4 +193,4 @@ export class ConnectionController implements IConnectionComponentController {
public set databaseDropdownExpanded(val: boolean) {
this._connectionWidget.databaseDropdownExpanded = val;
}
}
}

View File

@@ -15,10 +15,10 @@ import { TreeCreationUtils } from 'sql/parts/objectExplorer/viewlet/treeCreation
import { TreeUpdateUtils, IExpandableTree } from 'sql/parts/objectExplorer/viewlet/treeUpdateUtils';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { TabbedPanel, PanelTabIdentifier } from 'sql/base/browser/ui/panel/panel';
import { RecentConnectionTreeController, RecentConnectionActionsProvider } from 'sql/parts/connection/connectionDialog/recentConnectionTreeController';
import { SavedConnectionTreeController } from 'sql/parts/connection/connectionDialog/savedConnectionTreeController';
import { RecentConnectionTreeController, RecentConnectionActionsProvider } from 'sql/workbench/parts/connection/browser/recentConnectionTreeController';
import { SavedConnectionTreeController } from 'sql/workbench/parts/connection/browser/savedConnectionTreeController';
import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys';
import { ClearRecentConnectionsAction } from 'sql/parts/connection/common/connectionActions';
import { ClearRecentConnectionsAction } from 'sql/workbench/parts/connection/common/connectionActions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';