mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 17:23:05 -05:00
More layering and strictness (#9004)
* 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 * remove no longer good parts * fix issues with startup * another try * fix startup
This commit is contained in:
@@ -10,13 +10,13 @@ import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { ManageActionContext } from 'sql/workbench/browser/actions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ItemContextKey } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { localize } from 'vs/nls';
|
||||
import { OEAction } from 'sql/workbench/contrib/objectExplorer/browser/objectExplorerActions';
|
||||
import { TreeNodeContextKey } from 'sql/workbench/contrib/objectExplorer/common/treeNodeContextKey';
|
||||
import { ConnectionContextKey } from 'sql/workbench/contrib/connection/common/connectionContextKey';
|
||||
import { ConnectionContextKey } from 'sql/workbench/services/connection/common/connectionContextKey';
|
||||
import { ServerInfoContextKey } from 'sql/workbench/contrib/connection/common/serverInfoContextKey';
|
||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
@@ -1,55 +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 { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConnectionProfile } from 'azdata';
|
||||
import { IQueryManagementService } from 'sql/workbench/services/query/common/queryManagement';
|
||||
|
||||
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);
|
||||
static IsQueryProvider = new RawContextKey<boolean>('isQueryProvider', false);
|
||||
|
||||
private _providerKey: IContextKey<string>;
|
||||
private _serverKey: IContextKey<string>;
|
||||
private _databaseKey: IContextKey<string>;
|
||||
private _connectionKey: IContextKey<IConnectionProfile>;
|
||||
private _isQueryProviderKey: IContextKey<boolean>;
|
||||
|
||||
constructor(
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IQueryManagementService private queryManagementService: IQueryManagementService
|
||||
) {
|
||||
this._providerKey = ConnectionContextKey.Provider.bindTo(contextKeyService);
|
||||
this._serverKey = ConnectionContextKey.Server.bindTo(contextKeyService);
|
||||
this._databaseKey = ConnectionContextKey.Database.bindTo(contextKeyService);
|
||||
this._connectionKey = ConnectionContextKey.Connection.bindTo(contextKeyService);
|
||||
this._isQueryProviderKey = ConnectionContextKey.IsQueryProvider.bindTo(contextKeyService);
|
||||
}
|
||||
|
||||
set(value: IConnectionProfile) {
|
||||
let queryProviders = this.queryManagementService.getRegisteredProviders();
|
||||
this._connectionKey.set(value);
|
||||
this._providerKey.set(value && value.providerName);
|
||||
this._serverKey.set(value && value.serverName);
|
||||
this._databaseKey.set(value && value.databaseName);
|
||||
this._isQueryProviderKey.set(value && value.providerName && queryProviders.indexOf(value.providerName) !== -1);
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._providerKey.reset();
|
||||
this._serverKey.reset();
|
||||
this._databaseKey.reset();
|
||||
this._connectionKey.reset();
|
||||
this._isQueryProviderKey.reset();
|
||||
}
|
||||
|
||||
public get(): IConnectionProfile {
|
||||
return this._connectionKey.get();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
ElementRef, OnInit, ChangeDetectorRef, ReflectiveInjector, Injector, Type, ComponentRef
|
||||
} from '@angular/core';
|
||||
|
||||
import { ComponentHostDirective } from 'sql/workbench/contrib/dashboard/browser/core/componentHost.directive';
|
||||
import { ComponentHostDirective } from 'sql/base/browser/componentHost.directive';
|
||||
import { WidgetConfig, WIDGET_CONFIG, IDashboardWidget } from 'sql/workbench/contrib/dashboard/browser/core/dashboardWidget';
|
||||
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
import { RefreshWidgetAction, ToggleMoreWidgetAction, DeleteWidgetAction, CollapseWidgetAction } from 'sql/workbench/contrib/dashboard/browser/core/actions';
|
||||
|
||||
@@ -15,7 +15,7 @@ import { DASHBOARD_CONFIG_ID } from 'sql/workbench/contrib/dashboard/browser/pag
|
||||
import { DATABASE_DASHBOARD_PROPERTIES, databaseDashboardPropertiesSchema, DATABASE_DASHBOARD_SETTING, databaseDashboardSettingSchema, DATABASE_DASHBOARD_TABS, databaseDashboardTabsSchema } from 'sql/workbench/contrib/dashboard/browser/pages/databaseDashboardPage.contribution';
|
||||
import { SERVER_DASHBOARD_PROPERTIES, serverDashboardPropertiesSchema, SERVER_DASHBOARD_SETTING, serverDashboardSettingSchema, SERVER_DASHBOARD_TABS, serverDashboardTabsSchema } from 'sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.contribution';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { TreeNodeContextKey } from 'sql/workbench/contrib/objectExplorer/common/treeNodeContextKey';
|
||||
import { DE_MANAGE_COMMAND_ID, OE_MANAGE_COMMAND_ID } from 'sql/workbench/contrib/dashboard/browser/dashboardActions';
|
||||
|
||||
@@ -28,7 +28,7 @@ import { DashboardServiceInterface } from 'sql/workbench/contrib/dashboard/brows
|
||||
import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service';
|
||||
|
||||
/* Directives */
|
||||
import { ComponentHostDirective } from 'sql/workbench/contrib/dashboard/browser/core/componentHost.directive';
|
||||
import { ComponentHostDirective } from 'sql/base/browser/componentHost.directive';
|
||||
|
||||
/* Base Components */
|
||||
import { DashboardComponent } from 'sql/workbench/contrib/dashboard/browser/dashboard.component';
|
||||
|
||||
@@ -16,7 +16,7 @@ import { DashboardModule } from './dashboard.module';
|
||||
import { bootstrapAngular } from 'sql/workbench/services/bootstrap/browser/bootstrapService';
|
||||
import { IDashboardComponentParams } from 'sql/workbench/services/bootstrap/common/bootstrapParams';
|
||||
import { DASHBOARD_SELECTOR } from 'sql/workbench/contrib/dashboard/browser/dashboard.component';
|
||||
import { ConnectionContextKey } from 'sql/workbench/contrib/connection/common/connectionContextKey';
|
||||
import { ConnectionContextKey } from 'sql/workbench/services/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';
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'rxjs/add/observable/fromPromise';
|
||||
|
||||
import { DashboardWidget, IDashboardWidget, WIDGET_CONFIG, WidgetConfig } from 'sql/workbench/contrib/dashboard/browser/core/dashboardWidget';
|
||||
import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service';
|
||||
import { ComponentHostDirective } from 'sql/workbench/contrib/dashboard/browser/core/componentHost.directive';
|
||||
import { ComponentHostDirective } from 'sql/base/browser/componentHost.directive';
|
||||
import { InsightAction, InsightActionContext } from 'sql/workbench/browser/actions';
|
||||
import { Extensions, IInsightRegistry, IInsightsConfig, IInsightsView, getWidgetAutoRefreshState } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
import { resolveQueryFilePath } from 'sql/workbench/services/insights/common/insightsUtils';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
import * as azdata from 'azdata';
|
||||
import { IOEShimService } from 'sql/workbench/contrib/objectExplorer/browser/objectExplorerViewTreeShim';
|
||||
import { IOEShimService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { DATA_TIER_WIZARD_COMMAND_ID, PROFILER_COMMAND_ID, IMPORT_COMMAND_ID, SCHEMA_COMPARE_COMMAND_ID, GENERATE_SCRIPTS_COMMAND_ID, PROPERTIES_COMMAND_ID } from 'sql/workbench/contrib/dataExplorer/browser/extensionActions';
|
||||
import { ContextKeyExpr, ContextKeyRegexExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import { localize } from 'vs/nls';
|
||||
import { DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
|
||||
@@ -1,183 +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 * as azdata from 'azdata';
|
||||
import { INodeContextValue } from 'sql/workbench/contrib/dataExplorer/browser/nodeContext';
|
||||
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { ExtensionNodeType, DatabaseEngineEdition } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
export class MssqlNodeContext extends Disposable {
|
||||
|
||||
static readonly canSelect = new Set([NodeType.Table, NodeType.View]);
|
||||
static readonly canEditData = new Set([NodeType.Table]);
|
||||
static readonly canCreateOrDelete = new Set([NodeType.AggregateFunction, NodeType.PartitionFunction, NodeType.ScalarValuedFunction,
|
||||
NodeType.Schema, NodeType.StoredProcedure, NodeType.Table, NodeType.TableValuedFunction,
|
||||
NodeType.User, NodeType.UserDefinedTableType, NodeType.View]);
|
||||
static readonly canExecute = new Set([NodeType.StoredProcedure]);
|
||||
static readonly canAlter = new Set([NodeType.AggregateFunction, NodeType.PartitionFunction, NodeType.ScalarValuedFunction,
|
||||
NodeType.StoredProcedure, NodeType.TableValuedFunction, NodeType.View]);
|
||||
|
||||
// General node context keys
|
||||
static NodeProvider = new RawContextKey<string>('nodeProvider', undefined);
|
||||
static IsDatabaseOrServer = new RawContextKey<boolean>('isDatabaseOrServer', false);
|
||||
static IsWindows = new RawContextKey<boolean>('isWindows', isWindows);
|
||||
static IsCloud = new RawContextKey<boolean>('isCloud', false);
|
||||
static NodeType = new RawContextKey<string>('nodeType', undefined);
|
||||
static NodeLabel = new RawContextKey<string>('nodeLabel', undefined);
|
||||
static EngineEdition = new RawContextKey<number>('engineEdition', DatabaseEngineEdition.Unknown);
|
||||
|
||||
// Scripting context keys
|
||||
static CanScriptAsSelect = new RawContextKey<boolean>('canScriptAsSelect', false);
|
||||
static CanEditData = new RawContextKey<boolean>('canEditData', false);
|
||||
static CanScriptAsCreateOrDelete = new RawContextKey<boolean>('canScriptAsCreateOeDelete', false);
|
||||
static CanScriptAsExecute = new RawContextKey<boolean>('canScriptAsExecute', false);
|
||||
static CanScriptAsAlter = new RawContextKey<boolean>('canScriptAsAlter', false);
|
||||
|
||||
private nodeProviderKey: IContextKey<string>;
|
||||
private isCloudKey: IContextKey<boolean>;
|
||||
private nodeTypeKey: IContextKey<string>;
|
||||
private nodeLabelKey: IContextKey<string>;
|
||||
private isDatabaseOrServerKey: IContextKey<boolean>;
|
||||
private engineEditionKey: IContextKey<number>;
|
||||
|
||||
private canScriptAsSelectKey: IContextKey<boolean>;
|
||||
private canEditDataKey: IContextKey<boolean>;
|
||||
private canScriptAsCreateOrDeleteKey: IContextKey<boolean>;
|
||||
private canScriptAsExecuteKey: IContextKey<boolean>;
|
||||
private canScriptAsAlterKey: IContextKey<boolean>;
|
||||
|
||||
constructor(
|
||||
private nodeContextValue: INodeContextValue,
|
||||
@IContextKeyService private contextKeyService: IContextKeyService,
|
||||
@IConnectionManagementService private connectionManagementService: IConnectionManagementService,
|
||||
@ICapabilitiesService private capabilitiesService: ICapabilitiesService
|
||||
) {
|
||||
super();
|
||||
this.bindContextKeys();
|
||||
|
||||
// Set additional node context keys
|
||||
if (this.nodeContextValue.node) {
|
||||
const node = this.nodeContextValue.node;
|
||||
if (node.payload) {
|
||||
this.setNodeProvider();
|
||||
this.setIsCloud();
|
||||
this.setEngineEdition();
|
||||
if (node.type) {
|
||||
this.setIsDatabaseOrServer();
|
||||
this.nodeTypeKey.set(node.type);
|
||||
} else if (node.contextValue && node.providerHandle === mssqlProviderName) {
|
||||
this.setIsDatabaseOrServer();
|
||||
this.setScriptingContextKeys();
|
||||
this.nodeTypeKey.set(node.contextValue);
|
||||
}
|
||||
}
|
||||
if (node.label) {
|
||||
this.nodeLabelKey.set(node.label.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bindContextKeys(): void {
|
||||
this.isCloudKey = MssqlNodeContext.IsCloud.bindTo(this.contextKeyService);
|
||||
this.engineEditionKey = MssqlNodeContext.EngineEdition.bindTo(this.contextKeyService);
|
||||
this.nodeTypeKey = MssqlNodeContext.NodeType.bindTo(this.contextKeyService);
|
||||
this.nodeLabelKey = MssqlNodeContext.NodeLabel.bindTo(this.contextKeyService);
|
||||
this.isDatabaseOrServerKey = MssqlNodeContext.IsDatabaseOrServer.bindTo(this.contextKeyService);
|
||||
this.canScriptAsSelectKey = MssqlNodeContext.CanScriptAsSelect.bindTo(this.contextKeyService);
|
||||
this.canEditDataKey = MssqlNodeContext.CanEditData.bindTo(this.contextKeyService);
|
||||
this.canScriptAsCreateOrDeleteKey = MssqlNodeContext.CanScriptAsCreateOrDelete.bindTo(this.contextKeyService);
|
||||
this.canScriptAsExecuteKey = MssqlNodeContext.CanScriptAsExecute.bindTo(this.contextKeyService);
|
||||
this.canScriptAsAlterKey = MssqlNodeContext.CanScriptAsAlter.bindTo(this.contextKeyService);
|
||||
this.nodeProviderKey = MssqlNodeContext.NodeProvider.bindTo(this.contextKeyService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the node provider
|
||||
*/
|
||||
private setNodeProvider(): void {
|
||||
if (this.nodeContextValue.node.payload.providerName) {
|
||||
this.nodeProviderKey.set(this.nodeContextValue.node.payload.providerName);
|
||||
} else if (this.nodeContextValue.node.childProvider) {
|
||||
this.nodeProviderKey.set(this.nodeContextValue.node.childProvider);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to tell whether a connected node is cloud or not
|
||||
*/
|
||||
private setIsCloud(): void {
|
||||
let serverInfo: azdata.ServerInfo = this.getServerInfo();
|
||||
if (serverInfo && serverInfo.isCloud) {
|
||||
this.isCloudKey.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to set engine edition
|
||||
*/
|
||||
private setEngineEdition(): void {
|
||||
|
||||
let serverInfo: azdata.ServerInfo = this.getServerInfo();
|
||||
if (serverInfo && serverInfo.engineEditionId) {
|
||||
this.engineEditionKey.set(serverInfo.engineEditionId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function fetching the server info
|
||||
*/
|
||||
private getServerInfo(): azdata.ServerInfo | undefined {
|
||||
const profile = new ConnectionProfile(this.capabilitiesService,
|
||||
this.nodeContextValue.node.payload);
|
||||
const connection = this.connectionManagementService.findExistingConnection(profile);
|
||||
if (connection) {
|
||||
return this.connectionManagementService.getServerInfo(connection.id);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to tell whether a connected node is a database or a
|
||||
* server or not. Added this key because this is easier to write than
|
||||
* writing an OR statement in ContextKeyExpr
|
||||
*/
|
||||
private setIsDatabaseOrServer(): void {
|
||||
const isDatabaseOrServer = (this.nodeContextValue.node.contextValue === NodeType.Server ||
|
||||
this.nodeContextValue.node.contextValue === NodeType.Database ||
|
||||
this.nodeContextValue.node.type === ExtensionNodeType.Server ||
|
||||
this.nodeContextValue.node.type === ExtensionNodeType.Database);
|
||||
this.isDatabaseOrServerKey.set(isDatabaseOrServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the correct context from node for showing
|
||||
* scripting context menu actions
|
||||
*/
|
||||
private setScriptingContextKeys(): void {
|
||||
const nodeType = this.nodeContextValue.node.contextValue;
|
||||
if (MssqlNodeContext.canCreateOrDelete.has(nodeType)) {
|
||||
this.canScriptAsCreateOrDeleteKey.set(true);
|
||||
}
|
||||
if (MssqlNodeContext.canEditData.has(nodeType)) {
|
||||
this.canEditDataKey.set(true);
|
||||
}
|
||||
if (MssqlNodeContext.canAlter.has(nodeType)) {
|
||||
this.canScriptAsAlterKey.set(true);
|
||||
}
|
||||
if (MssqlNodeContext.canExecute.has(nodeType)) {
|
||||
this.canScriptAsExecuteKey.set(true);
|
||||
}
|
||||
if (MssqlNodeContext.canSelect.has(nodeType)) {
|
||||
this.canScriptAsSelectKey.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,9 @@ import {
|
||||
DISCONNECT_COMMAND_ID, REFRESH_COMMAND_ID
|
||||
} from './nodeCommands.common';
|
||||
import { ContextKeyExpr, ContextKeyNotEqualsExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { NodeContextKey } from 'sql/workbench/contrib/dataExplorer/browser/nodeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { NodeContextKey } from 'sql/workbench/browser/parts/views/nodeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
|
||||
|
||||
// Disconnect
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IOEShimService } from 'sql/workbench/contrib/objectExplorer/browser/objectExplorerViewTreeShim';
|
||||
import { IOEShimService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim';
|
||||
import { ICustomViewDescriptor, TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IViewsRegistry, Extensions } from 'vs/workbench/common/views';
|
||||
|
||||
@@ -1,89 +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 { ConnectionContextKey } from 'sql/workbench/contrib/connection/common/connectionContextKey';
|
||||
import { IOEShimService } from 'sql/workbench/contrib/objectExplorer/browser/objectExplorerViewTreeShim';
|
||||
import { ITreeItem } from 'sql/workbench/common/views';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IQueryManagementService } from 'sql/workbench/services/query/common/queryManagement';
|
||||
import { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
|
||||
export interface INodeContextValue {
|
||||
node: ITreeItem;
|
||||
viewId: string;
|
||||
}
|
||||
|
||||
export class NodeContextKey extends Disposable implements IContextKey<INodeContextValue> {
|
||||
|
||||
static IsConnectable = new RawContextKey<boolean>('isConnectable', false);
|
||||
static IsConnected = new RawContextKey<boolean>('isConnected', false);
|
||||
static ViewId = new RawContextKey<string>('view', undefined);
|
||||
static ViewItem = new RawContextKey<string>('viewItem', undefined);
|
||||
static Node = new RawContextKey<INodeContextValue>('node', undefined);
|
||||
|
||||
private readonly _connectionContextKey: ConnectionContextKey;
|
||||
private readonly _connectableKey: IContextKey<boolean>;
|
||||
private readonly _connectedKey: IContextKey<boolean>;
|
||||
private readonly _viewIdKey: IContextKey<string>;
|
||||
private readonly _viewItemKey: IContextKey<string>;
|
||||
private readonly _nodeContextKey: IContextKey<INodeContextValue>;
|
||||
|
||||
private _nodeContextUtils: MssqlNodeContext;
|
||||
|
||||
constructor(
|
||||
@IContextKeyService private contextKeyService: IContextKeyService,
|
||||
@IOEShimService private oeService: IOEShimService,
|
||||
@IQueryManagementService queryManagementService: IQueryManagementService,
|
||||
@IConnectionManagementService private connectionManagementService: IConnectionManagementService,
|
||||
@ICapabilitiesService private capabilitiesService: ICapabilitiesService
|
||||
) {
|
||||
super();
|
||||
|
||||
this._connectableKey = NodeContextKey.IsConnectable.bindTo(contextKeyService);
|
||||
this._connectedKey = NodeContextKey.IsConnected.bindTo(contextKeyService);
|
||||
this._viewIdKey = NodeContextKey.ViewId.bindTo(contextKeyService);
|
||||
this._viewItemKey = NodeContextKey.ViewItem.bindTo(contextKeyService);
|
||||
this._nodeContextKey = NodeContextKey.Node.bindTo(contextKeyService);
|
||||
this._connectionContextKey = new ConnectionContextKey(contextKeyService, queryManagementService);
|
||||
}
|
||||
|
||||
set(value: INodeContextValue) {
|
||||
if (value.node && value.node.payload) {
|
||||
this._connectableKey.set(true);
|
||||
this._connectedKey.set(this.oeService.isNodeConnected(value.viewId, value.node));
|
||||
this._connectionContextKey.set(value.node.payload);
|
||||
} else {
|
||||
this._connectableKey.set(false);
|
||||
this._connectedKey.set(false);
|
||||
this._connectionContextKey.reset();
|
||||
}
|
||||
if (value.node) {
|
||||
this._viewItemKey.set(value.node.contextValue);
|
||||
} else {
|
||||
this._viewItemKey.reset();
|
||||
}
|
||||
this._nodeContextKey.set(value);
|
||||
this._viewIdKey.set(value.viewId);
|
||||
this._nodeContextUtils = new MssqlNodeContext(this._nodeContextKey.get(), this.contextKeyService,
|
||||
this.connectionManagementService, this.capabilitiesService);
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._viewIdKey.reset();
|
||||
this._viewItemKey.reset();
|
||||
this._connectableKey.reset();
|
||||
this._connectedKey.reset();
|
||||
this._connectionContextKey.reset();
|
||||
this._nodeContextKey.reset();
|
||||
this._nodeContextUtils.dispose();
|
||||
}
|
||||
|
||||
get(): INodeContextValue | undefined {
|
||||
return this._nodeContextKey.get();
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { INodeContextValue } from 'sql/workbench/contrib/dataExplorer/browser/nodeContext';
|
||||
import { INodeContextValue } from 'sql/workbench/browser/parts/views/nodeContext';
|
||||
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { ExtensionNodeType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
export class NodeContextUtils extends Disposable {
|
||||
@@ -129,8 +128,8 @@ export class NodeContextUtils extends Disposable {
|
||||
private setIsDatabaseOrServer(): void {
|
||||
const isDatabaseOrServer = (this.nodeContextValue.node.contextValue === NodeType.Server ||
|
||||
this.nodeContextValue.node.contextValue === NodeType.Database ||
|
||||
this.nodeContextValue.node.type === ExtensionNodeType.Server ||
|
||||
this.nodeContextValue.node.type === ExtensionNodeType.Database);
|
||||
this.nodeContextValue.node.type === NodeType.Server ||
|
||||
this.nodeContextValue.node.type === NodeType.Database);
|
||||
this.isDatabaseOrServerKey.set(isDatabaseOrServer);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'vs/css!./media/styles';
|
||||
|
||||
import { Table } from 'sql/base/browser/ui/table/table';
|
||||
import { Subscription, Subject } from 'rxjs/Rx';
|
||||
import * as Constants from 'sql/workbench/contrib/query/common/constants';
|
||||
import * as Constants from 'sql/platform/query/common/constants';
|
||||
import * as LocalizedConstants from 'sql/workbench/contrib/query/common/localizedConstants';
|
||||
import { IGridInfo, IGridDataSet, SaveFormat } from 'sql/workbench/contrib/grid/common/interfaces';
|
||||
import * as Utils from 'sql/platform/connection/common/utils';
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { EditorReplacementContribution } from 'sql/workbench/contrib/editorReplacement/common/editorReplacerContribution';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
const workbenchContributionsRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
workbenchContributionsRegistry.registerWorkbenchContribution(EditorReplacementContribution, LifecyclePhase.Starting);
|
||||
@@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IEditorService, IOpenEditorOverride } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { IEditorOptions, ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import * as path from 'vs/base/common/path';
|
||||
|
||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledTextEditorInput';
|
||||
|
||||
const languageAssociationRegistry = Registry.as<ILanguageAssociationRegistry>(LanguageAssociationExtensions.LanguageAssociations);
|
||||
|
||||
export class EditorReplacementContribution implements IWorkbenchContribution {
|
||||
private editorOpeningListener: IDisposable;
|
||||
|
||||
constructor(
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IModeService private readonly modeService: IModeService
|
||||
) {
|
||||
this.editorOpeningListener = this.editorService.overrideOpenEditor((editor, options, group) => this.onEditorOpening(editor, options, group));
|
||||
}
|
||||
|
||||
private onEditorOpening(editor: IEditorInput, options: IEditorOptions | ITextEditorOptions | undefined, group: IEditorGroup): IOpenEditorOverride | undefined {
|
||||
// If the resource was already opened before in the group, do not prevent
|
||||
// the opening of that resource. Otherwise we would have the same settings
|
||||
// opened twice (https://github.com/Microsoft/vscode/issues/36447)
|
||||
// if (group.isOpened(editor)) {
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
if (!(editor instanceof FileEditorInput) && !(editor instanceof UntitledTextEditorInput)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let language: string;
|
||||
if (editor instanceof FileEditorInput) {
|
||||
language = editor.getPreferredMode();
|
||||
} else if (editor instanceof UntitledTextEditorInput) {
|
||||
language = editor.getMode();
|
||||
}
|
||||
|
||||
if (!language) { // in the case the input doesn't have a preferred mode set we will attempt to guess the mode from the file path
|
||||
language = this.modeService.getModeIdByFilepathOrFirstLine(editor.getResource());
|
||||
}
|
||||
|
||||
if (!language) {
|
||||
// just use the extension
|
||||
language = path.extname(editor.getResource().toString()).slice(1); // remove the .
|
||||
}
|
||||
|
||||
if (!language) {
|
||||
const defaultInputCreator = languageAssociationRegistry.defaultAssociation;
|
||||
if (defaultInputCreator) {
|
||||
editor.setMode(defaultInputCreator[0]);
|
||||
const newInput = defaultInputCreator[1].convertInput(editor);
|
||||
if (newInput) {
|
||||
return { override: this.editorService.openEditor(newInput, options, group) };
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const inputCreator = languageAssociationRegistry.getAssociationForLanguage(language);
|
||||
if (inputCreator) {
|
||||
const newInput = inputCreator.convertInput(editor);
|
||||
if (newInput) {
|
||||
return { override: this.editorService.openEditor(newInput, options, group) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
dispose(this.editorOpeningListener);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { EditorReplacementContribution } from 'sql/workbench/contrib/editorReplacement/common/editorReplacerContribution';
|
||||
import { TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { IModeService, ILanguageSelection } from 'vs/editor/common/services/modeService';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IMode, LanguageId, LanguageIdentifier } from 'vs/editor/common/modes';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IOpenEditorOverrideHandler, IOpenEditorOverride, IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IDisposable, toDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { IEditorInput, EditorInput } from 'vs/workbench/common/editor';
|
||||
import { ITextEditorOptions, IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { QueryEditorLanguageAssociation } from 'sql/workbench/contrib/query/common/queryInputFactory';
|
||||
import { workbenchInstantiationService } from 'sql/workbench/test/workbenchTestServices';
|
||||
import { NotebookEditorInputAssociation } from 'sql/workbench/contrib/notebook/common/models/nodebookInputFactory';
|
||||
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledTextEditorInput';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/untitledQueryEditorInput';
|
||||
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { NotebookServiceStub } from 'sql/workbench/contrib/notebook/test/stubs';
|
||||
|
||||
const languageAssociations = Registry.as<ILanguageAssociationRegistry>(LanguageAssociationExtensions.LanguageAssociations);
|
||||
|
||||
suite('Editor Replacer Contribution', () => {
|
||||
let disposables: IDisposable[] = [];
|
||||
|
||||
setup(() => {
|
||||
disposables.push(languageAssociations.registerLanguageAssociation(QueryEditorLanguageAssociation.languages, QueryEditorLanguageAssociation, QueryEditorLanguageAssociation.isDefault));
|
||||
disposables.push(languageAssociations.registerLanguageAssociation(NotebookEditorInputAssociation.languages, NotebookEditorInputAssociation));
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
instantiationService.stub(INotebookService, new NotebookServiceStub());
|
||||
instantiationService.invokeFunction(accessor => {
|
||||
languageAssociations.start(accessor);
|
||||
});
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
disposables = dispose(disposables);
|
||||
});
|
||||
|
||||
test('does proper lifecycle', () => {
|
||||
const editorService = new MockEditorService();
|
||||
const modeService = new TestModeService();
|
||||
const contrib = new EditorReplacementContribution(editorService, modeService);
|
||||
assert.equal(editorService.overridenOpens.length, 1);
|
||||
contrib.dispose();
|
||||
assert.equal(editorService.overridenOpens.length, 0);
|
||||
});
|
||||
|
||||
test('does replace sql file input from uri (no mode service)', async () => {
|
||||
const editorService = new MockEditorService();
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
const contrib = instantiationService.createInstance(EditorReplacementContribution);
|
||||
const input = instantiationService.createInstance(FileEditorInput, URI.file('/test/file.sql'), undefined, undefined);
|
||||
const response = editorService.fireOpenEditor(input, undefined, undefined as IEditorGroup);
|
||||
assert(response?.override);
|
||||
const newinput = <any>(await response.override) as EditorInput; // our test service returns this so we are fine to cast this
|
||||
|
||||
assert(newinput instanceof QueryEditorInput);
|
||||
|
||||
contrib.dispose();
|
||||
});
|
||||
|
||||
test('does replace sql file input using input mode', async () => {
|
||||
const editorService = new MockEditorService();
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
const contrib = instantiationService.createInstance(EditorReplacementContribution);
|
||||
const input = instantiationService.createInstance(FileEditorInput, URI.file('/test/file.other'), undefined, 'sql');
|
||||
const response = editorService.fireOpenEditor(input, undefined, undefined as IEditorGroup);
|
||||
assert(response?.override);
|
||||
const newinput = <any>(await response.override) as EditorInput; // our test service returns this so we are fine to cast this
|
||||
|
||||
assert(newinput instanceof QueryEditorInput);
|
||||
|
||||
contrib.dispose();
|
||||
});
|
||||
|
||||
test('does replace notebook file input using input mode', async () => {
|
||||
const editorService = new MockEditorService();
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
const contrib = instantiationService.createInstance(EditorReplacementContribution);
|
||||
const input = instantiationService.createInstance(FileEditorInput, URI.file('/test/file.notebook'), undefined, undefined);
|
||||
const response = editorService.fireOpenEditor(input, undefined, undefined as IEditorGroup);
|
||||
assert(response?.override);
|
||||
const newinput = <any>(await response.override) as EditorInput; // our test service returns this so we are fine to cast this
|
||||
|
||||
assert(newinput instanceof NotebookInput);
|
||||
|
||||
contrib.dispose();
|
||||
});
|
||||
|
||||
test('does replace notebook file input using input mode', async () => {
|
||||
const editorService = new MockEditorService();
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
const contrib = instantiationService.createInstance(EditorReplacementContribution);
|
||||
const input = instantiationService.createInstance(FileEditorInput, URI.file('/test/file.iynb'), undefined, 'notebook');
|
||||
const response = editorService.fireOpenEditor(input, undefined, undefined as IEditorGroup);
|
||||
assert(response?.override);
|
||||
const newinput = <any>(await response.override) as EditorInput; // our test service returns this so we are fine to cast this
|
||||
|
||||
assert(newinput instanceof NotebookInput);
|
||||
|
||||
contrib.dispose();
|
||||
});
|
||||
|
||||
test('does replace notebook file input using input mode', async () => {
|
||||
const editorService = new MockEditorService();
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
const contrib = instantiationService.createInstance(EditorReplacementContribution);
|
||||
const input = instantiationService.createInstance(UntitledTextEditorInput, URI.file('/test/file'), false, undefined, undefined, undefined);
|
||||
const response = editorService.fireOpenEditor(input, undefined, undefined as IEditorGroup);
|
||||
assert(response?.override);
|
||||
const newinput = <any>(await response.override) as EditorInput; // our test service returns this so we are fine to cast this
|
||||
|
||||
assert(newinput instanceof QueryEditorInput);
|
||||
|
||||
contrib.dispose();
|
||||
});
|
||||
|
||||
test('does not replace editors that it shouldnt', async () => {
|
||||
const editorService = new MockEditorService();
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
const contrib = instantiationService.createInstance(EditorReplacementContribution);
|
||||
const untitled = instantiationService.createInstance(UntitledTextEditorInput, URI.file('/test/file'), false, undefined, undefined, undefined);
|
||||
const input = instantiationService.createInstance(UntitledQueryEditorInput, '', untitled, undefined);
|
||||
const response = editorService.fireOpenEditor(input, undefined, undefined as IEditorGroup);
|
||||
assert(response === undefined);
|
||||
|
||||
contrib.dispose();
|
||||
});
|
||||
|
||||
test('does not replace editors if it doesnt have a replacer', async () => {
|
||||
const editorService = new MockEditorService();
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
const contrib = instantiationService.createInstance(EditorReplacementContribution);
|
||||
const input = instantiationService.createInstance(UntitledTextEditorInput, URI.file('/test/file.unknown'), false, undefined, undefined, undefined);
|
||||
const response = editorService.fireOpenEditor(input, undefined, undefined as IEditorGroup);
|
||||
assert(response === undefined);
|
||||
|
||||
contrib.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
class MockEditorService extends TestEditorService {
|
||||
readonly overridenOpens: IOpenEditorOverrideHandler[] = [];
|
||||
|
||||
overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable {
|
||||
this.overridenOpens.push(_handler);
|
||||
return toDisposable(() => {
|
||||
const index = this.overridenOpens.findIndex(v => v === _handler);
|
||||
if (!isUndefinedOrNull(index)) {
|
||||
this.overridenOpens.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fireOpenEditor(editor: IEditorInput, options: IEditorOptions | ITextEditorOptions | undefined, group: IEditorGroup) {
|
||||
for (const handler of this.overridenOpens) {
|
||||
let response: IOpenEditorOverride | undefined;
|
||||
if (response = handler(editor, options, group)) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
openEditor(_editor: any, _options?: any, _group?: any): Promise<any> {
|
||||
return Promise.resolve(_editor);
|
||||
}
|
||||
}
|
||||
|
||||
class TestModeService implements IModeService {
|
||||
_serviceBrand: undefined;
|
||||
onDidCreateMode: Event<IMode>;
|
||||
|
||||
isRegisteredMode(mimetypeOrModeId: string): boolean {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getRegisteredModes(): string[] {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getRegisteredLanguageNames(): string[] {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getExtensions(alias: string): string[] {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getFilenames(alias: string): string[] {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getMimeForMode(modeId: string): string {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getLanguageName(modeId: string): string {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getModeIdForLanguageName(alias: string): string {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getModeIdByFilepathOrFirstLine(resource: URI, firstLine?: string): string {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getModeId(commaSeparatedMimetypesOrCommaSeparatedIds: string): string {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getLanguageIdentifier(modeId: string | LanguageId): LanguageIdentifier {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getConfigurationFiles(modeId: string): URI[] {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
create(commaSeparatedMimetypesOrCommaSeparatedIds: string): ILanguageSelection {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
createByLanguageName(languageName: string): ILanguageSelection {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
createByFilepathOrFirstLine(rsource: URI, firstLine?: string): ILanguageSelection {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
triggerMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import DivContainer from 'sql/workbench/browser/modelComponents/divContainer.component';
|
||||
import FlexContainer from 'sql/workbench/browser/modelComponents/flexContainer.component';
|
||||
import FormContainer from 'sql/workbench/browser/modelComponents/formContainer.component';
|
||||
import ToolbarContainer from 'sql/workbench/browser/modelComponents/toolbarContainer.component';
|
||||
import GroupContainer from 'sql/workbench/browser/modelComponents/groupContainer.component';
|
||||
import CardComponent from 'sql/workbench/browser/modelComponents/card.component';
|
||||
import InputBoxComponent from 'sql/workbench/browser/modelComponents/inputbox.component';
|
||||
import DropDownComponent from 'sql/workbench/browser/modelComponents/dropdown.component';
|
||||
import DeclarativeTableComponent from 'sql/workbench/browser/modelComponents/declarativeTable.component';
|
||||
import ListBoxComponent from 'sql/workbench/browser/modelComponents/listbox.component';
|
||||
import ButtonComponent from 'sql/workbench/browser/modelComponents/button.component';
|
||||
import CheckBoxComponent from 'sql/workbench/browser/modelComponents/checkbox.component';
|
||||
import TreeComponent from 'sql/workbench/browser/modelComponents/tree.component';
|
||||
import RadioButtonComponent from 'sql/workbench/browser/modelComponents/radioButton.component';
|
||||
import WebViewComponent from 'sql/workbench/contrib/modelView/browser/webview.component';
|
||||
import TableComponent from 'sql/workbench/browser/modelComponents/table.component';
|
||||
import TextComponent from 'sql/workbench/browser/modelComponents/text.component';
|
||||
import ImageComponent from 'sql/workbench/browser/modelComponents/image.component';
|
||||
import LoadingComponent from 'sql/workbench/browser/modelComponents/loadingComponent.component';
|
||||
import FileBrowserTreeComponent from 'sql/workbench/browser/modelComponents/fileBrowserTree.component';
|
||||
import EditorComponent from 'sql/workbench/browser/modelComponents/editor.component';
|
||||
import DiffEditorComponent from 'sql/workbench/browser/modelComponents/diffeditor.component';
|
||||
import DomComponent from 'sql/workbench/browser/modelComponents/dom.component';
|
||||
import { registerComponentType } from 'sql/platform/dashboard/browser/modelComponentRegistry';
|
||||
import HyperlinkComponent from 'sql/workbench/browser/modelComponents/hyperlink.component';
|
||||
import SplitViewContainer from 'sql/workbench/browser/modelComponents/splitviewContainer.component';
|
||||
import RadioCardGroup from 'sql/workbench/browser/modelComponents/radioCardGroup.component';
|
||||
import { ModelComponentTypes } from 'sql/platform/dashboard/browser/interfaces';
|
||||
|
||||
export const DIV_CONTAINER = 'div-container';
|
||||
registerComponentType(DIV_CONTAINER, ModelComponentTypes.DivContainer, DivContainer);
|
||||
|
||||
export const FLEX_CONTAINER = 'flex-container';
|
||||
registerComponentType(FLEX_CONTAINER, ModelComponentTypes.FlexContainer, FlexContainer);
|
||||
|
||||
export const SPLITVIEW_CONTAINER = 'splitView-container';
|
||||
registerComponentType(SPLITVIEW_CONTAINER, ModelComponentTypes.SplitViewContainer, SplitViewContainer);
|
||||
|
||||
export const FORM_CONTAINER = 'form-container';
|
||||
registerComponentType(FORM_CONTAINER, ModelComponentTypes.Form, FormContainer);
|
||||
|
||||
export const TOOLBAR_CONTAINER = 'toolbar-container';
|
||||
registerComponentType(TOOLBAR_CONTAINER, ModelComponentTypes.Toolbar, ToolbarContainer);
|
||||
|
||||
export const GROUP_CONTAINER = 'group-container';
|
||||
registerComponentType(GROUP_CONTAINER, ModelComponentTypes.Group, GroupContainer);
|
||||
|
||||
export const CARD_COMPONENT = 'card-component';
|
||||
registerComponentType(CARD_COMPONENT, ModelComponentTypes.Card, CardComponent);
|
||||
|
||||
export const INPUTBOX_COMPONENT = 'inputbox-component';
|
||||
registerComponentType(INPUTBOX_COMPONENT, ModelComponentTypes.InputBox, InputBoxComponent);
|
||||
|
||||
export const DROPDOWN_COMPONENT = 'dropdown-component';
|
||||
registerComponentType(DROPDOWN_COMPONENT, ModelComponentTypes.DropDown, DropDownComponent);
|
||||
|
||||
export const DECLARATIVETABLE_COMPONENT = 'declarativeTable-component';
|
||||
registerComponentType(DECLARATIVETABLE_COMPONENT, ModelComponentTypes.DeclarativeTable, DeclarativeTableComponent);
|
||||
|
||||
export const LISTBOX_COMPONENT = 'lisbox-component';
|
||||
registerComponentType(LISTBOX_COMPONENT, ModelComponentTypes.ListBox, ListBoxComponent);
|
||||
|
||||
export const BUTTON_COMPONENT = 'button-component';
|
||||
registerComponentType(BUTTON_COMPONENT, ModelComponentTypes.Button, ButtonComponent);
|
||||
|
||||
|
||||
export const CHECKBOX_COMPONENT = 'checkbox-component';
|
||||
registerComponentType(CHECKBOX_COMPONENT, ModelComponentTypes.CheckBox, CheckBoxComponent);
|
||||
|
||||
export const RADIOBUTTON_COMPONENT = 'radiobutton-component';
|
||||
registerComponentType(RADIOBUTTON_COMPONENT, ModelComponentTypes.RadioButton, RadioButtonComponent);
|
||||
|
||||
export const WEBVIEW_COMPONENT = 'webview-component';
|
||||
registerComponentType(WEBVIEW_COMPONENT, ModelComponentTypes.WebView, WebViewComponent);
|
||||
|
||||
export const TEXT_COMPONENT = 'text-component';
|
||||
registerComponentType(TEXT_COMPONENT, ModelComponentTypes.Text, TextComponent);
|
||||
|
||||
export const IMAGE_COMPONENT = 'image-component';
|
||||
registerComponentType(IMAGE_COMPONENT, ModelComponentTypes.Image, ImageComponent);
|
||||
|
||||
export const TABLE_COMPONENT = 'table-component';
|
||||
registerComponentType(TABLE_COMPONENT, ModelComponentTypes.Table, TableComponent);
|
||||
|
||||
export const LOADING_COMPONENT = 'loading-component';
|
||||
registerComponentType(LOADING_COMPONENT, ModelComponentTypes.LoadingComponent, LoadingComponent);
|
||||
|
||||
export const TREE_COMPONENT = 'tree-component';
|
||||
registerComponentType(TREE_COMPONENT, ModelComponentTypes.TreeComponent, TreeComponent);
|
||||
|
||||
export const FILEBROWSERTREE_COMPONENT = 'filebrowsertree-component';
|
||||
registerComponentType(FILEBROWSERTREE_COMPONENT, ModelComponentTypes.FileBrowserTree, FileBrowserTreeComponent);
|
||||
|
||||
export const EDITOR_COMPONENT = 'editor-component';
|
||||
registerComponentType(EDITOR_COMPONENT, ModelComponentTypes.Editor, EditorComponent);
|
||||
|
||||
export const DIFF_EDITOR_COMPONENT = 'diff-editor-component';
|
||||
registerComponentType(DIFF_EDITOR_COMPONENT, ModelComponentTypes.DiffEditor, DiffEditorComponent);
|
||||
|
||||
export const DOM_COMPONENT = 'dom-component';
|
||||
registerComponentType(DOM_COMPONENT, ModelComponentTypes.Dom, DomComponent);
|
||||
|
||||
export const HYPERLINK_COMPONENT = 'hyperlink-component';
|
||||
registerComponentType(HYPERLINK_COMPONENT, ModelComponentTypes.Hyperlink, HyperlinkComponent);
|
||||
|
||||
export const RADIOCARDGROUP_COMPONENT = 'radiocardgroup-component';
|
||||
registerComponentType(RADIOCARDGROUP_COMPONENT, ModelComponentTypes.RadioCardGroup, RadioCardGroup);
|
||||
@@ -3,11 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Directive, ViewContainerRef, Inject, forwardRef } from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[component-host]',
|
||||
})
|
||||
export class ComponentHostDirective {
|
||||
constructor(@Inject(forwardRef(() => ViewContainerRef)) public viewContainerRef: ViewContainerRef) { }
|
||||
}
|
||||
modelview-webview-component {
|
||||
height: 100%;
|
||||
width : 100%;
|
||||
display: block;
|
||||
}
|
||||
221
src/sql/workbench/contrib/modelView/browser/webview.component.ts
Normal file
221
src/sql/workbench/contrib/modelView/browser/webview.component.ts
Normal file
@@ -0,0 +1,221 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import 'vs/css!./media/webview';
|
||||
import {
|
||||
Component, Input, Inject, ChangeDetectorRef, forwardRef, ElementRef, OnDestroy
|
||||
} from '@angular/core';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { addDisposableListener, EventType } from 'vs/base/browser/dom';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { WebviewContentOptions, IWebviewService, WebviewElement } from 'vs/workbench/contrib/webview/browser/webview';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
|
||||
import { ComponentBase } from 'sql/workbench/browser/modelComponents/componentBase';
|
||||
import { ComponentEventType, IModelStore, IComponentDescriptor, IComponent } from 'sql/platform/dashboard/browser/interfaces';
|
||||
|
||||
function reviveWebviewOptions(options: vscode.WebviewOptions): vscode.WebviewOptions {
|
||||
return {
|
||||
...options,
|
||||
localResourceRoots: Array.isArray(options.localResourceRoots) ? options.localResourceRoots.map(URI.revive) : undefined
|
||||
};
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '',
|
||||
selector: 'modelview-webview-component'
|
||||
})
|
||||
export default class WebViewComponent extends ComponentBase implements IComponent, OnDestroy {
|
||||
@Input() descriptor: IComponentDescriptor;
|
||||
@Input() modelStore: IModelStore;
|
||||
|
||||
private static readonly standardSupportedLinkSchemes = ['http', 'https', 'mailto'];
|
||||
|
||||
private _webview: WebviewElement;
|
||||
private _renderedHtml: string;
|
||||
private _extensionLocationUri: URI;
|
||||
private _ready: Promise<void>;
|
||||
|
||||
protected contextKey: IContextKey<boolean>;
|
||||
protected findInputFocusContextKey: IContextKey<boolean>;
|
||||
|
||||
private readonly id = generateUuid();
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => ElementRef)) el: ElementRef,
|
||||
@Inject(IOpenerService) private readonly _openerService: IOpenerService,
|
||||
@Inject(IWorkspaceContextService) private readonly _contextService: IWorkspaceContextService,
|
||||
@Inject(IWebviewService) private readonly webviewService: IWebviewService
|
||||
) {
|
||||
super(changeRef, el);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.baseInit();
|
||||
this._createWebview();
|
||||
this._register(addDisposableListener(window, EventType.RESIZE, e => {
|
||||
this.layout();
|
||||
}));
|
||||
}
|
||||
|
||||
private _createWebview(): void {
|
||||
this._webview = this.webviewService.createWebview(this.id,
|
||||
{},
|
||||
{
|
||||
allowScripts: true
|
||||
});
|
||||
|
||||
this._webview.mountTo(this._el.nativeElement);
|
||||
|
||||
this._ready = new Promise(resolve => {
|
||||
let webview = (<any>this._webview)._webview;
|
||||
const subscription = this._register(addDisposableListener(webview, 'ipc-message', (event) => {
|
||||
if (event.channel === 'webview-ready') {
|
||||
subscription.dispose();
|
||||
resolve();
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
this._ready.then(() => {
|
||||
this._register(this._webview.onDidClickLink(link => this.onDidClickLink(URI.parse(link))));
|
||||
|
||||
this._register(this._webview.onMessage(e => {
|
||||
this.fireEvent({
|
||||
eventType: ComponentEventType.onMessage,
|
||||
args: e
|
||||
});
|
||||
}));
|
||||
|
||||
this.setHtml();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.baseDestroy();
|
||||
}
|
||||
|
||||
/// Webview Functions
|
||||
|
||||
private setHtml(): void {
|
||||
if (this._webview && this.html) {
|
||||
this._renderedHtml = this.html;
|
||||
this._webview.html = this._renderedHtml;
|
||||
}
|
||||
}
|
||||
|
||||
private sendMessage(): void {
|
||||
if (this._webview && this.message) {
|
||||
this._webview.sendMessage(this.message);
|
||||
}
|
||||
}
|
||||
|
||||
private onDidClickLink(link: URI): any {
|
||||
if (!link) {
|
||||
return;
|
||||
}
|
||||
if (WebViewComponent.standardSupportedLinkSchemes.indexOf(link.scheme) >= 0 || this.enableCommandUris && link.scheme === 'command') {
|
||||
this._openerService.open(link);
|
||||
}
|
||||
}
|
||||
|
||||
private get enableCommandUris(): boolean {
|
||||
if (this.options && this.options.enableCommandUris) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// IComponent implementation
|
||||
|
||||
public layout(): void {
|
||||
if (this._ready) {
|
||||
this._ready.then(() => {
|
||||
let element = <HTMLElement>this._el.nativeElement;
|
||||
element.style.position = this.position;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public setLayout(layout: any): void {
|
||||
// TODO allow configuring the look and feel
|
||||
this.layout();
|
||||
}
|
||||
|
||||
public setProperties(properties: { [key: string]: any; }): void {
|
||||
if (this._ready) {
|
||||
this._ready.then(() => {
|
||||
super.setProperties(properties);
|
||||
if (this.options) {
|
||||
this._webview.contentOptions = this.getExtendedOptions();
|
||||
}
|
||||
if (this.html !== this._renderedHtml) {
|
||||
this.setHtml();
|
||||
}
|
||||
if (this.extensionLocation) {
|
||||
this._extensionLocationUri = URI.revive(this.extensionLocation);
|
||||
}
|
||||
this.sendMessage();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// CSS-bound properties
|
||||
|
||||
public get message(): any {
|
||||
return this.getPropertyOrDefault<azdata.WebViewProperties, any>((props) => props.message, undefined);
|
||||
}
|
||||
|
||||
public set message(newValue: any) {
|
||||
this.setPropertyFromUI<azdata.WebViewProperties, any>((properties, message) => { properties.message = message; }, newValue);
|
||||
}
|
||||
|
||||
public get html(): string {
|
||||
return this.getPropertyOrDefault<azdata.WebViewProperties, string>((props) => props.html, undefined);
|
||||
}
|
||||
|
||||
public set html(newValue: string) {
|
||||
this.setPropertyFromUI<azdata.WebViewProperties, string>((properties, html) => { properties.html = html; }, newValue);
|
||||
}
|
||||
|
||||
public get options(): vscode.WebviewOptions {
|
||||
return this.getPropertyOrDefault<azdata.WebViewProperties, vscode.WebviewOptions>((props) => props.options, undefined);
|
||||
}
|
||||
|
||||
public get extensionLocation(): UriComponents {
|
||||
return this.getPropertyOrDefault<azdata.WebViewProperties, UriComponents>((props) => props.extensionLocation, undefined);
|
||||
}
|
||||
|
||||
private get extensionLocationUri(): URI {
|
||||
if (!this._extensionLocationUri && this.extensionLocation) {
|
||||
this._extensionLocationUri = URI.revive(this.extensionLocation);
|
||||
}
|
||||
return this._extensionLocationUri;
|
||||
}
|
||||
|
||||
private getExtendedOptions(): WebviewContentOptions {
|
||||
let options = this.options || { enableScripts: true };
|
||||
options = reviveWebviewOptions(options);
|
||||
return {
|
||||
allowScripts: options.enableScripts,
|
||||
localResourceRoots: options.localResourceRoots || this.getDefaultLocalResourceRoots()
|
||||
};
|
||||
}
|
||||
|
||||
private getDefaultLocalResourceRoots(): URI[] {
|
||||
const rootPaths = this._contextService.getWorkspace().folders.map(x => x.uri);
|
||||
if (this.extensionLocationUri) {
|
||||
rootPaths.push(this.extensionLocationUri);
|
||||
}
|
||||
return rootPaths;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { ICellModel } from 'sql/workbench/contrib/notebook/browser/models/modelI
|
||||
import * as outputProcessor from 'sql/workbench/contrib/notebook/browser/models/outputProcessor';
|
||||
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { ComponentHostDirective } from 'sql/workbench/contrib/dashboard/browser/core/componentHost.directive';
|
||||
import { ComponentHostDirective } from 'sql/base/browser/componentHost.directive';
|
||||
import { Extensions, IMimeComponent, IMimeComponentRegistry } from 'sql/workbench/contrib/notebook/browser/outputs/mimeRegistry';
|
||||
import * as colors from 'vs/platform/theme/common/colorRegistry';
|
||||
import * as themeColors from 'vs/workbench/common/theme';
|
||||
|
||||
@@ -23,9 +23,9 @@ import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import { firstIndex, find } from 'vs/base/common/arrays';
|
||||
let modelId = 0;
|
||||
import { HideInputTag } from 'sql/platform/notebooks/common/outputRegistry';
|
||||
|
||||
export const HideInputTag = 'hide_input';
|
||||
let modelId = 0;
|
||||
|
||||
export class CellModel implements ICellModel {
|
||||
public id: string;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { localize } from 'vs/nls';
|
||||
import { IEditorInputFactoryRegistry, Extensions as EditorInputFactoryExtensions } from 'vs/workbench/common/editor';
|
||||
|
||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/common/languageAssociation';
|
||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { UntitledNotebookInput } from 'sql/workbench/contrib/notebook/common/models/untitledNotebookInput';
|
||||
import { FileNotebookInput } from 'sql/workbench/contrib/notebook/common/models/fileNotebookInput';
|
||||
import { FileNoteBookEditorInputFactory, UntitledNoteBookEditorInputFactory, NotebookEditorInputAssociation } from 'sql/workbench/contrib/notebook/common/models/nodebookInputFactory';
|
||||
@@ -28,8 +28,8 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { NodeContextKey } from 'sql/workbench/contrib/dataExplorer/browser/nodeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
import { NodeContextKey } from 'sql/workbench/browser/parts/views/nodeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { FormsModule } from '@angular/forms';
|
||||
import { CommonModule, APP_BASE_HREF } from '@angular/common';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { ComponentHostDirective } from 'sql/workbench/contrib/dashboard/browser/core/componentHost.directive';
|
||||
import { ComponentHostDirective } from 'sql/base/browser/componentHost.directive';
|
||||
import { providerIterator } from 'sql/workbench/services/bootstrap/browser/bootstrapService';
|
||||
import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service';
|
||||
import { EditableDropDown } from 'sql/platform/browser/editableDropdown/editableDropdown.component';
|
||||
|
||||
@@ -11,7 +11,7 @@ import { FileNotebookInput } from 'sql/workbench/contrib/notebook/common/models/
|
||||
import { UntitledNotebookInput } from 'sql/workbench/contrib/notebook/common/models/untitledNotebookInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledTextEditorInput';
|
||||
import { ILanguageAssociation } from 'sql/workbench/common/languageAssociation';
|
||||
import { ILanguageAssociation } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||
|
||||
const editorInputFactoryRegistry = Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories);
|
||||
|
||||
@@ -1,229 +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 * as azdata from 'azdata';
|
||||
import { TreeNode } from 'sql/workbench/contrib/objectExplorer/common/treeNode';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ITreeItem } from 'sql/workbench/common/views';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { hash } from 'vs/base/common/hash';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TreeItemCollapsibleState } from 'vs/workbench/common/views';
|
||||
import { localize } from 'vs/nls';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { UserCancelledConnectionError } from 'sql/base/common/errors';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
export const SERVICE_ID = 'oeShimService';
|
||||
export const IOEShimService = createDecorator<IOEShimService>(SERVICE_ID);
|
||||
|
||||
export interface IOEShimService {
|
||||
_serviceBrand: undefined;
|
||||
getChildren(node: ITreeItem, viewId: string): Promise<ITreeItem[]>;
|
||||
disconnectNode(viewId: string, node: ITreeItem): Promise<boolean>;
|
||||
providerExists(providerId: string): boolean;
|
||||
isNodeConnected(viewId: string, node: ITreeItem): boolean;
|
||||
getNodeInfoForTreeItem(treeItem: ITreeItem): azdata.NodeInfo;
|
||||
}
|
||||
|
||||
export class OEShimService extends Disposable implements IOEShimService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private sessionMap = new Map<number, string>();
|
||||
private nodeHandleMap = new Map<number, string>();
|
||||
private nodeInfoMap = new Map<ITreeItem, azdata.NodeInfo>();
|
||||
|
||||
constructor(
|
||||
@IObjectExplorerService private oe: IObjectExplorerService,
|
||||
@IConnectionManagementService private cm: IConnectionManagementService,
|
||||
@ICapabilitiesService private capabilities: ICapabilitiesService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
private async createSession(viewId: string, providerId: string, node: ITreeItem): Promise<string> {
|
||||
let connProfile = new ConnectionProfile(this.capabilities, node.payload);
|
||||
connProfile.saveProfile = false;
|
||||
if (this.cm.providerRegistered(providerId)) {
|
||||
connProfile = await this.connectOrPrompt(connProfile);
|
||||
} else {
|
||||
// Throw and expect upstream handler to notify about the error
|
||||
// TODO: In the future should use extension recommendations to prompt for correct extension
|
||||
throw new Error(localize('noProviderFound', "Cannot expand as the required connection provider '{0}' was not found", providerId));
|
||||
}
|
||||
let sessionResp = await this.oe.createNewSession(providerId, connProfile);
|
||||
let sessionId = sessionResp.sessionId;
|
||||
await new Promise((resolve, reject) => {
|
||||
let listener = this.oe.onUpdateObjectExplorerNodes(e => {
|
||||
if (e.connection.id === connProfile.id) {
|
||||
if (e.errorMessage) {
|
||||
listener.dispose();
|
||||
reject(new Error(e.errorMessage));
|
||||
return;
|
||||
}
|
||||
let rootNode = this.oe.getSession(sessionResp.sessionId).rootNode;
|
||||
// this is how we know it was shimmed
|
||||
if (rootNode.nodePath) {
|
||||
this.nodeHandleMap.set(generateNodeMapKey(viewId, node), rootNode.nodePath);
|
||||
}
|
||||
}
|
||||
listener.dispose();
|
||||
resolve(sessionResp.sessionId);
|
||||
});
|
||||
});
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
private async connectOrPrompt(connProfile: ConnectionProfile): Promise<ConnectionProfile> {
|
||||
connProfile = await new Promise(async (resolve, reject) => {
|
||||
let result = await this.cm.connect(connProfile, undefined, { showConnectionDialogOnError: true, showFirewallRuleOnError: true, saveTheConnection: false, showDashboard: false, params: undefined }, {
|
||||
onConnectSuccess: async (e, profile) => {
|
||||
let existingConnection = this.cm.findExistingConnection(profile);
|
||||
connProfile = new ConnectionProfile(this.capabilities, existingConnection);
|
||||
connProfile = <ConnectionProfile>await this.cm.addSavedPassword(connProfile);
|
||||
resolve(connProfile);
|
||||
},
|
||||
onConnectCanceled: () => {
|
||||
reject(new UserCancelledConnectionError(localize('loginCanceled', "User canceled")));
|
||||
},
|
||||
onConnectReject: undefined,
|
||||
onConnectStart: undefined,
|
||||
onDisconnect: undefined
|
||||
});
|
||||
// connection cancelled from firewall dialog
|
||||
if (!result) {
|
||||
reject(new UserCancelledConnectionError(localize('firewallCanceled', "Firewall dialog canceled")));
|
||||
}
|
||||
});
|
||||
return connProfile;
|
||||
}
|
||||
|
||||
public async disconnectNode(viewId: string, node: ITreeItem): Promise<boolean> {
|
||||
// we assume only nodes with payloads can be connected
|
||||
// check to make sure we have an existing connection
|
||||
let key = generateSessionMapKey(viewId, node);
|
||||
let session = this.sessionMap.get(key);
|
||||
if (session) {
|
||||
let closed = (await this.oe.closeSession(node.childProvider, this.oe.getSession(session))).success;
|
||||
if (closed) {
|
||||
this.sessionMap.delete(key);
|
||||
}
|
||||
return closed;
|
||||
}
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
private async getOrCreateSession(viewId: string, node: ITreeItem): Promise<string> {
|
||||
// verify the map is correct
|
||||
let key = generateSessionMapKey(viewId, node);
|
||||
if (!this.sessionMap.has(key)) {
|
||||
this.sessionMap.set(key, await this.createSession(viewId, node.childProvider, node));
|
||||
}
|
||||
return this.sessionMap.get(key);
|
||||
}
|
||||
|
||||
public async getChildren(node: ITreeItem, viewId: string): Promise<ITreeItem[]> {
|
||||
if (node.payload) {
|
||||
let sessionId = await this.getOrCreateSession(viewId, node);
|
||||
let requestHandle = this.nodeHandleMap.get(generateNodeMapKey(viewId, node)) || node.handle;
|
||||
let treeNode = new TreeNode(undefined, undefined, undefined, requestHandle, undefined, undefined, undefined, undefined, undefined, undefined);
|
||||
treeNode.connection = new ConnectionProfile(this.capabilities, node.payload);
|
||||
return this.oe.resolveTreeNodeChildren({
|
||||
success: undefined,
|
||||
sessionId,
|
||||
rootNode: undefined,
|
||||
errorMessage: undefined
|
||||
}, treeNode).then(e => e.map(n => this.treeNodeToITreeItem(viewId, n, node)));
|
||||
} else {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
}
|
||||
|
||||
private treeNodeToITreeItem(viewId: string, node: TreeNode, parentNode: ITreeItem): ITreeItem {
|
||||
let handle = generateUuid();
|
||||
let icon: string = '';
|
||||
let nodePath = node.nodePath;
|
||||
if (node.iconType) {
|
||||
icon = (typeof node.iconType === 'string') ? node.iconType : node.iconType.id;
|
||||
} else {
|
||||
icon = node.nodeTypeId;
|
||||
if (node.nodeStatus) {
|
||||
icon = node.nodeTypeId + '_' + node.nodeStatus;
|
||||
}
|
||||
if (node.nodeSubType) {
|
||||
icon = node.nodeTypeId + '_' + node.nodeSubType;
|
||||
}
|
||||
}
|
||||
icon = icon.toLowerCase();
|
||||
// Change the database if the node has a different database
|
||||
// than its parent
|
||||
let databaseChanged = false;
|
||||
let updatedPayload: azdata.IConnectionProfile | any = {};
|
||||
if (node.nodeTypeId === NodeType.Database) {
|
||||
const database = node.getDatabaseName();
|
||||
if (database) {
|
||||
databaseChanged = true;
|
||||
updatedPayload = assign(updatedPayload, parentNode.payload);
|
||||
updatedPayload.databaseName = node.getDatabaseName();
|
||||
}
|
||||
}
|
||||
const nodeInfo: azdata.NodeInfo = {
|
||||
nodePath: nodePath,
|
||||
nodeType: node.nodeTypeId,
|
||||
nodeSubType: node.nodeSubType,
|
||||
nodeStatus: node.nodeStatus,
|
||||
label: node.label,
|
||||
isLeaf: node.isAlwaysLeaf,
|
||||
metadata: node.metadata,
|
||||
errorMessage: node.errorStateMessage,
|
||||
iconType: icon,
|
||||
childProvider: node.childProvider || parentNode.childProvider,
|
||||
payload: node.payload || (databaseChanged ? updatedPayload : parentNode.payload)
|
||||
};
|
||||
let newTreeItem: ITreeItem = {
|
||||
parentHandle: node.parent.id,
|
||||
handle,
|
||||
collapsibleState: node.isAlwaysLeaf ? TreeItemCollapsibleState.None : TreeItemCollapsibleState.Collapsed,
|
||||
label: {
|
||||
label: node.label
|
||||
},
|
||||
childProvider: node.childProvider || parentNode.childProvider,
|
||||
providerHandle: parentNode.childProvider,
|
||||
payload: node.payload || (databaseChanged ? updatedPayload : parentNode.payload),
|
||||
contextValue: node.nodeTypeId,
|
||||
sqlIcon: icon
|
||||
};
|
||||
this.nodeHandleMap.set(generateNodeMapKey(viewId, newTreeItem), nodePath);
|
||||
this.nodeInfoMap.set(newTreeItem, nodeInfo);
|
||||
return newTreeItem;
|
||||
}
|
||||
|
||||
public providerExists(providerId: string): boolean {
|
||||
return this.oe.providerRegistered(providerId);
|
||||
}
|
||||
|
||||
public isNodeConnected(viewId: string, node: ITreeItem): boolean {
|
||||
return this.sessionMap.has(generateSessionMapKey(viewId, node));
|
||||
}
|
||||
|
||||
public getNodeInfoForTreeItem(treeItem: ITreeItem): azdata.NodeInfo {
|
||||
if (this.nodeInfoMap.has(treeItem)) {
|
||||
return this.nodeInfoMap.get(treeItem);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function generateSessionMapKey(viewId: string, node: ITreeItem): number {
|
||||
return hash([viewId, node.childProvider, node.payload]);
|
||||
}
|
||||
|
||||
function generateNodeMapKey(viewId: string, node: ITreeItem): number {
|
||||
return hash([viewId, node.handle]);
|
||||
}
|
||||
@@ -14,13 +14,13 @@ import {
|
||||
DeleteConnectionAction, RefreshAction, EditServerGroupAction
|
||||
} from 'sql/workbench/contrib/objectExplorer/browser/connectionTreeAction';
|
||||
import { TreeNode } from 'sql/workbench/contrib/objectExplorer/common/treeNode';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { TreeUpdateUtils } from 'sql/workbench/contrib/objectExplorer/browser/treeUpdateUtils';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { MenuId, IMenuService } from 'vs/platform/actions/common/actions';
|
||||
import { ConnectionContextKey } from 'sql/workbench/contrib/connection/common/connectionContextKey';
|
||||
import { ConnectionContextKey } from 'sql/workbench/services/connection/common/connectionContextKey';
|
||||
import { TreeNodeContextKey } from 'sql/workbench/contrib/objectExplorer/common/treeNodeContextKey';
|
||||
import { IQueryManagementService } from 'sql/workbench/services/query/common/queryManagement';
|
||||
import { ServerInfoContextKey } from 'sql/workbench/contrib/connection/common/serverInfoContextKey';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { IConnectionManagementService, IConnectionCompletionOptions, IConnection
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
|
||||
import { TreeNode } from 'sql/workbench/contrib/objectExplorer/common/treeNode';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
|
||||
@@ -1,104 +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 NodeType {
|
||||
public static Folder = 'Folder';
|
||||
public static Root = 'root';
|
||||
public static Database = 'Database';
|
||||
public static Server = 'Server';
|
||||
public static ScalarValuedFunction = 'ScalarValuedFunction';
|
||||
public static TableValuedFunction = 'TableValuedFunction';
|
||||
public static AggregateFunction = 'AggregateFunction';
|
||||
public static FileGroup = 'FileGroup';
|
||||
public static StoredProcedure = 'StoredProcedure';
|
||||
public static UserDefinedTableType = 'UserDefinedTableType';
|
||||
public static View = 'View';
|
||||
public static Table = 'Table';
|
||||
public static HistoryTable = 'HistoryTable';
|
||||
public static ServerLevelLinkedServerLogin = 'ServerLevelLinkedServerLogin';
|
||||
public static ServerLevelServerAudit = 'ServerLevelServerAudit';
|
||||
public static ServerLevelCryptographicProvider = 'ServerLevelCryptographicProvider';
|
||||
public static ServerLevelCredential = 'ServerLevelCredential';
|
||||
public static ServerLevelServerRole = 'ServerLevelServerRole';
|
||||
public static ServerLevelLogin = 'ServerLevelLogin';
|
||||
public static ServerLevelServerAuditSpecification = 'ServerLevelServerAuditSpecification';
|
||||
public static ServerLevelServerTrigger = 'ServerLevelServerTrigger';
|
||||
public static ServerLevelLinkedServer = 'ServerLevelLinkedServer';
|
||||
public static ServerLevelEndpoint = 'ServerLevelEndpoint';
|
||||
public static Synonym = 'Synonym';
|
||||
public static DatabaseTrigger = 'DatabaseTrigger';
|
||||
public static Assembly = 'Assembly';
|
||||
public static MessageType = 'MessageType';
|
||||
public static Contract = 'Contract';
|
||||
public static Queue = 'Queue';
|
||||
public static Service = 'Service';
|
||||
public static Route = 'Route';
|
||||
public static DatabaseAndQueueEventNotification = 'DatabaseAndQueueEventNotification';
|
||||
public static RemoteServiceBinding = 'RemoteServiceBinding';
|
||||
public static BrokerPriority = 'BrokerPriority';
|
||||
public static FullTextCatalog = 'FullTextCatalog';
|
||||
public static FullTextStopList = 'FullTextStopList';
|
||||
public static SqlLogFile = 'SqlLogFile';
|
||||
public static PartitionFunction = 'PartitionFunction';
|
||||
public static PartitionScheme = 'PartitionScheme';
|
||||
public static SearchPropertyList = 'SearchPropertyList';
|
||||
public static User = 'User';
|
||||
public static Schema = 'Schema';
|
||||
public static AsymmetricKey = 'AsymmetricKey';
|
||||
public static Certificate = 'Certificate';
|
||||
public static SymmetricKey = 'SymmetricKey';
|
||||
public static DatabaseEncryptionKey = 'DatabaseEncryptionKey';
|
||||
public static MasterKey = 'MasterKey';
|
||||
public static DatabaseAuditSpecification = 'DatabaseAuditSpecification';
|
||||
public static Column = 'Column';
|
||||
public static Key = 'Key';
|
||||
public static Constraint = 'Constraint';
|
||||
public static Trigger = 'Trigger';
|
||||
public static Index = 'Index';
|
||||
public static Statistic = 'Statistic';
|
||||
public static UserDefinedDataType = 'UserDefinedDataType';
|
||||
public static UserDefinedType = 'UserDefinedType';
|
||||
public static XmlSchemaCollection = 'XmlSchemaCollection';
|
||||
public static SystemExactNumeric = 'SystemExactNumeric';
|
||||
public static SystemApproximateNumeric = 'SystemApproximateNumeric';
|
||||
public static SystemDateAndTime = 'SystemDateAndTime';
|
||||
public static SystemCharacterString = 'SystemCharacterString';
|
||||
public static SystemUnicodeCharacterString = 'SystemUnicodeCharacterString';
|
||||
public static SystemBinaryString = 'SystemBinaryString';
|
||||
public static SystemOtherDataType = 'SystemOtherDataType';
|
||||
public static SystemClrDataType = 'SystemClrDataType';
|
||||
public static SystemSpatialDataType = 'SystemSpatialDataType';
|
||||
public static UserDefinedTableTypeColumn = 'UserDefinedTableTypeColumn';
|
||||
public static UserDefinedTableTypeKey = 'UserDefinedTableTypeKey';
|
||||
public static UserDefinedTableTypeConstraint = 'UserDefinedTableTypeConstraint';
|
||||
public static StoredProcedureParameter = 'StoredProcedureParameter';
|
||||
public static TableValuedFunctionParameter = 'TableValuedFunctionParameter';
|
||||
public static ScalarValuedFunctionParameter = 'ScalarValuedFunctionParameter';
|
||||
public static AggregateFunctionParameter = 'AggregateFunctionParameter';
|
||||
public static DatabaseRole = 'DatabaseRole';
|
||||
public static ApplicationRole = 'ApplicationRole';
|
||||
public static FileGroupFile = 'FileGroupFile';
|
||||
public static SystemMessageType = 'SystemMessageType';
|
||||
public static SystemContract = 'SystemContract';
|
||||
public static SystemService = 'SystemService';
|
||||
public static SystemQueue = 'SystemQueue';
|
||||
public static Sequence = 'Sequence';
|
||||
public static SecurityPolicy = 'SecurityPolicy';
|
||||
public static DatabaseScopedCredential = 'DatabaseScopedCredential';
|
||||
public static ExternalResource = 'ExternalResource';
|
||||
public static ExternalDataSource = 'ExternalDataSource';
|
||||
public static ExternalFileFormat = 'ExternalFileFormat';
|
||||
public static ExternalTable = 'ExternalTable';
|
||||
public static ColumnMasterKey = 'ColumnMasterKey';
|
||||
public static ColumnEncryptionKey = 'ColumnEncryptionKey';
|
||||
|
||||
public static readonly SCRIPTABLE_OBJECTS = [NodeType.Table, NodeType.View, NodeType.Schema, NodeType.User, NodeType.UserDefinedTableType,
|
||||
NodeType.StoredProcedure, NodeType.AggregateFunction, NodeType.PartitionFunction, NodeType.ScalarValuedFunction,
|
||||
NodeType.TableValuedFunction];
|
||||
}
|
||||
|
||||
export interface SqlThemeIcon {
|
||||
readonly id: string;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { NodeType, SqlThemeIcon } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { NodeType, SqlThemeIcon } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import * as UUID from 'vs/base/common/uuid';
|
||||
|
||||
@@ -19,7 +19,7 @@ import { ServerTreeView } from 'sql/workbench/contrib/objectExplorer/browser/ser
|
||||
import * as LocalizedConstants from 'sql/workbench/contrib/connection/common/localizedConstants';
|
||||
import { ObjectExplorerService, ObjectExplorerNodeEventArgs } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { TreeNode } from 'sql/workbench/contrib/objectExplorer/common/treeNode';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||
import { ServerTreeDataSource } from 'sql/workbench/contrib/objectExplorer/browser/serverTreeDataSource';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
|
||||
@@ -12,7 +12,6 @@ import { getCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
|
||||
import { DidChangeLanguageFlavorParams } from 'azdata';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
@@ -97,12 +96,12 @@ export class SqlFlavorStatusbarItem extends Disposable implements IWorkbenchCont
|
||||
}
|
||||
|
||||
private _onEditorClosed(event: IEditorCloseEvent): void {
|
||||
let uri = WorkbenchUtils.getEditorUri(event.editor);
|
||||
let uri = event.editor.getResource().toString();
|
||||
if (uri && uri in this._sqlStatusEditors) {
|
||||
// If active editor is being closed, hide the query status.
|
||||
let activeEditor = this.editorService.activeControl;
|
||||
if (activeEditor) {
|
||||
let currentUri = WorkbenchUtils.getEditorUri(activeEditor.input);
|
||||
let currentUri = activeEditor.input.getResource().toString();
|
||||
if (uri === currentUri) {
|
||||
this.hide();
|
||||
}
|
||||
@@ -115,7 +114,7 @@ export class SqlFlavorStatusbarItem extends Disposable implements IWorkbenchCont
|
||||
private _onEditorsChanged(): void {
|
||||
let activeEditor = this.editorService.activeControl;
|
||||
if (activeEditor) {
|
||||
let uri = WorkbenchUtils.getEditorUri(activeEditor.input);
|
||||
let uri = activeEditor.input.getResource().toString();
|
||||
|
||||
// Show active editor's language flavor status
|
||||
if (uri) {
|
||||
@@ -146,7 +145,7 @@ export class SqlFlavorStatusbarItem extends Disposable implements IWorkbenchCont
|
||||
private _showStatus(uri: string): void {
|
||||
let activeEditor = this.editorService.activeControl;
|
||||
if (activeEditor) {
|
||||
let currentUri = WorkbenchUtils.getEditorUri(activeEditor.input);
|
||||
let currentUri = activeEditor.input.getResource().toString();
|
||||
if (uri === currentUri) {
|
||||
let flavor: SqlProviderEntry = this._sqlStatusEditors[uri];
|
||||
if (flavor) {
|
||||
@@ -187,7 +186,7 @@ export class ChangeFlavorAction extends Action {
|
||||
|
||||
public run(): Promise<any> {
|
||||
let activeEditor = this._editorService.activeControl;
|
||||
let currentUri = WorkbenchUtils.getEditorUri(activeEditor.input);
|
||||
let currentUri = activeEditor?.input.getResource().toString();
|
||||
if (this._connectionManagementService.isConnected(currentUri)) {
|
||||
let currentProvider = this._connectionManagementService.getProviderIdFromUri(currentUri);
|
||||
return this._showMessage(Severity.Info, nls.localize('alreadyConnected',
|
||||
|
||||
@@ -15,7 +15,7 @@ import { IConnectionManagementService } from 'sql/platform/connection/common/con
|
||||
import { QueryEditor } from 'sql/workbench/contrib/query/browser/queryEditor';
|
||||
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
|
||||
import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
|
||||
import * as Constants from 'sql/workbench/contrib/query/common/constants';
|
||||
import * as Constants from 'sql/platform/query/common/constants';
|
||||
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';
|
||||
|
||||
@@ -13,7 +13,7 @@ import { WizardNavigation } from 'sql/workbench/services/dialog/browser/wizardNa
|
||||
import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/browser/modelComponentRegistry';
|
||||
import { ModelViewContent } from 'sql/workbench/browser/modelComponents/modelViewContent.component';
|
||||
import { ModelComponentWrapper } from 'sql/workbench/browser/modelComponents/modelComponentWrapper.component';
|
||||
import { ComponentHostDirective } from 'sql/workbench/contrib/dashboard/browser/core/componentHost.directive';
|
||||
import { ComponentHostDirective } from 'sql/base/browser/componentHost.directive';
|
||||
import { providerIterator } from 'sql/workbench/services/bootstrap/browser/bootstrapService';
|
||||
import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service';
|
||||
import { EditableDropDown } from 'sql/platform/browser/editableDropdown/editableDropdown.component';
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from 'sql/workbench/contrib/query/browser/keyboardQueryActions';
|
||||
import * as gridActions from 'sql/workbench/contrib/editData/common/gridActions';
|
||||
import * as gridCommands from 'sql/workbench/contrib/editData/browser/gridCommands';
|
||||
import * as Constants from 'sql/workbench/contrib/query/common/constants';
|
||||
import * as Constants from 'sql/platform/query/common/constants';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
|
||||
@@ -36,10 +36,10 @@ import { IEditorInputFactoryRegistry, Extensions as EditorInputFactoryExtensions
|
||||
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 { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/common/languageAssociation';
|
||||
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 { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
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';
|
||||
import { ItemContextKey } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||
|
||||
@@ -1,27 +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 const copyIncludeHeaders = 'copyIncludeHeaders';
|
||||
export const configSaveAsCsv = 'saveAsCsv';
|
||||
export const configSaveAsXml = 'saveAsXml';
|
||||
export const configCopyRemoveNewLine = 'copyRemoveNewLine';
|
||||
export const configShowBatchTime = 'showBatchTime';
|
||||
export const querySection = 'query';
|
||||
export const shortcutStart = 'shortcut';
|
||||
|
||||
export const tabColorModeOff = 'off';
|
||||
export const tabColorModeBorder = 'border';
|
||||
export const tabColorModeFill = 'fill';
|
||||
|
||||
export const defaultChartType = 'defaultChartType';
|
||||
export const chartTypeBar = 'bar';
|
||||
export const chartTypeDoughnut = 'doughnut';
|
||||
export const chartTypeHorizontalBar = 'horizontalBar';
|
||||
export const chartTypeLine = 'line';
|
||||
export const chartTypePie = 'pie';
|
||||
export const chartTypeScatter = 'scatter';
|
||||
export const chartTypeTimeSeries = 'timeSeries';
|
||||
export const allChartTypes = [chartTypeBar, chartTypeDoughnut, chartTypeHorizontalBar, chartTypeLine,
|
||||
chartTypePie, chartTypeScatter, chartTypeTimeSeries];
|
||||
@@ -12,7 +12,7 @@ import { UntitledQueryEditorInput } from 'sql/workbench/contrib/query/common/unt
|
||||
import { FileQueryEditorInput } from 'sql/workbench/contrib/query/common/fileQueryEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledTextEditorInput';
|
||||
import { ILanguageAssociation } from 'sql/workbench/common/languageAssociation';
|
||||
import { ILanguageAssociation } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||
import { getCurrentGlobalConnection } from 'sql/workbench/browser/taskUtilities';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { EditorDescriptor, IEditorRegistry, Extensions } from 'vs/workbench/brow
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { QueryPlanEditor } from 'sql/workbench/contrib/queryPlan/browser/queryPlanEditor';
|
||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/common/languageAssociation';
|
||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
|
||||
// Query Plan editor registration
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledTextEditorInput';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILanguageAssociation } from 'sql/workbench/common/languageAssociation';
|
||||
import { ILanguageAssociation } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
|
||||
export class QueryPlanConverter implements ILanguageAssociation {
|
||||
static readonly languages = ['sqlplan'];
|
||||
|
||||
@@ -8,13 +8,13 @@ import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import { RestoreAction } from 'sql/workbench/contrib/restore/browser/restoreActions';
|
||||
import { TreeNodeContextKey } from 'sql/workbench/contrib/objectExplorer/common/treeNodeContextKey';
|
||||
import { ObjectExplorerActionsContext } from 'sql/workbench/contrib/objectExplorer/browser/objectExplorerActions';
|
||||
import { ConnectionContextKey } from 'sql/workbench/contrib/connection/common/connectionContextKey';
|
||||
import { ConnectionContextKey } from 'sql/workbench/services/connection/common/connectionContextKey';
|
||||
import { ManageActionContext } from 'sql/workbench/browser/actions';
|
||||
import { ItemContextKey } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||
import { ServerInfoContextKey } from 'sql/workbench/contrib/connection/common/serverInfoContextKey';
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import * as commands from 'sql/workbench/contrib/scripting/browser/scriptingActions';
|
||||
import { MssqlNodeContext } from 'sql/workbench/contrib/dataExplorer/browser/mssqlNodeContext';
|
||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { TreeNodeContextKey } from 'sql/workbench/contrib/objectExplorer/common/treeNodeContextKey';
|
||||
import { ConnectionContextKey } from 'sql/workbench/contrib/connection/common/connectionContextKey';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { ConnectionContextKey } from 'sql/workbench/services/connection/common/connectionContextKey';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ItemContextKey } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMess
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { IOEShimService } from 'sql/workbench/contrib/objectExplorer/browser/objectExplorerViewTreeShim';
|
||||
import { IOEShimService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim';
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
|
||||
@@ -16,7 +16,7 @@ import { TreeNode } from 'sql/workbench/contrib/objectExplorer/common/treeNode';
|
||||
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { NodeType } from 'sql/workbench/contrib/objectExplorer/common/nodeType';
|
||||
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
|
||||
import { ServerTreeView } from 'sql/workbench/contrib/objectExplorer/browser/serverTreeView';
|
||||
import { createObjectExplorerServiceMock } from 'sql/workbench/services/objectExplorer/test/browser/testObjectExplorerService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { AbstractEnablePreviewFeatures } from 'sql/workbench/contrib/welcome/gettingStarted/common/enablePreviewFeatures';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
export class BrowserEnablePreviewFeatures extends AbstractEnablePreviewFeatures {
|
||||
|
||||
constructor(
|
||||
@IStorageService storageService: IStorageService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
super(storageService, notificationService, hostService, configurationService);
|
||||
|
||||
this.handlePreviewFeatures();
|
||||
}
|
||||
|
||||
protected async getWindowCount(): Promise<number> {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { BrowserEnablePreviewFeatures } from 'sql/workbench/browser/enablePreviewFeatures';
|
||||
import { BrowserEnablePreviewFeatures } from 'sql/workbench/contrib/welcome/gettingStarted/browser/enablePreviewFeatures';
|
||||
|
||||
Registry
|
||||
.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { localize } from 'vs/nls';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
|
||||
export abstract class AbstractEnablePreviewFeatures implements IWorkbenchContribution {
|
||||
|
||||
private static ENABLE_PREVIEW_FEATURES_SHOWN = 'workbench.enablePreviewFeaturesShown';
|
||||
|
||||
constructor(
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IHostService private readonly hostService: IHostService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) { }
|
||||
|
||||
protected handlePreviewFeatures(): void {
|
||||
let previewFeaturesEnabled = this.configurationService.getValue('workbench')['enablePreviewFeatures'];
|
||||
if (previewFeaturesEnabled || this.storageService.get(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, StorageScope.GLOBAL)) {
|
||||
return;
|
||||
}
|
||||
Promise.all([
|
||||
this.hostService.hasFocus,
|
||||
this.getWindowCount()
|
||||
]).then(async ([focused, count]) => {
|
||||
if (!focused && count > 1) {
|
||||
return null;
|
||||
}
|
||||
await this.configurationService.updateValue('workbench.enablePreviewFeatures', false);
|
||||
|
||||
const enablePreviewFeaturesNotice = localize('enablePreviewFeatures.notice', "Preview features are required in order for extensions to be fully supported and for some actions to be available. Would you like to enable preview features?");
|
||||
this.notificationService.prompt(
|
||||
Severity.Info,
|
||||
enablePreviewFeaturesNotice,
|
||||
[{
|
||||
label: localize('enablePreviewFeatures.yes', "Yes"),
|
||||
run: () => {
|
||||
this.configurationService.updateValue('workbench.enablePreviewFeatures', true).catch(e => onUnexpectedError(e));
|
||||
this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL);
|
||||
}
|
||||
}, {
|
||||
label: localize('enablePreviewFeatures.no', "No"),
|
||||
run: () => {
|
||||
this.configurationService.updateValue('workbench.enablePreviewFeatures', false).catch(e => onUnexpectedError(e));
|
||||
}
|
||||
}, {
|
||||
label: localize('enablePreviewFeatures.never', "No, don't show again"),
|
||||
run: () => {
|
||||
this.configurationService.updateValue('workbench.enablePreviewFeatures', false).catch(e => onUnexpectedError(e));
|
||||
this.storageService.store(AbstractEnablePreviewFeatures.ENABLE_PREVIEW_FEATURES_SHOWN, true, StorageScope.GLOBAL);
|
||||
},
|
||||
isSecondary: true
|
||||
}]
|
||||
);
|
||||
}).catch(e => onUnexpectedError(e));
|
||||
}
|
||||
|
||||
protected abstract getWindowCount(): Promise<number>;
|
||||
}
|
||||
@@ -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 { AbstractEnablePreviewFeatures } from 'sql/workbench/contrib/welcome/gettingStarted/common/enablePreviewFeatures';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
|
||||
export class NativeEnablePreviewFeatures extends AbstractEnablePreviewFeatures {
|
||||
|
||||
constructor(
|
||||
@IStorageService storageService: IStorageService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IElectronService private readonly electronService: IElectronService
|
||||
) {
|
||||
super(storageService, notificationService, hostService, configurationService);
|
||||
|
||||
this.handlePreviewFeatures();
|
||||
}
|
||||
|
||||
protected getWindowCount(): Promise<number> {
|
||||
return this.electronService.getWindowCount();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { NativeEnablePreviewFeatures } from 'sql/workbench/electron-browser/enablePreviewFeatures';
|
||||
import { NativeEnablePreviewFeatures } from 'sql/workbench/contrib/welcome/gettingStarted/electron-browser/enablePreviewFeatures';
|
||||
|
||||
Registry
|
||||
.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
|
||||
|
||||
Reference in New Issue
Block a user