mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Isolate features (#6792)
* working; new query and scripting * working; removing manage from menus and combining data explorer contributions * consolidate dashboard contributions; move manage action to dashboard contributions; make groupings the same * fix notebook actions * fix tests
This commit is contained in:
@@ -13,8 +13,6 @@ import { ConnectionManagementInfo } from 'sql/platform/connection/common/connect
|
|||||||
import { IServerGroupDialogCallbacks } from 'sql/platform/serverGroup/common/serverGroupController';
|
import { IServerGroupDialogCallbacks } from 'sql/platform/serverGroup/common/serverGroupController';
|
||||||
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||||
|
|
||||||
export const VIEWLET_ID = 'workbench.view.connections';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for the actions that could happen after connecting is complete
|
* Options for the actions that could happen after connecting is complete
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,11 +5,10 @@
|
|||||||
|
|
||||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||||
import {
|
import {
|
||||||
IConnectableInput, IConnectionManagementService,
|
IConnectionManagementService,
|
||||||
IConnectionCompletionOptions, ConnectionType,
|
IConnectionCompletionOptions, ConnectionType,
|
||||||
RunQueryOnConnectionMode, IConnectionResult
|
RunQueryOnConnectionMode, IConnectionResult
|
||||||
} from 'sql/platform/connection/common/connectionManagement';
|
} from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
|
||||||
import { EditDataInput } from 'sql/workbench/parts/editData/common/editDataInput';
|
import { EditDataInput } from 'sql/workbench/parts/editData/common/editDataInput';
|
||||||
import { IRestoreDialogController } from 'sql/platform/restore/common/restoreService';
|
import { IRestoreDialogController } from 'sql/platform/restore/common/restoreService';
|
||||||
import { IInsightsDialogService } from 'sql/workbench/services/insights/browser/insightsDialogService';
|
import { IInsightsDialogService } from 'sql/workbench/services/insights/browser/insightsDialogService';
|
||||||
@@ -22,39 +21,6 @@ import { IBackupUiService } from 'sql/workbench/services/backup/common/backupUiS
|
|||||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { IInsightsConfig } from 'sql/platform/dashboard/browser/insightRegistry';
|
import { IInsightsConfig } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||||
|
|
||||||
export function newQuery(
|
|
||||||
connectionProfile: IConnectionProfile,
|
|
||||||
connectionService: IConnectionManagementService,
|
|
||||||
queryEditorService: IQueryEditorService,
|
|
||||||
objectExplorerService: IObjectExplorerService,
|
|
||||||
workbenchEditorService: IEditorService,
|
|
||||||
sqlContent?: string,
|
|
||||||
executeOnOpen: RunQueryOnConnectionMode = RunQueryOnConnectionMode.none
|
|
||||||
): Promise<void> {
|
|
||||||
return new Promise<void>((resolve) => {
|
|
||||||
if (!connectionProfile) {
|
|
||||||
connectionProfile = getCurrentGlobalConnection(objectExplorerService, connectionService, workbenchEditorService);
|
|
||||||
}
|
|
||||||
queryEditorService.newSqlEditor(sqlContent).then((owner: IConnectableInput) => {
|
|
||||||
// Connect our editor to the input connection
|
|
||||||
let options: IConnectionCompletionOptions = {
|
|
||||||
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: executeOnOpen, input: owner },
|
|
||||||
saveTheConnection: false,
|
|
||||||
showDashboard: false,
|
|
||||||
showConnectionDialogOnError: true,
|
|
||||||
showFirewallRuleOnError: true
|
|
||||||
};
|
|
||||||
if (connectionProfile) {
|
|
||||||
connectionService.connect(connectionProfile, owner.uri, options).then(() => {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function replaceConnection(oldUri: string, newUri: string, connectionService: IConnectionManagementService): Promise<IConnectionResult> {
|
export function replaceConnection(oldUri: string, newUri: string, connectionService: IConnectionManagementService): Promise<IConnectionResult> {
|
||||||
return new Promise<IConnectionResult>((resolve, reject) => {
|
return new Promise<IConnectionResult>((resolve, reject) => {
|
||||||
let defaultResult: IConnectionResult = {
|
let defaultResult: IConnectionResult = {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platf
|
|||||||
|
|
||||||
new Actions.BackupAction().registerTask();
|
new Actions.BackupAction().registerTask();
|
||||||
new Actions.RestoreAction().registerTask();
|
new Actions.RestoreAction().registerTask();
|
||||||
new Actions.NewQueryAction().registerTask();
|
|
||||||
new Actions.ConfigureDashboardAction().registerTask();
|
new Actions.ConfigureDashboardAction().registerTask();
|
||||||
|
|
||||||
Registry.as<IConfigurationRegistry>(ConfigExtensions.Configuration).registerConfiguration({
|
Registry.as<IConfigurationRegistry>(ConfigExtensions.Configuration).registerConfiguration({
|
||||||
|
|||||||
@@ -41,32 +41,6 @@ export interface ManageActionContext extends BaseActionContext {
|
|||||||
uri: string;
|
uri: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- actions
|
|
||||||
export class NewQueryAction extends Task {
|
|
||||||
public static ID = 'newQuery';
|
|
||||||
public static LABEL = nls.localize('newQueryAction.newQuery', "New Query");
|
|
||||||
public static ICON = 'new-query';
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super({
|
|
||||||
id: NewQueryAction.ID,
|
|
||||||
title: NewQueryAction.LABEL,
|
|
||||||
iconPath: undefined,
|
|
||||||
iconClass: NewQueryAction.ICON
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public runTask(accessor: ServicesAccessor, profile: IConnectionProfile): Promise<void> {
|
|
||||||
return TaskUtilities.newQuery(
|
|
||||||
profile,
|
|
||||||
accessor.get<IConnectionManagementService>(IConnectionManagementService),
|
|
||||||
accessor.get<IQueryEditorService>(IQueryEditorService),
|
|
||||||
accessor.get<IObjectExplorerService>(IObjectExplorerService),
|
|
||||||
accessor.get<IEditorService>(IEditorService)
|
|
||||||
).then();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const BackupFeatureName = 'backup';
|
export const BackupFeatureName = 'backup';
|
||||||
|
|
||||||
export class BackupAction extends Task {
|
export class BackupAction extends Task {
|
||||||
|
|||||||
@@ -11,11 +11,8 @@ import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionT
|
|||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||||
import * as Constants from 'sql/platform/connection/common/constants';
|
import * as Constants from 'sql/platform/connection/common/constants';
|
||||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
|
||||||
import * as platform from 'vs/platform/registry/common/platform';
|
import * as platform from 'vs/platform/registry/common/platform';
|
||||||
import { IConnectionProviderRegistry, Extensions as ConnectionProviderExtensions } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
import { IConnectionProviderRegistry, Extensions as ConnectionProviderExtensions } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||||
import * as TaskUtilities from 'sql/workbench/browser/taskUtilities';
|
|
||||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
|
||||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
import { ipcRenderer as ipc } from 'electron';
|
import { ipcRenderer as ipc } from 'electron';
|
||||||
@@ -27,20 +24,21 @@ import { URI } from 'vs/base/common/uri';
|
|||||||
import { ILogService } from 'vs/platform/log/common/log';
|
import { ILogService } from 'vs/platform/log/common/log';
|
||||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||||
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
import { openNewQuery } from 'sql/workbench/parts/query/browser/queryActions';
|
||||||
|
|
||||||
export class CommandLineWorkbenchContribution implements IWorkbenchContribution {
|
export class CommandLineWorkbenchContribution implements IWorkbenchContribution {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
@ICapabilitiesService private readonly _capabilitiesService: ICapabilitiesService,
|
||||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
@IConnectionManagementService private readonly _connectionManagementService: IConnectionManagementService,
|
||||||
@IEnvironmentService environmentService: IEnvironmentService,
|
@IEnvironmentService environmentService: IEnvironmentService,
|
||||||
@IQueryEditorService private _queryEditorService: IQueryEditorService,
|
@IEditorService private readonly _editorService: IEditorService,
|
||||||
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
|
@ICommandService private readonly _commandService: ICommandService,
|
||||||
@IEditorService private _editorService: IEditorService,
|
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||||
@ICommandService private _commandService: ICommandService,
|
@INotificationService private readonly _notificationService: INotificationService,
|
||||||
@IConfigurationService private _configurationService: IConfigurationService,
|
@ILogService private readonly logService: ILogService,
|
||||||
@INotificationService private _notificationService: INotificationService,
|
@IInstantiationService private readonly instantiationService: IInstantiationService
|
||||||
@ILogService private logService: ILogService
|
|
||||||
) {
|
) {
|
||||||
if (ipc) {
|
if (ipc) {
|
||||||
ipc.on('ads:processCommandLine', (event: any, args: ParsedArgs) => this.onLaunched(args));
|
ipc.on('ads:processCommandLine', (event: any, args: ParsedArgs) => this.onLaunched(args));
|
||||||
@@ -122,11 +120,7 @@ export class CommandLineWorkbenchContribution implements IWorkbenchContribution
|
|||||||
this._notificationService.status(localize('openingNewQueryLabel', "Opening new query: {0}", profile.serverName), { hideAfter: 2500 });
|
this._notificationService.status(localize('openingNewQueryLabel', "Opening new query: {0}", profile.serverName), { hideAfter: 2500 });
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await TaskUtilities.newQuery(profile,
|
await this.instantiationService.invokeFunction(openNewQuery, profile);
|
||||||
this._connectionManagementService,
|
|
||||||
this._queryEditorService,
|
|
||||||
this._objectExplorerService,
|
|
||||||
this._editorService);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logService.warn('unable to open query editor ' + error);
|
this.logService.warn('unable to open query editor ' + error);
|
||||||
// Note: we are intentionally swallowing this error.
|
// Note: we are intentionally swallowing this error.
|
||||||
|
|||||||
@@ -110,13 +110,12 @@ suite('commandLineService tests', () => {
|
|||||||
capabilitiesService,
|
capabilitiesService,
|
||||||
connectionManagementService,
|
connectionManagementService,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
editorService,
|
editorService,
|
||||||
commandService,
|
commandService,
|
||||||
configurationService,
|
configurationService,
|
||||||
undefined,
|
undefined,
|
||||||
logService
|
logService,
|
||||||
|
undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,52 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
|||||||
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
|
import { IConfigurationNode, IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||||
|
import { DASHBOARD_CONFIG_ID } from 'sql/workbench/parts/dashboard/browser/pages/dashboardPageContribution';
|
||||||
|
import { DATABASE_DASHBOARD_PROPERTIES, databaseDashboardPropertiesSchema, DATABASE_DASHBOARD_SETTING, databaseDashboardSettingSchema, DATABASE_DASHBOARD_TABS, databaseDashboardTabsSchema } from 'sql/workbench/parts/dashboard/browser/pages/databaseDashboardPage.contribution';
|
||||||
|
import { SERVER_DASHBOARD_PROPERTIES, serverDashboardPropertiesSchema, SERVER_DASHBOARD_SETTING, serverDashboardSettingSchema, SERVER_DASHBOARD_TABS, serverDashboardTabsSchema } from 'sql/workbench/parts/dashboard/browser/pages/serverDashboardPage.contribution';
|
||||||
|
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||||
|
import { MssqlNodeContext } from 'sql/workbench/parts/dataExplorer/common/mssqlNodeContext';
|
||||||
|
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||||
|
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
|
||||||
|
import { DE_MANAGE_COMMAND_ID, OE_MANAGE_COMMAND_ID } from 'sql/workbench/parts/dashboard/browser/dashboardActions';
|
||||||
|
|
||||||
|
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
|
||||||
|
const dashboardConfig: IConfigurationNode = {
|
||||||
|
id: DASHBOARD_CONFIG_ID,
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
[DATABASE_DASHBOARD_PROPERTIES]: databaseDashboardPropertiesSchema,
|
||||||
|
[SERVER_DASHBOARD_PROPERTIES]: serverDashboardPropertiesSchema,
|
||||||
|
[DATABASE_DASHBOARD_SETTING]: databaseDashboardSettingSchema,
|
||||||
|
[SERVER_DASHBOARD_SETTING]: serverDashboardSettingSchema,
|
||||||
|
[DATABASE_DASHBOARD_TABS]: databaseDashboardTabsSchema,
|
||||||
|
[SERVER_DASHBOARD_TABS]: serverDashboardTabsSchema
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
configurationRegistry.registerConfiguration(dashboardConfig);
|
||||||
|
|
||||||
|
// // Manage
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
|
group: '0_query',
|
||||||
|
order: 1,
|
||||||
|
command: {
|
||||||
|
id: DE_MANAGE_COMMAND_ID,
|
||||||
|
title: localize('manage', "Manage")
|
||||||
|
},
|
||||||
|
when: MssqlNodeContext.IsDatabaseOrServer
|
||||||
|
});
|
||||||
|
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||||
|
group: '0_query',
|
||||||
|
order: 1,
|
||||||
|
command: {
|
||||||
|
id: OE_MANAGE_COMMAND_ID,
|
||||||
|
title: localize('manage', "Manage")
|
||||||
|
},
|
||||||
|
when: ContextKeyExpr.or(ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.NodeType.isEqualTo('Server')), ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.NodeType.isEqualTo('Database')))
|
||||||
|
});
|
||||||
|
|
||||||
const dashboardEditorDescriptor = new EditorDescriptor(
|
const dashboardEditorDescriptor = new EditorDescriptor(
|
||||||
DashboardEditor,
|
DashboardEditor,
|
||||||
|
|||||||
137
src/sql/workbench/parts/dashboard/browser/dashboardActions.ts
Normal file
137
src/sql/workbench/parts/dashboard/browser/dashboardActions.ts
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||||
|
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||||
|
import { IConnectionManagementService, IConnectionCompletionOptions } from 'sql/platform/connection/common/connectionManagement';
|
||||||
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
import { generateUri } from 'sql/platform/connection/common/utils';
|
||||||
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
|
import { localize } from 'vs/nls';
|
||||||
|
import { Action } from 'vs/base/common/actions';
|
||||||
|
import { TreeSelectionHandler } from 'sql/workbench/parts/objectExplorer/browser/treeSelectionHandler';
|
||||||
|
import { ObjectExplorerActionsContext, getTreeNode } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
|
||||||
|
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
||||||
|
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||||
|
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
||||||
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
||||||
|
import { IViewsService } from 'vs/workbench/common/views';
|
||||||
|
import { ConnectionViewletPanel } from 'sql/workbench/parts/dataExplorer/browser/connectionViewletPanel';
|
||||||
|
|
||||||
|
export const DE_MANAGE_COMMAND_ID = 'dataExplorer.manage';
|
||||||
|
|
||||||
|
// Manage
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: DE_MANAGE_COMMAND_ID,
|
||||||
|
handler: (accessor, args: TreeViewItemHandleArg) => {
|
||||||
|
if (args.$treeItem) {
|
||||||
|
const connectionService = accessor.get(IConnectionManagementService);
|
||||||
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
|
let options = {
|
||||||
|
showDashboard: true,
|
||||||
|
saveTheConnection: false,
|
||||||
|
params: undefined,
|
||||||
|
showConnectionDialogOnError: true,
|
||||||
|
showFirewallRuleOnError: true
|
||||||
|
};
|
||||||
|
let profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||||
|
let uri = generateUri(profile, 'dashboard');
|
||||||
|
return connectionService.connect(new ConnectionProfile(capabilitiesService, args.$treeItem.payload), uri, options);
|
||||||
|
}
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const OE_MANAGE_COMMAND_ID = 'objectExplorer.manage';
|
||||||
|
|
||||||
|
// Manage
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: OE_MANAGE_COMMAND_ID,
|
||||||
|
handler: (accessor, args: ObjectExplorerActionsContext) => {
|
||||||
|
return accessor.get(IInstantiationService).createInstance(OEManageConnectionAction, OEManageConnectionAction.ID, OEManageConnectionAction.LABEL).run(args);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export class OEManageConnectionAction extends Action {
|
||||||
|
public static ID = 'objectExplorer.manage';
|
||||||
|
public static LABEL = localize('ManageAction', "Manage");
|
||||||
|
|
||||||
|
private _treeSelectionHandler: TreeSelectionHandler;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
id: string,
|
||||||
|
label: string,
|
||||||
|
@IConnectionManagementService protected readonly _connectionManagementService: IConnectionManagementService,
|
||||||
|
@ICapabilitiesService protected readonly _capabilitiesService: ICapabilitiesService,
|
||||||
|
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||||
|
@IObjectExplorerService private readonly _objectExplorerService: IObjectExplorerService,
|
||||||
|
@IViewsService private readonly _viewsService: IViewsService
|
||||||
|
) {
|
||||||
|
super(id, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
run(actionContext: ObjectExplorerActionsContext): Promise<any> {
|
||||||
|
this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler);
|
||||||
|
this._treeSelectionHandler.onTreeActionStateChange(true);
|
||||||
|
let self = this;
|
||||||
|
let promise = new Promise<boolean>((resolve, reject) => {
|
||||||
|
self.doManage(actionContext).then((success) => {
|
||||||
|
self.done();
|
||||||
|
resolve(success);
|
||||||
|
}, error => {
|
||||||
|
self.done();
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async doManage(actionContext: ObjectExplorerActionsContext): Promise<boolean> {
|
||||||
|
let treeNode: TreeNode = undefined;
|
||||||
|
let connectionProfile: IConnectionProfile = undefined;
|
||||||
|
if (actionContext instanceof ObjectExplorerActionsContext) {
|
||||||
|
// Must use a real connection profile for this action due to lookup
|
||||||
|
connectionProfile = ConnectionProfile.fromIConnectionProfile(this._capabilitiesService, actionContext.connectionProfile);
|
||||||
|
if (!actionContext.isConnectionNode) {
|
||||||
|
treeNode = await getTreeNode(actionContext, this._objectExplorerService);
|
||||||
|
if (TreeUpdateUtils.isDatabaseNode(treeNode)) {
|
||||||
|
connectionProfile = TreeUpdateUtils.getConnectionProfile(treeNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!connectionProfile) {
|
||||||
|
// This should never happen. There should be always a valid connection if the manage action is called for
|
||||||
|
// an OE node or a database node
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let options: IConnectionCompletionOptions = {
|
||||||
|
params: undefined,
|
||||||
|
saveTheConnection: false,
|
||||||
|
showConnectionDialogOnError: true,
|
||||||
|
showDashboard: true,
|
||||||
|
showFirewallRuleOnError: true
|
||||||
|
};
|
||||||
|
|
||||||
|
// If it's a database node just open a database connection and open dashboard,
|
||||||
|
// the node is already from an open OE session we don't need to create new session
|
||||||
|
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
|
||||||
|
return this._connectionManagementService.showDashboard(connectionProfile);
|
||||||
|
} else {
|
||||||
|
const view = await this._viewsService.openView(ConnectionViewletPanel.ID) as ConnectionViewletPanel;
|
||||||
|
return TreeUpdateUtils.connectAndCreateOeSession(connectionProfile, options, this._connectionManagementService, this._objectExplorerService, view.serversTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private done() {
|
||||||
|
this._treeSelectionHandler.onTreeActionStateChange(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose(): void {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +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 { Registry } from 'vs/platform/registry/common/platform';
|
|
||||||
import { IConfigurationRegistry, Extensions, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry';
|
|
||||||
import { DASHBOARD_CONFIG_ID } from 'sql/workbench/parts/dashboard/browser/pages/dashboardPageContribution';
|
|
||||||
import { DATABASE_DASHBOARD_SETTING, DATABASE_DASHBOARD_PROPERTIES, DATABASE_DASHBOARD_TABS, databaseDashboardSettingSchema, databaseDashboardPropertiesSchema, databaseDashboardTabsSchema } from 'sql/workbench/parts/dashboard/browser/pages/databaseDashboardPage.contribution';
|
|
||||||
import { SERVER_DASHBOARD_SETTING, SERVER_DASHBOARD_PROPERTIES, SERVER_DASHBOARD_TABS, serverDashboardSettingSchema, serverDashboardPropertiesSchema, serverDashboardTabsSchema } from 'sql/workbench/parts/dashboard/browser/pages/serverDashboardPage.contribution';
|
|
||||||
|
|
||||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
|
|
||||||
const dashboardConfig: IConfigurationNode = {
|
|
||||||
id: DASHBOARD_CONFIG_ID,
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
[DATABASE_DASHBOARD_PROPERTIES]: databaseDashboardPropertiesSchema,
|
|
||||||
[SERVER_DASHBOARD_PROPERTIES]: serverDashboardPropertiesSchema,
|
|
||||||
[DATABASE_DASHBOARD_SETTING]: databaseDashboardSettingSchema,
|
|
||||||
[SERVER_DASHBOARD_SETTING]: serverDashboardSettingSchema,
|
|
||||||
[DATABASE_DASHBOARD_TABS]: databaseDashboardTabsSchema,
|
|
||||||
[SERVER_DASHBOARD_TABS]: serverDashboardTabsSchema
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
configurationRegistry.registerConfiguration(dashboardConfig);
|
|
||||||
@@ -10,9 +10,10 @@ import { ExplorerManageAction, CustomExecuteCommandAction } from 'sql/workbench/
|
|||||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { ItemContextKey } from 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerTreeContext';
|
import { ItemContextKey } from 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||||
import { BackupAction, RestoreAction, NewQueryAction } from 'sql/workbench/common/actions';
|
import { BackupAction, RestoreAction } from 'sql/workbench/common/actions';
|
||||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
|
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
|
||||||
|
import { NewQueryTask } from 'sql/workbench/parts/query/browser/queryActions';
|
||||||
|
|
||||||
const explorerSchema: IJSONSchema = {
|
const explorerSchema: IJSONSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -40,7 +41,7 @@ CommandsRegistry.registerCommand(ExplorerRestoreActionID, (accessor, context) =>
|
|||||||
const ExplorerNewQueryActionID = 'explorer.query';
|
const ExplorerNewQueryActionID = 'explorer.query';
|
||||||
CommandsRegistry.registerCommand(ExplorerNewQueryActionID, (accessor, context) => {
|
CommandsRegistry.registerCommand(ExplorerNewQueryActionID, (accessor, context) => {
|
||||||
const instantiationService = accessor.get(IInstantiationService);
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
instantiationService.createInstance(CustomExecuteCommandAction, NewQueryAction.ID, NewQueryAction.LABEL).run(context);
|
instantiationService.createInstance(CustomExecuteCommandAction, NewQueryTask.ID, NewQueryTask.LABEL).run(context);
|
||||||
});
|
});
|
||||||
|
|
||||||
const ExplorerNotebookActionID = 'explorer.notebook';
|
const ExplorerNotebookActionID = 'explorer.notebook';
|
||||||
@@ -61,7 +62,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
|||||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||||
command: {
|
command: {
|
||||||
id: ExplorerNewQueryActionID,
|
id: ExplorerNewQueryActionID,
|
||||||
title: NewQueryAction.LABEL
|
title: NewQueryTask.LABEL
|
||||||
},
|
},
|
||||||
when: ItemContextKey.ItemType.isEqualTo('database'),
|
when: ItemContextKey.ItemType.isEqualTo('database'),
|
||||||
order: 1
|
order: 1
|
||||||
|
|||||||
@@ -6,12 +6,10 @@
|
|||||||
import { Action } from 'vs/base/common/actions';
|
import { Action } from 'vs/base/common/actions';
|
||||||
import * as nls from 'vs/nls';
|
import * as nls from 'vs/nls';
|
||||||
|
|
||||||
import * as TaskUtilities from 'sql/workbench/browser/taskUtilities';
|
import { RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { RunQueryOnConnectionMode, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
|
||||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
|
||||||
import { InsightActionContext } from 'sql/workbench/common/actions';
|
import { InsightActionContext } from 'sql/workbench/common/actions';
|
||||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
import { openNewQuery } from 'sql/workbench/parts/query/browser/queryActions';
|
||||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
|
||||||
export class RunInsightQueryAction extends Action {
|
export class RunInsightQueryAction extends Action {
|
||||||
public static ID = 'runQuery';
|
public static ID = 'runQuery';
|
||||||
@@ -19,25 +17,12 @@ export class RunInsightQueryAction extends Action {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
id: string, label: string,
|
id: string, label: string,
|
||||||
@IQueryEditorService protected _queryEditorService: IQueryEditorService,
|
@IInstantiationService private readonly instantiationService: IInstantiationService
|
||||||
@IConnectionManagementService protected _connectionManagementService: IConnectionManagementService,
|
|
||||||
@IObjectExplorerService protected _objectExplorerService: IObjectExplorerService,
|
|
||||||
@IEditorService protected _workbenchEditorService: IEditorService
|
|
||||||
) {
|
) {
|
||||||
super(id, label);
|
super(id, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
public run(context: InsightActionContext): Promise<boolean> {
|
public run(context: InsightActionContext): Promise<boolean> {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return this.instantiationService.invokeFunction(openNewQuery, context.profile, undefined, RunQueryOnConnectionMode.executeQuery).then(() => true, () => false);
|
||||||
TaskUtilities.newQuery(
|
|
||||||
context.profile,
|
|
||||||
this._connectionManagementService,
|
|
||||||
this._queryEditorService,
|
|
||||||
this._objectExplorerService,
|
|
||||||
this._workbenchEditorService,
|
|
||||||
context.insight.query as string,
|
|
||||||
RunQueryOnConnectionMode.executeQuery
|
|
||||||
).then(() => resolve(true), () => resolve(false));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,12 @@ import {
|
|||||||
} from 'sql/workbench/parts/objectExplorer/browser/connectionTreeAction';
|
} from 'sql/workbench/parts/objectExplorer/browser/connectionTreeAction';
|
||||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
||||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||||
|
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||||
|
|
||||||
export class ConnectionViewletPanel extends ViewletPanel {
|
export class ConnectionViewletPanel extends ViewletPanel {
|
||||||
|
|
||||||
|
public static readonly ID = 'dataExplorer.servers';
|
||||||
|
|
||||||
private _root: HTMLElement;
|
private _root: HTMLElement;
|
||||||
private _serverTreeView: ServerTreeView;
|
private _serverTreeView: ServerTreeView;
|
||||||
private _addServerAction: IAction;
|
private _addServerAction: IAction;
|
||||||
@@ -70,6 +73,10 @@ export class ConnectionViewletPanel extends ViewletPanel {
|
|||||||
this._root = container;
|
this._root = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get serversTree(): ITree {
|
||||||
|
return this._serverTreeView.tree;
|
||||||
|
}
|
||||||
|
|
||||||
layoutBody(size: number): void {
|
layoutBody(size: number): void {
|
||||||
this._serverTreeView.layout(size);
|
this._serverTreeView.layout(size);
|
||||||
DOM.toggleClass(this._root, 'narrow', this._root.clientWidth < 300);
|
DOM.toggleClass(this._root, 'narrow', this._root.clientWidth < 300);
|
||||||
|
|||||||
@@ -6,16 +6,16 @@
|
|||||||
import 'vs/css!sql/media/actionBarLabel';
|
import 'vs/css!sql/media/actionBarLabel';
|
||||||
import 'vs/css!./media/dataExplorer.contribution';
|
import 'vs/css!./media/dataExplorer.contribution';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor, ShowViewletAction } from 'vs/workbench/browser/viewlet';
|
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
|
||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
import { VIEWLET_ID } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint';
|
import { DataExplorerViewlet, DataExplorerViewletViewsContribution, OpenDataExplorerViewletAction, VIEWLET_ID } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet';
|
||||||
import { DataExplorerViewlet, DataExplorerViewletViewsContribution, OpenDataExplorerViewletAction } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet';
|
|
||||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||||
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
|
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
|
||||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||||
|
import { DataExplorerContainerExtensionHandler } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint';
|
||||||
|
|
||||||
// Data Explorer Viewlet
|
// Data Explorer Viewlet
|
||||||
const viewletDescriptor = new ViewletDescriptor(
|
const viewletDescriptor = new ViewletDescriptor(
|
||||||
@@ -70,3 +70,5 @@ configurationRegistry.registerConfiguration({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
workbenchRegistry.registerWorkbenchContribution(DataExplorerContainerExtensionHandler, LifecyclePhase.Starting);
|
||||||
|
|||||||
@@ -9,17 +9,14 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
|||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
import { IViewContainersRegistry, ViewContainer, Extensions as ViewContainerExtensions, ITreeViewDescriptor, IViewsRegistry } from 'vs/workbench/common/views';
|
import { IViewContainersRegistry, ViewContainer, Extensions as ViewContainerExtensions, ITreeViewDescriptor, IViewsRegistry } from 'vs/workbench/common/views';
|
||||||
import { IExtensionPoint, ExtensionsRegistry, ExtensionMessageCollector } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
import { IExtensionPoint, ExtensionsRegistry, ExtensionMessageCollector } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
||||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { CustomTreeViewPanel } from 'vs/workbench/browser/parts/views/customView';
|
import { CustomTreeViewPanel } from 'vs/workbench/browser/parts/views/customView';
|
||||||
import { coalesce } from 'vs/base/common/arrays';
|
import { coalesce } from 'vs/base/common/arrays';
|
||||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
|
||||||
|
|
||||||
import { CustomTreeView } from 'sql/workbench/browser/parts/views/customView';
|
import { CustomTreeView } from 'sql/workbench/browser/parts/views/customView';
|
||||||
|
import { VIEWLET_ID } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet';
|
||||||
export const VIEWLET_ID = 'workbench.view.connections';
|
|
||||||
export const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer(VIEWLET_ID);
|
|
||||||
|
|
||||||
interface IUserFriendlyViewDescriptor {
|
interface IUserFriendlyViewDescriptor {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -67,7 +64,7 @@ const dataExplorerContribution: IJSONSchema = {
|
|||||||
|
|
||||||
const dataExplorerExtensionPoint: IExtensionPoint<{ [loc: string]: IUserFriendlyViewDescriptor[] }> = ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: IUserFriendlyViewDescriptor[] }>({ extensionPoint: 'dataExplorer', jsonSchema: dataExplorerContribution });
|
const dataExplorerExtensionPoint: IExtensionPoint<{ [loc: string]: IUserFriendlyViewDescriptor[] }> = ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: IUserFriendlyViewDescriptor[] }>({ extensionPoint: 'dataExplorer', jsonSchema: dataExplorerContribution });
|
||||||
|
|
||||||
class DataExplorerContainerExtensionHandler implements IWorkbenchContribution {
|
export class DataExplorerContainerExtensionHandler implements IWorkbenchContribution {
|
||||||
|
|
||||||
private viewContainersRegistry: IViewContainersRegistry;
|
private viewContainersRegistry: IViewContainersRegistry;
|
||||||
|
|
||||||
@@ -154,5 +151,3 @@ class DataExplorerContainerExtensionHandler implements IWorkbenchContribution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
|
||||||
workbenchRegistry.registerWorkbenchContribution(DataExplorerContainerExtensionHandler, LifecyclePhase.Starting);
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||||
import { IAction } from 'vs/base/common/actions';
|
import { IAction } from 'vs/base/common/actions';
|
||||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
|
||||||
import { append, $, addClass, toggleClass, Dimension } from 'vs/base/browser/dom';
|
import { append, $, addClass, toggleClass, Dimension } from 'vs/base/browser/dom';
|
||||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
@@ -18,9 +17,8 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
|
|||||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||||
import { IAddedViewDescriptorRef } from 'vs/workbench/browser/parts/views/views';
|
import { IAddedViewDescriptorRef } from 'vs/workbench/browser/parts/views/views';
|
||||||
import { ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet';
|
import { ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet';
|
||||||
import { VIEWLET_ID, VIEW_CONTAINER } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint';
|
|
||||||
import { ConnectionViewletPanel } from 'sql/workbench/parts/dataExplorer/browser/connectionViewletPanel';
|
import { ConnectionViewletPanel } from 'sql/workbench/parts/dataExplorer/browser/connectionViewletPanel';
|
||||||
import { Extensions as ViewContainerExtensions, IViewDescriptor, IViewsRegistry } from 'vs/workbench/common/views';
|
import { Extensions as ViewContainerExtensions, IViewDescriptor, IViewsRegistry, IViewContainersRegistry } from 'vs/workbench/common/views';
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
@@ -28,6 +26,9 @@ import { IMenuService, MenuId } from 'vs/platform/actions/common/actions';
|
|||||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { ShowViewletAction } from 'vs/workbench/browser/viewlet';
|
import { ShowViewletAction } from 'vs/workbench/browser/viewlet';
|
||||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||||
|
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||||
|
|
||||||
|
export const VIEWLET_ID = 'workbench.view.connections';
|
||||||
|
|
||||||
// Viewlet Action
|
// Viewlet Action
|
||||||
export class OpenDataExplorerViewletAction extends ShowViewletAction {
|
export class OpenDataExplorerViewletAction extends ShowViewletAction {
|
||||||
@@ -45,6 +46,8 @@ export class OpenDataExplorerViewletAction extends ShowViewletAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const VIEW_CONTAINER = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer(VIEWLET_ID);
|
||||||
|
|
||||||
export class DataExplorerViewletViewsContribution implements IWorkbenchContribution {
|
export class DataExplorerViewletViewsContribution implements IWorkbenchContribution {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -59,7 +62,7 @@ export class DataExplorerViewletViewsContribution implements IWorkbenchContribut
|
|||||||
|
|
||||||
private createObjectExplorerViewDescriptor(): IViewDescriptor {
|
private createObjectExplorerViewDescriptor(): IViewDescriptor {
|
||||||
return {
|
return {
|
||||||
id: 'dataExplorer.servers',
|
id: ConnectionViewletPanel.ID,
|
||||||
name: localize('dataExplorer.servers', "Servers"),
|
name: localize('dataExplorer.servers', "Servers"),
|
||||||
ctorDescriptor: { ctor: ConnectionViewletPanel },
|
ctorDescriptor: { ctor: ConnectionViewletPanel },
|
||||||
weight: 100,
|
weight: 100,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { localize } from 'vs/nls';
|
|||||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||||
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||||
import {
|
import {
|
||||||
DISCONNECT_COMMAND_ID, MANAGE_COMMAND_ID, NEW_QUERY_COMMAND_ID, REFRESH_COMMAND_ID,
|
DISCONNECT_COMMAND_ID, MANAGE_COMMAND_ID, REFRESH_COMMAND_ID,
|
||||||
NEW_NOTEBOOK_COMMAND_ID, SCHEMA_COMPARE_COMMAND_ID, DATA_TIER_WIZARD_COMMAND_ID,
|
NEW_NOTEBOOK_COMMAND_ID, SCHEMA_COMPARE_COMMAND_ID, DATA_TIER_WIZARD_COMMAND_ID,
|
||||||
IMPORT_COMMAND_ID, BACKUP_COMMAND_ID, RESTORE_COMMAND_ID, PROFILER_COMMAND_ID, GENERATE_SCRIPTS_COMMAND_ID, PROPERTIES_COMMAND_ID
|
IMPORT_COMMAND_ID, BACKUP_COMMAND_ID, RESTORE_COMMAND_ID, PROFILER_COMMAND_ID, GENERATE_SCRIPTS_COMMAND_ID, PROPERTIES_COMMAND_ID
|
||||||
} from './nodeCommands.common';
|
} from './nodeCommands.common';
|
||||||
@@ -41,29 +41,6 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|||||||
MssqlNodeContext.IsDatabaseOrServer)
|
MssqlNodeContext.IsDatabaseOrServer)
|
||||||
});
|
});
|
||||||
|
|
||||||
// New Query
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|
||||||
group: 'connection',
|
|
||||||
order: 2,
|
|
||||||
command: {
|
|
||||||
id: NEW_QUERY_COMMAND_ID,
|
|
||||||
title: localize('newQuery', "New Query")
|
|
||||||
},
|
|
||||||
when: MssqlNodeContext.IsDatabaseOrServer
|
|
||||||
});
|
|
||||||
|
|
||||||
// Manage
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|
||||||
group: 'connection',
|
|
||||||
order: 1,
|
|
||||||
command: {
|
|
||||||
id: MANAGE_COMMAND_ID,
|
|
||||||
title: localize('manage', "Manage")
|
|
||||||
},
|
|
||||||
when: MssqlNodeContext.IsDatabaseOrServer
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Refresh
|
// Refresh
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
group: 'connection',
|
group: 'connection',
|
||||||
|
|||||||
@@ -1,75 +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 { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
|
||||||
import { SCRIPT_AS_CREATE_COMMAND_ID, SCRIPT_AS_DELETE_COMMAND_ID, SCRIPT_AS_SELECT_COMMAND_ID, SCRIPT_AS_EXECUTE_COMMAND_ID, SCRIPT_AS_ALTER_COMMAND_ID, EDIT_DATA_COMMAND_ID } from 'sql/workbench/parts/dataExplorer/electron-browser/nodeCommand';
|
|
||||||
import { MssqlNodeContext } from 'sql/workbench/parts/dataExplorer/common/mssqlNodeContext';
|
|
||||||
import { localize } from 'vs/nls';
|
|
||||||
|
|
||||||
// Script as Create
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|
||||||
group: 'connection',
|
|
||||||
order: 3,
|
|
||||||
command: {
|
|
||||||
id: SCRIPT_AS_CREATE_COMMAND_ID,
|
|
||||||
title: localize('scriptAsCreate', "Script as Create")
|
|
||||||
},
|
|
||||||
when: MssqlNodeContext.CanScriptAsCreateOrDelete
|
|
||||||
});
|
|
||||||
|
|
||||||
// Script as Delete
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|
||||||
group: 'connection',
|
|
||||||
order: 4,
|
|
||||||
command: {
|
|
||||||
id: SCRIPT_AS_DELETE_COMMAND_ID,
|
|
||||||
title: localize('scriptAsDelete', "Script as Drop")
|
|
||||||
},
|
|
||||||
when: MssqlNodeContext.CanScriptAsCreateOrDelete
|
|
||||||
});
|
|
||||||
|
|
||||||
// Script as Select
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|
||||||
group: 'connection',
|
|
||||||
order: 1,
|
|
||||||
command: {
|
|
||||||
id: SCRIPT_AS_SELECT_COMMAND_ID,
|
|
||||||
title: localize('scriptAsSelect', "Select Top 1000")
|
|
||||||
},
|
|
||||||
when: MssqlNodeContext.CanScriptAsSelect
|
|
||||||
});
|
|
||||||
|
|
||||||
// Script as Execute
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|
||||||
group: 'connection',
|
|
||||||
order: 5,
|
|
||||||
command: {
|
|
||||||
id: SCRIPT_AS_EXECUTE_COMMAND_ID,
|
|
||||||
title: localize('scriptAsExecute', "Script as Execute")
|
|
||||||
},
|
|
||||||
when: MssqlNodeContext.CanScriptAsExecute
|
|
||||||
});
|
|
||||||
|
|
||||||
// Script as Alter
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|
||||||
group: 'connection',
|
|
||||||
order: 5,
|
|
||||||
command: {
|
|
||||||
id: SCRIPT_AS_ALTER_COMMAND_ID,
|
|
||||||
title: localize('scriptAsAlter', "Script as Alter")
|
|
||||||
},
|
|
||||||
when: MssqlNodeContext.CanScriptAsAlter
|
|
||||||
});
|
|
||||||
|
|
||||||
// Edit Data
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
|
||||||
group: 'connection',
|
|
||||||
order: 2,
|
|
||||||
command: {
|
|
||||||
id: EDIT_DATA_COMMAND_ID,
|
|
||||||
title: localize('editData', "Edit Data")
|
|
||||||
},
|
|
||||||
when: MssqlNodeContext.CanEditData
|
|
||||||
});
|
|
||||||
@@ -1,155 +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 { VIEWLET_ID } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint';
|
|
||||||
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
|
|
||||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
|
||||||
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/parts/objectExplorer/common/objectExplorerViewTreeShim';
|
|
||||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
|
||||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
|
||||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
|
||||||
import { BaseActionContext } from 'sql/workbench/common/actions';
|
|
||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
|
||||||
import { ScriptCreateAction, ScriptDeleteAction, ScriptSelectAction, ScriptExecuteAction, ScriptAlterAction, EditDataAction } from 'sql/workbench/electron-browser/scriptingActions';
|
|
||||||
|
|
||||||
export const SCRIPT_AS_CREATE_COMMAND_ID = 'dataExplorer.scriptAsCreate';
|
|
||||||
export const SCRIPT_AS_DELETE_COMMAND_ID = 'dataExplorer.scriptAsDelete';
|
|
||||||
export const SCRIPT_AS_SELECT_COMMAND_ID = 'dataExplorer.scriptAsSelect';
|
|
||||||
export const SCRIPT_AS_EXECUTE_COMMAND_ID = 'dataExplorer.scriptAsExecute';
|
|
||||||
export const SCRIPT_AS_ALTER_COMMAND_ID = 'dataExplorer.scriptAsAlter';
|
|
||||||
export const EDIT_DATA_COMMAND_ID = 'dataExplorer.scriptAsEdit';
|
|
||||||
|
|
||||||
// Script as Create
|
|
||||||
CommandsRegistry.registerCommand({
|
|
||||||
id: SCRIPT_AS_CREATE_COMMAND_ID,
|
|
||||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
|
||||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
|
||||||
const oeShimService = accessor.get(IOEShimService);
|
|
||||||
const queryEditorService = accessor.get(IQueryEditorService);
|
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
|
||||||
const scriptingService = accessor.get(IScriptingService);
|
|
||||||
const errorMessageService = accessor.get(IErrorMessageService);
|
|
||||||
const progressService = accessor.get(IProgressService);
|
|
||||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
|
||||||
const baseContext: BaseActionContext = {
|
|
||||||
profile: profile,
|
|
||||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
|
||||||
};
|
|
||||||
const scriptCreateAction = new ScriptCreateAction(ScriptCreateAction.ID, ScriptCreateAction.LABEL,
|
|
||||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
|
||||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptCreateAction.run(baseContext));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Script as Delete
|
|
||||||
CommandsRegistry.registerCommand({
|
|
||||||
id: SCRIPT_AS_DELETE_COMMAND_ID,
|
|
||||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
|
||||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
|
||||||
const oeShimService = accessor.get(IOEShimService);
|
|
||||||
const queryEditorService = accessor.get(IQueryEditorService);
|
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
|
||||||
const scriptingService = accessor.get(IScriptingService);
|
|
||||||
const errorMessageService = accessor.get(IErrorMessageService);
|
|
||||||
const progressService = accessor.get(IProgressService);
|
|
||||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
|
||||||
const baseContext: BaseActionContext = {
|
|
||||||
profile: profile,
|
|
||||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
|
||||||
};
|
|
||||||
const scriptDeleteAction = new ScriptDeleteAction(ScriptDeleteAction.ID, ScriptDeleteAction.LABEL,
|
|
||||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
|
||||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptDeleteAction.run(baseContext));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Script as Select
|
|
||||||
CommandsRegistry.registerCommand({
|
|
||||||
id: SCRIPT_AS_SELECT_COMMAND_ID,
|
|
||||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
|
||||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
|
||||||
const oeShimService = accessor.get(IOEShimService);
|
|
||||||
const queryEditorService = accessor.get(IQueryEditorService);
|
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
|
||||||
const scriptingService = accessor.get(IScriptingService);
|
|
||||||
const progressService = accessor.get(IProgressService);
|
|
||||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
|
||||||
const baseContext: BaseActionContext = {
|
|
||||||
profile: profile,
|
|
||||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
|
||||||
};
|
|
||||||
const scriptSelectAction = new ScriptSelectAction(ScriptSelectAction.ID, ScriptSelectAction.LABEL,
|
|
||||||
queryEditorService, connectionManagementService, scriptingService);
|
|
||||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptSelectAction.run(baseContext));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Script as Execute
|
|
||||||
CommandsRegistry.registerCommand({
|
|
||||||
id: SCRIPT_AS_EXECUTE_COMMAND_ID,
|
|
||||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
|
||||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
|
||||||
const oeShimService = accessor.get(IOEShimService);
|
|
||||||
const queryEditorService = accessor.get(IQueryEditorService);
|
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
|
||||||
const scriptingService = accessor.get(IScriptingService);
|
|
||||||
const progressService = accessor.get(IProgressService);
|
|
||||||
const errorMessageService = accessor.get(IErrorMessageService);
|
|
||||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
|
||||||
const baseContext: BaseActionContext = {
|
|
||||||
profile: profile,
|
|
||||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
|
||||||
};
|
|
||||||
const scriptExecuteAction = new ScriptExecuteAction(ScriptExecuteAction.ID, ScriptExecuteAction.LABEL,
|
|
||||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
|
||||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptExecuteAction.run(baseContext));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Script as Alter
|
|
||||||
CommandsRegistry.registerCommand({
|
|
||||||
id: SCRIPT_AS_ALTER_COMMAND_ID,
|
|
||||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
|
||||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
|
||||||
const oeShimService = accessor.get(IOEShimService);
|
|
||||||
const queryEditorService = accessor.get(IQueryEditorService);
|
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
|
||||||
const scriptingService = accessor.get(IScriptingService);
|
|
||||||
const progressService = accessor.get(IProgressService);
|
|
||||||
const errorMessageService = accessor.get(IErrorMessageService);
|
|
||||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
|
||||||
const baseContext: BaseActionContext = {
|
|
||||||
profile: profile,
|
|
||||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
|
||||||
};
|
|
||||||
const scriptAlterAction = new ScriptAlterAction(ScriptAlterAction.ID, ScriptAlterAction.LABEL,
|
|
||||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
|
||||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptAlterAction.run(baseContext));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Edit Data
|
|
||||||
CommandsRegistry.registerCommand({
|
|
||||||
id: EDIT_DATA_COMMAND_ID,
|
|
||||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
|
||||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
|
||||||
const oeShimService = accessor.get(IOEShimService);
|
|
||||||
const queryEditorService = accessor.get(IQueryEditorService);
|
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
|
||||||
const scriptingService = accessor.get(IScriptingService);
|
|
||||||
const progressService = accessor.get(IProgressService);
|
|
||||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
|
||||||
const baseContext: BaseActionContext = {
|
|
||||||
profile: profile,
|
|
||||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
|
||||||
};
|
|
||||||
const editDataAction = new EditDataAction(EditDataAction.ID, EditDataAction.LABEL,
|
|
||||||
queryEditorService, connectionManagementService, scriptingService);
|
|
||||||
return progressService.withProgress({ location: VIEWLET_ID }, () => editDataAction.run(baseContext));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -304,40 +304,6 @@ export class RecentConnectionsFilterAction extends Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NewQueryAction extends Action {
|
|
||||||
public static ID = 'registeredServers.newQuery';
|
|
||||||
public static LABEL = localize('registeredServers.newQuery', "New Query");
|
|
||||||
private _connectionProfile: IConnectionProfile;
|
|
||||||
get connectionProfile(): IConnectionProfile {
|
|
||||||
return this._connectionProfile;
|
|
||||||
}
|
|
||||||
set connectionProfile(profile: IConnectionProfile) {
|
|
||||||
this._connectionProfile = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
id: string,
|
|
||||||
label: string,
|
|
||||||
@IQueryEditorService private queryEditorService: IQueryEditorService,
|
|
||||||
@IConnectionManagementService private connectionManagementService: IConnectionManagementService,
|
|
||||||
@IObjectExplorerService protected _objectExplorerService: IObjectExplorerService,
|
|
||||||
@IEditorService protected _workbenchEditorService: IEditorService,
|
|
||||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService
|
|
||||||
) {
|
|
||||||
super(id, label);
|
|
||||||
this.class = 'extension-action update';
|
|
||||||
}
|
|
||||||
|
|
||||||
public run(actionContext: ObjectExplorerActionsContext): Promise<boolean> {
|
|
||||||
if (actionContext instanceof ObjectExplorerActionsContext) {
|
|
||||||
this._connectionProfile = new ConnectionProfile(this._capabilitiesService, actionContext.connectionProfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskUtilities.newQuery(this._connectionProfile, this.connectionManagementService, this.queryEditorService, this._objectExplorerService, this._workbenchEditorService);
|
|
||||||
return Promise.resolve(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions to delete a server/group
|
* Actions to delete a server/group
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,14 +3,11 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { localize } from 'vs/nls';
|
|
||||||
import { Action } from 'vs/base/common/actions';
|
|
||||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||||
import { ExecuteCommandAction } from 'vs/platform/actions/common/actions';
|
import { ExecuteCommandAction } from 'vs/platform/actions/common/actions';
|
||||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
|
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import { IConnectionManagementService, IConnectionCompletionOptions } from 'sql/platform/connection/common/connectionManagement';
|
|
||||||
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
||||||
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
||||||
import { TreeSelectionHandler } from 'sql/workbench/parts/objectExplorer/browser/treeSelectionHandler';
|
import { TreeSelectionHandler } from 'sql/workbench/parts/objectExplorer/browser/treeSelectionHandler';
|
||||||
@@ -68,83 +65,3 @@ export class OEAction extends ExecuteCommandAction {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ManageConnectionAction extends Action {
|
|
||||||
public static ID = 'objectExplorer.manage';
|
|
||||||
public static LABEL = localize('ManageAction', "Manage");
|
|
||||||
|
|
||||||
private _treeSelectionHandler: TreeSelectionHandler;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
id: string,
|
|
||||||
label: string,
|
|
||||||
private _tree: ITree,
|
|
||||||
@IConnectionManagementService protected _connectionManagementService: IConnectionManagementService,
|
|
||||||
@ICapabilitiesService protected _capabilitiesService: ICapabilitiesService,
|
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
|
||||||
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService
|
|
||||||
) {
|
|
||||||
super(id, label);
|
|
||||||
}
|
|
||||||
|
|
||||||
run(actionContext: ObjectExplorerActionsContext): Promise<any> {
|
|
||||||
this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler);
|
|
||||||
this._treeSelectionHandler.onTreeActionStateChange(true);
|
|
||||||
let self = this;
|
|
||||||
let promise = new Promise<boolean>((resolve, reject) => {
|
|
||||||
self.doManage(actionContext).then((success) => {
|
|
||||||
self.done();
|
|
||||||
resolve(success);
|
|
||||||
}, error => {
|
|
||||||
self.done();
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async doManage(actionContext: ObjectExplorerActionsContext): Promise<boolean> {
|
|
||||||
let treeNode: TreeNode = undefined;
|
|
||||||
let connectionProfile: IConnectionProfile = undefined;
|
|
||||||
if (actionContext instanceof ObjectExplorerActionsContext) {
|
|
||||||
// Must use a real connection profile for this action due to lookup
|
|
||||||
connectionProfile = ConnectionProfile.fromIConnectionProfile(this._capabilitiesService, actionContext.connectionProfile);
|
|
||||||
if (!actionContext.isConnectionNode) {
|
|
||||||
treeNode = await getTreeNode(actionContext, this._objectExplorerService);
|
|
||||||
if (TreeUpdateUtils.isDatabaseNode(treeNode)) {
|
|
||||||
connectionProfile = TreeUpdateUtils.getConnectionProfile(treeNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!connectionProfile) {
|
|
||||||
// This should never happen. There should be always a valid connection if the manage action is called for
|
|
||||||
// an OE node or a database node
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let options: IConnectionCompletionOptions = {
|
|
||||||
params: undefined,
|
|
||||||
saveTheConnection: false,
|
|
||||||
showConnectionDialogOnError: true,
|
|
||||||
showDashboard: true,
|
|
||||||
showFirewallRuleOnError: true
|
|
||||||
};
|
|
||||||
|
|
||||||
// If it's a database node just open a database connection and open dashboard,
|
|
||||||
// the node is already from an open OE session we don't need to create new session
|
|
||||||
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
|
|
||||||
return this._connectionManagementService.showDashboard(connectionProfile);
|
|
||||||
} else {
|
|
||||||
return TreeUpdateUtils.connectAndCreateOeSession(connectionProfile, options, this._connectionManagementService, this._objectExplorerService, this._tree);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private done() {
|
|
||||||
this._treeSelectionHandler.onTreeActionStateChange(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose(): void {
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
DeleteConnectionAction, RefreshAction, EditServerGroupAction
|
DeleteConnectionAction, RefreshAction, EditServerGroupAction
|
||||||
} from 'sql/workbench/parts/objectExplorer/browser/connectionTreeAction';
|
} from 'sql/workbench/parts/objectExplorer/browser/connectionTreeAction';
|
||||||
import {
|
import {
|
||||||
ManageConnectionAction, OEAction
|
OEAction
|
||||||
} from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
|
} from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
|
||||||
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
||||||
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
||||||
@@ -23,12 +23,10 @@ import { ConnectionProfile } from 'sql/platform/connection/common/connectionProf
|
|||||||
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
||||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { MenuId, IMenuService } from 'vs/platform/actions/common/actions';
|
import { MenuId, IMenuService } from 'vs/platform/actions/common/actions';
|
||||||
import { NewQueryAction, BackupAction, RestoreAction } from 'sql/workbench/common/actions';
|
import { BackupAction, RestoreAction } from 'sql/workbench/common/actions';
|
||||||
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
|
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
|
||||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
|
||||||
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
|
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
|
||||||
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
||||||
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
|
|
||||||
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
||||||
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||||
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
|
import { NewNotebookAction } from 'sql/workbench/parts/notebook/browser/notebookActions';
|
||||||
@@ -42,8 +40,6 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||||
@IQueryManagementService private _queryManagementService: IQueryManagementService,
|
@IQueryManagementService private _queryManagementService: IQueryManagementService,
|
||||||
@IScriptingService private _scriptingService: IScriptingService,
|
|
||||||
@IContextMenuService private contextMenuService: IContextMenuService,
|
|
||||||
@IMenuService private menuService: IMenuService,
|
@IMenuService private menuService: IMenuService,
|
||||||
@IContextKeyService private _contextKeyService: IContextKeyService
|
@IContextKeyService private _contextKeyService: IContextKeyService
|
||||||
) {
|
) {
|
||||||
@@ -111,7 +107,6 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
|
|
||||||
private getBuiltinConnectionActions(context: ObjectExplorerContext): IAction[] {
|
private getBuiltinConnectionActions(context: ObjectExplorerContext): IAction[] {
|
||||||
let actions: IAction[] = [];
|
let actions: IAction[] = [];
|
||||||
actions.push(this._instantiationService.createInstance(ManageConnectionAction, ManageConnectionAction.ID, ManageConnectionAction.LABEL, context.tree));
|
|
||||||
this.addNewQueryNotebookActions(context, actions);
|
this.addNewQueryNotebookActions(context, actions);
|
||||||
|
|
||||||
if (this._connectionManagementService.isProfileConnected(context.profile)) {
|
if (this._connectionManagementService.isProfileConnected(context.profile)) {
|
||||||
@@ -168,7 +163,6 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
if (TreeUpdateUtils.isDatabaseNode(treeNode)) {
|
if (TreeUpdateUtils.isDatabaseNode(treeNode)) {
|
||||||
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
|
if (TreeUpdateUtils.isAvailableDatabaseNode(treeNode)) {
|
||||||
isAvailableDatabaseNode = true;
|
isAvailableDatabaseNode = true;
|
||||||
actions.push(this._instantiationService.createInstance(ManageConnectionAction, ManageConnectionAction.ID, ManageConnectionAction.LABEL, context.tree));
|
|
||||||
this.addNewQueryNotebookActions(context, actions);
|
this.addNewQueryNotebookActions(context, actions);
|
||||||
} else {
|
} else {
|
||||||
return actions;
|
return actions;
|
||||||
@@ -193,7 +187,6 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
|
|
||||||
private addNewQueryNotebookActions(context: ObjectExplorerContext, actions: IAction[]): void {
|
private addNewQueryNotebookActions(context: ObjectExplorerContext, actions: IAction[]): void {
|
||||||
if (this._queryManagementService.isProviderRegistered(context.profile.providerName)) {
|
if (this._queryManagementService.isProviderRegistered(context.profile.providerName)) {
|
||||||
actions.push(this._instantiationService.createInstance(OEAction, NewQueryAction.ID, NewQueryAction.LABEL));
|
|
||||||
// Workaround for #6397 right-click and run New Notebook connects to wrong server. Use notebook action instead of generic command action
|
// Workaround for #6397 right-click and run New Notebook connects to wrong server. Use notebook action instead of generic command action
|
||||||
let notebookAction = this._instantiationService.createInstance(NewNotebookAction, NewNotebookAction.ID, NewNotebookAction.LABEL);
|
let notebookAction = this._instantiationService.createInstance(NewNotebookAction, NewNotebookAction.ID, NewNotebookAction.LABEL);
|
||||||
actions.push(notebookAction);
|
actions.push(notebookAction);
|
||||||
|
|||||||
@@ -24,12 +24,15 @@ import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
|||||||
import { ServerTreeDataSource } from 'sql/workbench/parts/objectExplorer/browser/serverTreeDataSource';
|
import { ServerTreeDataSource } from 'sql/workbench/parts/objectExplorer/browser/serverTreeDataSource';
|
||||||
import { Emitter } from 'vs/base/common/event';
|
import { Emitter } from 'vs/base/common/event';
|
||||||
import Severity from 'vs/base/common/severity';
|
import Severity from 'vs/base/common/severity';
|
||||||
import { ObjectExplorerActionsContext, ManageConnectionAction } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
|
import { ObjectExplorerActionsContext } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
|
||||||
import { IConnectionResult, IConnectionParams } from 'sql/platform/connection/common/connectionManagement';
|
import { IConnectionResult, IConnectionParams } from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { TreeSelectionHandler } from 'sql/workbench/parts/objectExplorer/browser/treeSelectionHandler';
|
import { TreeSelectionHandler } from 'sql/workbench/parts/objectExplorer/browser/treeSelectionHandler';
|
||||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||||
import { UNSAVED_GROUP_ID, mssqlProviderName } from 'sql/platform/connection/common/constants';
|
import { UNSAVED_GROUP_ID, mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||||
import { $ } from 'vs/base/browser/dom';
|
import { $ } from 'vs/base/browser/dom';
|
||||||
|
import { OEManageConnectionAction } from 'sql/workbench/parts/dashboard/browser/dashboardActions';
|
||||||
|
import { IViewsService, IView, ViewContainer, IViewDescriptorCollection } from 'vs/workbench/common/views';
|
||||||
|
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
|
||||||
suite('SQL Connection Tree Action tests', () => {
|
suite('SQL Connection Tree Action tests', () => {
|
||||||
let errorMessageService: TypeMoq.Mock<TestErrorMessageService>;
|
let errorMessageService: TypeMoq.Mock<TestErrorMessageService>;
|
||||||
@@ -103,8 +106,21 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
return treeSelectionMock.object;
|
return treeSelectionMock.object;
|
||||||
});
|
});
|
||||||
|
|
||||||
let manageConnectionAction: ManageConnectionAction = new ManageConnectionAction(ManageConnectionAction.ID,
|
const viewsService = new class implements IViewsService {
|
||||||
ManageConnectionAction.LABEL, undefined, connectionManagementService.object, capabilitiesService, instantiationService.object, objectExplorerService.object);
|
_serviceBrand: ServiceIdentifier<any>;
|
||||||
|
openView(id: string, focus?: boolean): Promise<IView> {
|
||||||
|
return Promise.resolve({
|
||||||
|
id: '',
|
||||||
|
serversTree: undefined
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getViewDescriptors(container: ViewContainer): IViewDescriptorCollection {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let manageConnectionAction: OEManageConnectionAction = new OEManageConnectionAction(OEManageConnectionAction.ID,
|
||||||
|
OEManageConnectionAction.LABEL, connectionManagementService.object, capabilitiesService, instantiationService.object, objectExplorerService.object, viewsService);
|
||||||
|
|
||||||
let actionContext = new ObjectExplorerActionsContext();
|
let actionContext = new ObjectExplorerActionsContext();
|
||||||
actionContext.connectionProfile = connection.toIConnectionProfile();
|
actionContext.connectionProfile = connection.toIConnectionProfile();
|
||||||
@@ -141,8 +157,8 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
return treeSelectionMock.object;
|
return treeSelectionMock.object;
|
||||||
});
|
});
|
||||||
|
|
||||||
let manageConnectionAction: ManageConnectionAction = new ManageConnectionAction(ManageConnectionAction.ID,
|
let manageConnectionAction: OEManageConnectionAction = new OEManageConnectionAction(OEManageConnectionAction.ID,
|
||||||
ManageConnectionAction.LABEL, undefined, connectionManagementService.object, capabilitiesService, instantiationService.object, objectExplorerService.object);
|
OEManageConnectionAction.LABEL, connectionManagementService.object, capabilitiesService, instantiationService.object, objectExplorerService.object, undefined);
|
||||||
|
|
||||||
let actionContext = new ObjectExplorerActionsContext();
|
let actionContext = new ObjectExplorerActionsContext();
|
||||||
actionContext.connectionProfile = connection.toIConnectionProfile();
|
actionContext.connectionProfile = connection.toIConnectionProfile();
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes';
|
|||||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||||
import { ContextKeyExpr, ContextKeyEqualsExpr } from 'vs/platform/contextkey/common/contextkey';
|
import { ContextKeyExpr, ContextKeyEqualsExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { isMacintosh } from 'vs/base/common/platform';
|
|
||||||
|
|
||||||
import { QueryEditor } from 'sql/workbench/parts/query/browser/queryEditor';
|
import { QueryEditor } from 'sql/workbench/parts/query/browser/queryEditor';
|
||||||
import { QueryResultsEditor } from 'sql/workbench/parts/query/browser/queryResultsEditor';
|
import { QueryResultsEditor } from 'sql/workbench/parts/query/browser/queryResultsEditor';
|
||||||
@@ -34,6 +33,9 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } fr
|
|||||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||||
import { TimeElapsedStatusBarContributions, RowCountStatusBarContributions, QueryStatusStatusBarContributions } from 'sql/workbench/parts/query/browser/statusBarItems';
|
import { TimeElapsedStatusBarContributions, RowCountStatusBarContributions, QueryStatusStatusBarContributions } from 'sql/workbench/parts/query/browser/statusBarItems';
|
||||||
import { SqlFlavorStatusbarItem } from 'sql/workbench/parts/query/browser/flavorStatus';
|
import { SqlFlavorStatusbarItem } from 'sql/workbench/parts/query/browser/flavorStatus';
|
||||||
|
import { NewQueryTask, OE_NEW_QUERY_ACTION_ID, DE_NEW_QUERY_COMMAND_ID } from 'sql/workbench/parts/query/browser/queryActions';
|
||||||
|
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
|
||||||
|
import { MssqlNodeContext } from 'sql/workbench/parts/dataExplorer/common/mssqlNodeContext';
|
||||||
|
|
||||||
const gridCommandsWeightBonus = 100; // give our commands a little bit more weight over other default list/tree commands
|
const gridCommandsWeightBonus = 100; // give our commands a little bit more weight over other default list/tree commands
|
||||||
|
|
||||||
@@ -61,7 +63,30 @@ const queryEditorDescriptor = new EditorDescriptor(
|
|||||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||||
.registerEditor(queryEditorDescriptor, [new SyncDescriptor(QueryInput)]);
|
.registerEditor(queryEditorDescriptor, [new SyncDescriptor(QueryInput)]);
|
||||||
|
|
||||||
let actionRegistry = <IWorkbenchActionRegistry>Registry.as(Extensions.WorkbenchActions);
|
const actionRegistry = <IWorkbenchActionRegistry>Registry.as(Extensions.WorkbenchActions);
|
||||||
|
|
||||||
|
new NewQueryTask().registerTask();
|
||||||
|
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||||
|
group: '0_query',
|
||||||
|
order: 0,
|
||||||
|
command: {
|
||||||
|
id: OE_NEW_QUERY_ACTION_ID,
|
||||||
|
title: localize('newQuery', "New Query")
|
||||||
|
},
|
||||||
|
when: ContextKeyExpr.or(ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.NodeType.isEqualTo('Server')), ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.NodeType.isEqualTo('Database')))
|
||||||
|
});
|
||||||
|
|
||||||
|
// New Query
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
|
group: '0_query',
|
||||||
|
order: 0,
|
||||||
|
command: {
|
||||||
|
id: DE_NEW_QUERY_COMMAND_ID,
|
||||||
|
title: localize('newQuery', "New Query")
|
||||||
|
},
|
||||||
|
when: MssqlNodeContext.IsDatabaseOrServer
|
||||||
|
});
|
||||||
|
|
||||||
// Query Actions
|
// Query Actions
|
||||||
actionRegistry.registerWorkbenchAction(
|
actionRegistry.registerWorkbenchAction(
|
||||||
@@ -74,15 +99,12 @@ actionRegistry.registerWorkbenchAction(
|
|||||||
RunQueryKeyboardAction.LABEL
|
RunQueryKeyboardAction.LABEL
|
||||||
);
|
);
|
||||||
|
|
||||||
// Touch Bar
|
// Only show Run Query if the active editor is a query editor.
|
||||||
if (isMacintosh) {
|
MenuRegistry.appendMenuItem(MenuId.TouchBarContext, {
|
||||||
// Only show Run Query if the active editor is a query editor.
|
command: { id: RunQueryKeyboardAction.ID, title: RunQueryKeyboardAction.LABEL },
|
||||||
MenuRegistry.appendMenuItem(MenuId.TouchBarContext, {
|
group: 'query',
|
||||||
command: { id: RunQueryKeyboardAction.ID, title: RunQueryKeyboardAction.LABEL },
|
when: ContextKeyEqualsExpr.create('activeEditor', 'workbench.editor.queryEditor')
|
||||||
group: 'query',
|
});
|
||||||
when: ContextKeyEqualsExpr.create('activeEditor', 'workbench.editor.queryEditor')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
actionRegistry.registerWorkbenchAction(
|
actionRegistry.registerWorkbenchAction(
|
||||||
new SyncActionDescriptor(
|
new SyncActionDescriptor(
|
||||||
@@ -260,7 +282,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Intellisense and other configuration options
|
// Intellisense and other configuration options
|
||||||
let registryProperties = {
|
const registryProperties = {
|
||||||
'sql.saveAsCsv.includeHeaders': {
|
'sql.saveAsCsv.includeHeaders': {
|
||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
'description': localize('sql.saveAsCsv.includeHeaders', "[Optional] When true, column headers are included when saving results as CSV"),
|
'description': localize('sql.saveAsCsv.includeHeaders', "[Optional] When true, column headers are included when saving results as CSV"),
|
||||||
@@ -480,7 +502,7 @@ let registryProperties = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Setup keybindings
|
// Setup keybindings
|
||||||
let initialShortcuts = [
|
const initialShortcuts = [
|
||||||
{ name: 'sp_help', primary: KeyMod.Alt + KeyCode.F2 },
|
{ name: 'sp_help', primary: KeyMod.Alt + KeyCode.F2 },
|
||||||
// Note: using Ctrl+Shift+N since Ctrl+N is used for "open editor at index" by default. This means it's different from SSMS
|
// Note: using Ctrl+Shift+N since Ctrl+N is used for "open editor at index" by default. This means it's different from SSMS
|
||||||
{ name: 'sp_who', primary: KeyMod.WinCtrl + KeyMod.Shift + KeyCode.KEY_1 },
|
{ name: 'sp_who', primary: KeyMod.WinCtrl + KeyMod.Shift + KeyCode.KEY_1 },
|
||||||
@@ -512,7 +534,7 @@ for (let i = 0; i < 9; i++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register the query-related configuration options
|
// Register the query-related configuration options
|
||||||
let configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigExtensions.Configuration);
|
const configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigExtensions.Configuration);
|
||||||
configurationRegistry.registerConfiguration({
|
configurationRegistry.registerConfiguration({
|
||||||
'id': 'sqlEditor',
|
'id': 'sqlEditor',
|
||||||
'title': 'SQL Editor',
|
'title': 'SQL Editor',
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
|
|||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
import { IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
|
||||||
import Severity from 'vs/base/common/severity';
|
import Severity from 'vs/base/common/severity';
|
||||||
import { append, $ } from 'vs/base/browser/dom';
|
import { append, $ } from 'vs/base/browser/dom';
|
||||||
|
|
||||||
@@ -21,13 +20,27 @@ import {
|
|||||||
IConnectionParams,
|
IConnectionParams,
|
||||||
INewConnectionParams,
|
INewConnectionParams,
|
||||||
ConnectionType,
|
ConnectionType,
|
||||||
RunQueryOnConnectionMode
|
RunQueryOnConnectionMode,
|
||||||
|
IConnectionCompletionOptions,
|
||||||
|
IConnectableInput
|
||||||
} from 'sql/platform/connection/common/connectionManagement';
|
} from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { QueryEditor } from 'sql/workbench/parts/query/browser/queryEditor';
|
import { QueryEditor } from 'sql/workbench/parts/query/browser/queryEditor';
|
||||||
import { IQueryModelService } from 'sql/platform/query/common/queryModel';
|
import { IQueryModelService } from 'sql/platform/query/common/queryModel';
|
||||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||||
import { attachEditableDropdownStyler, attachSelectBoxStyler } from 'sql/platform/theme/common/styler';
|
import { attachEditableDropdownStyler, attachSelectBoxStyler } from 'sql/platform/theme/common/styler';
|
||||||
import { Dropdown } from 'sql/base/parts/editableDropdown/browser/dropdown';
|
import { Dropdown } from 'sql/base/parts/editableDropdown/browser/dropdown';
|
||||||
|
import { Task } from 'sql/platform/tasks/browser/tasksRegistry';
|
||||||
|
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
||||||
|
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
|
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||||
|
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||||
|
import { getCurrentGlobalConnection } from 'sql/workbench/browser/taskUtilities';
|
||||||
|
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||||
|
import { OEAction } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
|
||||||
|
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||||
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,6 +111,83 @@ export abstract class QueryTaskbarAction extends Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function openNewQuery(accessor: ServicesAccessor, profile?: IConnectionProfile, initalContent?: string, onConnection?: RunQueryOnConnectionMode): Promise<void> {
|
||||||
|
const editorService = accessor.get(IEditorService);
|
||||||
|
const queryEditorService = accessor.get(IQueryEditorService);
|
||||||
|
const objectExplorerService = accessor.get(IObjectExplorerService);
|
||||||
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
|
if (!profile) {
|
||||||
|
profile = getCurrentGlobalConnection(objectExplorerService, connectionManagementService, editorService);
|
||||||
|
}
|
||||||
|
return queryEditorService.newSqlEditor(initalContent).then((owner: IConnectableInput) => {
|
||||||
|
// Connect our editor to the input connection
|
||||||
|
let options: IConnectionCompletionOptions = {
|
||||||
|
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: onConnection, input: owner },
|
||||||
|
saveTheConnection: false,
|
||||||
|
showDashboard: false,
|
||||||
|
showConnectionDialogOnError: true,
|
||||||
|
showFirewallRuleOnError: true
|
||||||
|
};
|
||||||
|
if (profile) {
|
||||||
|
return connectionManagementService.connect(profile, owner.uri, options).then();
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- actions
|
||||||
|
export class NewQueryTask extends Task {
|
||||||
|
public static ID = 'newQuery';
|
||||||
|
public static LABEL = nls.localize('newQueryTask.newQuery', "New Query");
|
||||||
|
public static ICON = 'new-query';
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
id: NewQueryTask.ID,
|
||||||
|
title: NewQueryTask.LABEL,
|
||||||
|
iconPath: undefined,
|
||||||
|
iconClass: NewQueryTask.ICON
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public runTask(accessor: ServicesAccessor, profile: IConnectionProfile): Promise<void> {
|
||||||
|
return openNewQuery(accessor, profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const OE_NEW_QUERY_ACTION_ID = 'objectExplorer.newQuery';
|
||||||
|
|
||||||
|
CommandsRegistry.registerCommand(OE_NEW_QUERY_ACTION_ID, (accessor: ServicesAccessor, actionContext: any) => {
|
||||||
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
|
return instantiationService.createInstance(OEAction, NewQueryTask.ID, NewQueryTask.LABEL).run(actionContext);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const DE_NEW_QUERY_COMMAND_ID = 'dataExplorer.newQuery';
|
||||||
|
|
||||||
|
// New Query
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: DE_NEW_QUERY_COMMAND_ID,
|
||||||
|
handler: (accessor, args: TreeViewItemHandleArg) => {
|
||||||
|
if (args.$treeItem) {
|
||||||
|
const queryEditorService = accessor.get(IQueryEditorService);
|
||||||
|
const connectionService = accessor.get(IConnectionManagementService);
|
||||||
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
|
return queryEditorService.newSqlEditor().then((owner: IConnectableInput) => {
|
||||||
|
// Connect our editor to the input connection
|
||||||
|
let options: IConnectionCompletionOptions = {
|
||||||
|
params: { connectionType: ConnectionType.editor, input: owner },
|
||||||
|
saveTheConnection: false,
|
||||||
|
showDashboard: false,
|
||||||
|
showConnectionDialogOnError: true,
|
||||||
|
showFirewallRuleOnError: true
|
||||||
|
};
|
||||||
|
return connectionService.connect(new ConnectionProfile(capabilitiesService, args.$treeItem.payload), owner.uri, options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action class that runs a query in the active SQL text document.
|
* Action class that runs a query in the active SQL text document.
|
||||||
*/
|
*/
|
||||||
@@ -109,8 +199,7 @@ export class RunQueryAction extends QueryTaskbarAction {
|
|||||||
constructor(
|
constructor(
|
||||||
editor: QueryEditor,
|
editor: QueryEditor,
|
||||||
@IQueryModelService protected readonly queryModelService: IQueryModelService,
|
@IQueryModelService protected readonly queryModelService: IQueryModelService,
|
||||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
@IConnectionManagementService connectionManagementService: IConnectionManagementService
|
||||||
@IExtensionTipsService private readonly extensionTipsService: IExtensionTipsService
|
|
||||||
) {
|
) {
|
||||||
super(connectionManagementService, editor, RunQueryAction.ID, RunQueryAction.EnabledClass);
|
super(connectionManagementService, editor, RunQueryAction.ID, RunQueryAction.EnabledClass);
|
||||||
this.label = nls.localize('runQueryLabel', "Run");
|
this.label = nls.localize('runQueryLabel', "Run");
|
||||||
@@ -480,7 +569,6 @@ export class ListDatabasesActionItem implements IActionViewItem {
|
|||||||
|
|
||||||
public actionRunner: IActionRunner;
|
public actionRunner: IActionRunner;
|
||||||
private _toDispose: IDisposable[];
|
private _toDispose: IDisposable[];
|
||||||
private _context: any;
|
|
||||||
private _currentDatabaseName: string;
|
private _currentDatabaseName: string;
|
||||||
private _isConnected: boolean;
|
private _isConnected: boolean;
|
||||||
private _databaseListDropdown: HTMLElement;
|
private _databaseListDropdown: HTMLElement;
|
||||||
@@ -537,7 +625,6 @@ export class ListDatabasesActionItem implements IActionViewItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setActionContext(context: any): void {
|
public setActionContext(context: any): void {
|
||||||
this._context = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public isEnabled(): boolean {
|
public isEnabled(): boolean {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
|
|
||||||
test('setClass sets child CSS class correctly', (done) => {
|
test('setClass sets child CSS class correctly', (done) => {
|
||||||
// If I create a RunQueryAction
|
// If I create a RunQueryAction
|
||||||
let queryAction: QueryTaskbarAction = new RunQueryAction(undefined, undefined, undefined, undefined);
|
let queryAction: QueryTaskbarAction = new RunQueryAction(undefined, undefined, undefined);
|
||||||
|
|
||||||
// "class should automatically get set to include the base class and the RunQueryAction class
|
// "class should automatically get set to include the base class and the RunQueryAction class
|
||||||
let className = RunQueryAction.EnabledClass;
|
let className = RunQueryAction.EnabledClass;
|
||||||
@@ -93,7 +93,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
editor.setup(x => x.input).returns(() => testQueryInput.object);
|
editor.setup(x => x.input).returns(() => testQueryInput.object);
|
||||||
|
|
||||||
// If I create a QueryTaskbarAction and I pass a non-connected editor to _getConnectedQueryEditorUri
|
// If I create a QueryTaskbarAction and I pass a non-connected editor to _getConnectedQueryEditorUri
|
||||||
let queryAction: QueryTaskbarAction = new RunQueryAction(undefined, undefined, connectionManagementService.object, undefined);
|
let queryAction: QueryTaskbarAction = new RunQueryAction(undefined, undefined, connectionManagementService.object);
|
||||||
let connected: boolean = queryAction.isConnected(editor.object);
|
let connected: boolean = queryAction.isConnected(editor.object);
|
||||||
|
|
||||||
// I should get an unconnected state
|
// I should get an unconnected state
|
||||||
@@ -136,7 +136,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// If I call run on RunQueryAction when I am not connected
|
// If I call run on RunQueryAction when I am not connected
|
||||||
let queryAction: RunQueryAction = new RunQueryAction(editor.object, queryModelService.object, connectionManagementService.object, undefined);
|
let queryAction: RunQueryAction = new RunQueryAction(editor.object, queryModelService.object, connectionManagementService.object);
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
calledRunQueryOnInput = false;
|
calledRunQueryOnInput = false;
|
||||||
queryAction.run();
|
queryAction.run();
|
||||||
@@ -195,7 +195,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
let queryModelService = TypeMoq.Mock.ofType(QueryModelService, TypeMoq.MockBehavior.Loose);
|
let queryModelService = TypeMoq.Mock.ofType(QueryModelService, TypeMoq.MockBehavior.Loose);
|
||||||
|
|
||||||
// If I call run on RunQueryAction when I have a non empty selection
|
// If I call run on RunQueryAction when I have a non empty selection
|
||||||
let queryAction: RunQueryAction = new RunQueryAction(queryEditor.object, queryModelService.object, connectionManagementService.object, undefined);
|
let queryAction: RunQueryAction = new RunQueryAction(queryEditor.object, queryModelService.object, connectionManagementService.object);
|
||||||
isSelectionEmpty = false;
|
isSelectionEmpty = false;
|
||||||
queryAction.run();
|
queryAction.run();
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
/// End Setup Test ///
|
/// End Setup Test ///
|
||||||
|
|
||||||
////// If I call run on RunQueryAction while disconnected and with an undefined selection
|
////// If I call run on RunQueryAction while disconnected and with an undefined selection
|
||||||
let queryAction: RunQueryAction = new RunQueryAction(queryEditor.object, undefined, connectionManagementService.object, undefined);
|
let queryAction: RunQueryAction = new RunQueryAction(queryEditor.object, undefined, connectionManagementService.object);
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
selectionToReturnInGetSelection = undefined;
|
selectionToReturnInGetSelection = undefined;
|
||||||
queryAction.run();
|
queryAction.run();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
return new Promise((resolve) => resolve(mockEditor));
|
return new Promise((resolve) => resolve(mockEditor));
|
||||||
});
|
});
|
||||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((input) => {
|
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((input) => {
|
||||||
return new Promise((resolve) => resolve(new RunQueryAction(undefined, undefined, undefined, undefined)));
|
return new Promise((resolve) => resolve(new RunQueryAction(undefined, undefined, undefined)));
|
||||||
});
|
});
|
||||||
// Setup hook to capture calls to create the listDatabase action
|
// Setup hook to capture calls to create the listDatabase action
|
||||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
|
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
|
||||||
@@ -64,7 +64,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Default
|
// Default
|
||||||
return new RunQueryAction(undefined, undefined, undefined, undefined);
|
return new RunQueryAction(undefined, undefined, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mock EditorDescriptorService to give us a mock editor description
|
// Mock EditorDescriptorService to give us a mock editor description
|
||||||
@@ -269,7 +269,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
|
|
||||||
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((input) => {
|
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((input) => {
|
||||||
// Default
|
// Default
|
||||||
return new RunQueryAction(undefined, undefined, undefined, undefined);
|
return new RunQueryAction(undefined, undefined, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Setup hook to capture calls to create the listDatabase action
|
// Setup hook to capture calls to create the listDatabase action
|
||||||
@@ -280,7 +280,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
// Default
|
// Default
|
||||||
return new RunQueryAction(undefined, undefined, undefined, undefined);
|
return new RunQueryAction(undefined, undefined, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
let fileInput = new UntitledEditorInput(URI.parse('file://testUri'), false, '', '', '', instantiationService.object, undefined, undefined);
|
let fileInput = new UntitledEditorInput(URI.parse('file://testUri'), false, '', '', '', instantiationService.object, undefined, undefined);
|
||||||
|
|||||||
@@ -3,23 +3,90 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import {
|
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||||
SCRIPT_AS_SELECT_COMMAND_ID, EDIT_DATA_COMMAND_ID, SCRIPT_AS_CREATE_COMMAND_ID,
|
import * as commands from 'sql/workbench/parts/scripting/electron-browser/scriptingActions';
|
||||||
SCRIPT_AS_EXECUTE_COMMAND_ID, SCRIPT_AS_ALTER_COMMAND_ID, SCRIPT_AS_DELETE_COMMAND_ID,
|
import { MssqlNodeContext } from 'sql/workbench/parts/dataExplorer/common/mssqlNodeContext';
|
||||||
REFRESH_OE_COMMAND_ID
|
|
||||||
} from 'sql/workbench/parts/objectExplorer/electron-browser/objectExplorerScriptingActions';
|
|
||||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
|
|
||||||
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
|
|
||||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||||
|
import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/treeNodeContextKey';
|
||||||
|
import { ConnectionContextKey } from 'sql/workbench/parts/connection/common/connectionContextKey';
|
||||||
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
||||||
|
|
||||||
|
//#region -- Data Explorer
|
||||||
|
// Script as Create
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
|
group: 'connection',
|
||||||
|
order: 3,
|
||||||
|
command: {
|
||||||
|
id: commands.SCRIPT_AS_CREATE_COMMAND_ID,
|
||||||
|
title: localize('scriptAsCreate', "Script as Create")
|
||||||
|
},
|
||||||
|
when: MssqlNodeContext.CanScriptAsCreateOrDelete
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script as Delete
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
|
group: 'connection',
|
||||||
|
order: 4,
|
||||||
|
command: {
|
||||||
|
id: commands.SCRIPT_AS_DELETE_COMMAND_ID,
|
||||||
|
title: localize('scriptAsDelete', "Script as Drop")
|
||||||
|
},
|
||||||
|
when: MssqlNodeContext.CanScriptAsCreateOrDelete
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script as Select
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
|
group: 'connection',
|
||||||
|
order: 1,
|
||||||
|
command: {
|
||||||
|
id: commands.SCRIPT_AS_SELECT_COMMAND_ID,
|
||||||
|
title: localize('scriptAsSelect', "Select Top 1000")
|
||||||
|
},
|
||||||
|
when: MssqlNodeContext.CanScriptAsSelect
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script as Execute
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
|
group: 'connection',
|
||||||
|
order: 5,
|
||||||
|
command: {
|
||||||
|
id: commands.SCRIPT_AS_EXECUTE_COMMAND_ID,
|
||||||
|
title: localize('scriptAsExecute', "Script as Execute")
|
||||||
|
},
|
||||||
|
when: MssqlNodeContext.CanScriptAsExecute
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script as Alter
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
|
group: 'connection',
|
||||||
|
order: 5,
|
||||||
|
command: {
|
||||||
|
id: commands.SCRIPT_AS_ALTER_COMMAND_ID,
|
||||||
|
title: localize('scriptAsAlter', "Script as Alter")
|
||||||
|
},
|
||||||
|
when: MssqlNodeContext.CanScriptAsAlter
|
||||||
|
});
|
||||||
|
|
||||||
|
// Edit Data
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||||
|
group: 'connection',
|
||||||
|
order: 2,
|
||||||
|
command: {
|
||||||
|
id: commands.EDIT_DATA_COMMAND_ID,
|
||||||
|
title: localize('editData', "Edit Data")
|
||||||
|
},
|
||||||
|
when: MssqlNodeContext.CanEditData
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region -- Object Explorer
|
||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||||
group: 'scripting',
|
group: 'scripting',
|
||||||
order: 1,
|
order: 1,
|
||||||
command: {
|
command: {
|
||||||
id: SCRIPT_AS_SELECT_COMMAND_ID,
|
id: commands.OE_SCRIPT_AS_SELECT_COMMAND_ID,
|
||||||
title: localize('scriptSelect', "Select Top 1000")
|
title: localize('scriptSelect', "Select Top 1000")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.or(TreeNodeContextKey.NodeType.isEqualTo('Table'), TreeNodeContextKey.NodeType.isEqualTo('View'))
|
when: ContextKeyExpr.or(TreeNodeContextKey.NodeType.isEqualTo('Table'), TreeNodeContextKey.NodeType.isEqualTo('View'))
|
||||||
@@ -29,7 +96,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
group: 'scripting',
|
group: 'scripting',
|
||||||
order: 2,
|
order: 2,
|
||||||
command: {
|
command: {
|
||||||
id: EDIT_DATA_COMMAND_ID,
|
id: commands.OE_EDIT_DATA_COMMAND_ID,
|
||||||
title: localize('editData', "Edit Data")
|
title: localize('editData', "Edit Data")
|
||||||
},
|
},
|
||||||
when: TreeNodeContextKey.NodeType.isEqualTo('Table')
|
when: TreeNodeContextKey.NodeType.isEqualTo('Table')
|
||||||
@@ -39,7 +106,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
group: 'scripting',
|
group: 'scripting',
|
||||||
order: 3,
|
order: 3,
|
||||||
command: {
|
command: {
|
||||||
id: SCRIPT_AS_CREATE_COMMAND_ID,
|
id: commands.OE_SCRIPT_AS_CREATE_COMMAND_ID,
|
||||||
title: localize('scriptCreate', "Script as Create")
|
title: localize('scriptCreate', "Script as Create")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.or(
|
when: ContextKeyExpr.or(
|
||||||
@@ -59,7 +126,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
group: 'scripting',
|
group: 'scripting',
|
||||||
order: 6,
|
order: 6,
|
||||||
command: {
|
command: {
|
||||||
id: SCRIPT_AS_EXECUTE_COMMAND_ID,
|
id: commands.OE_SCRIPT_AS_EXECUTE_COMMAND_ID,
|
||||||
title: localize('scriptExecute', "Script as Execute")
|
title: localize('scriptExecute', "Script as Execute")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.and(ConnectionContextKey.Provider.isEqualTo('MSSQL'), TreeNodeContextKey.NodeType.isEqualTo('StoredProcedure'))
|
when: ContextKeyExpr.and(ConnectionContextKey.Provider.isEqualTo('MSSQL'), TreeNodeContextKey.NodeType.isEqualTo('StoredProcedure'))
|
||||||
@@ -69,7 +136,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
group: 'scripting',
|
group: 'scripting',
|
||||||
order: 5,
|
order: 5,
|
||||||
command: {
|
command: {
|
||||||
id: SCRIPT_AS_ALTER_COMMAND_ID,
|
id: commands.OE_SCRIPT_AS_ALTER_COMMAND_ID,
|
||||||
title: localize('scriptAlter', "Script as Alter")
|
title: localize('scriptAlter', "Script as Alter")
|
||||||
},
|
},
|
||||||
when:
|
when:
|
||||||
@@ -99,7 +166,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
group: 'scripting',
|
group: 'scripting',
|
||||||
order: 4,
|
order: 4,
|
||||||
command: {
|
command: {
|
||||||
id: SCRIPT_AS_DELETE_COMMAND_ID,
|
id: commands.OE_SCRIPT_AS_DELETE_COMMAND_ID,
|
||||||
title: localize('scriptDelete', "Script as Drop")
|
title: localize('scriptDelete', "Script as Drop")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.or(
|
when: ContextKeyExpr.or(
|
||||||
@@ -119,7 +186,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
group: 'scripting',
|
group: 'scripting',
|
||||||
order: 7,
|
order: 7,
|
||||||
command: {
|
command: {
|
||||||
id: REFRESH_OE_COMMAND_ID,
|
id: commands.OE_REFRESH_COMMAND_ID,
|
||||||
title: localize('refreshNode', "Refresh")
|
title: localize('refreshNode', "Refresh")
|
||||||
},
|
},
|
||||||
when: ContextKeyExpr.or(
|
when: ContextKeyExpr.or(
|
||||||
@@ -134,3 +201,5 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
|||||||
TreeNodeContextKey.NodeType.isEqualTo(NodeType.ScalarValuedFunction),
|
TreeNodeContextKey.NodeType.isEqualTo(NodeType.ScalarValuedFunction),
|
||||||
TreeNodeContextKey.NodeType.isEqualTo(NodeType.TableValuedFunction))
|
TreeNodeContextKey.NodeType.isEqualTo(NodeType.TableValuedFunction))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//#endregion
|
||||||
@@ -3,31 +3,179 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { ScriptSelectAction, EditDataAction, ScriptCreateAction, ScriptExecuteAction, ScriptAlterAction, ScriptDeleteAction } from 'sql/workbench/electron-browser/scriptingActions';
|
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
|
||||||
import { TreeSelectionHandler } from 'sql/workbench/parts/objectExplorer/browser/treeSelectionHandler';
|
|
||||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
|
||||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
|
||||||
import { ObjectExplorerActionsContext, getTreeNode } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
|
|
||||||
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
|
||||||
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
|
||||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
|
||||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||||
|
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||||
|
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
|
||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
|
import { IOEShimService } from 'sql/workbench/parts/objectExplorer/common/objectExplorerViewTreeShim';
|
||||||
|
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||||
|
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||||
|
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||||
|
import { BaseActionContext } from 'sql/workbench/common/actions';
|
||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
|
import { ScriptCreateAction, ScriptDeleteAction, ScriptSelectAction, ScriptExecuteAction, ScriptAlterAction, EditDataAction } from 'sql/workbench/electron-browser/scriptingActions';
|
||||||
|
import { ObjectExplorerActionsContext, getTreeNode } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
|
||||||
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
||||||
|
import { TreeSelectionHandler } from 'sql/workbench/parts/objectExplorer/browser/treeSelectionHandler';
|
||||||
|
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
||||||
import Severity from 'vs/base/common/severity';
|
import Severity from 'vs/base/common/severity';
|
||||||
|
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
||||||
|
import { VIEWLET_ID } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet';
|
||||||
|
|
||||||
export const SCRIPT_AS_CREATE_COMMAND_ID = 'objectExplorer.scriptAsCreate';
|
//#region -- Data Explorer
|
||||||
export const SCRIPT_AS_DELETE_COMMAND_ID = 'objectExplorer.scriptAsDelete';
|
export const SCRIPT_AS_CREATE_COMMAND_ID = 'dataExplorer.scriptAsCreate';
|
||||||
export const SCRIPT_AS_SELECT_COMMAND_ID = 'objectExplorer.scriptAsSelect';
|
export const SCRIPT_AS_DELETE_COMMAND_ID = 'dataExplorer.scriptAsDelete';
|
||||||
export const SCRIPT_AS_EXECUTE_COMMAND_ID = 'objectExplorer.scriptAsExecute';
|
export const SCRIPT_AS_SELECT_COMMAND_ID = 'dataExplorer.scriptAsSelect';
|
||||||
export const SCRIPT_AS_ALTER_COMMAND_ID = 'objectExplorer.scriptAsAlter';
|
export const SCRIPT_AS_EXECUTE_COMMAND_ID = 'dataExplorer.scriptAsExecute';
|
||||||
export const EDIT_DATA_COMMAND_ID = 'objectExplorer.scriptAsEdit';
|
export const SCRIPT_AS_ALTER_COMMAND_ID = 'dataExplorer.scriptAsAlter';
|
||||||
export const REFRESH_OE_COMMAND_ID = 'objectExplorer.refreshNode';
|
export const EDIT_DATA_COMMAND_ID = 'dataExplorer.scriptAsEdit';
|
||||||
|
|
||||||
|
// Script as Create
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: SCRIPT_AS_CREATE_COMMAND_ID,
|
||||||
|
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||||
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
|
const oeShimService = accessor.get(IOEShimService);
|
||||||
|
const queryEditorService = accessor.get(IQueryEditorService);
|
||||||
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
|
const scriptingService = accessor.get(IScriptingService);
|
||||||
|
const errorMessageService = accessor.get(IErrorMessageService);
|
||||||
|
const progressService = accessor.get(IProgressService);
|
||||||
|
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||||
|
const baseContext: BaseActionContext = {
|
||||||
|
profile: profile,
|
||||||
|
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||||
|
};
|
||||||
|
const scriptCreateAction = new ScriptCreateAction(ScriptCreateAction.ID, ScriptCreateAction.LABEL,
|
||||||
|
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||||
|
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptCreateAction.run(baseContext));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script as Delete
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: SCRIPT_AS_DELETE_COMMAND_ID,
|
||||||
|
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||||
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
|
const oeShimService = accessor.get(IOEShimService);
|
||||||
|
const queryEditorService = accessor.get(IQueryEditorService);
|
||||||
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
|
const scriptingService = accessor.get(IScriptingService);
|
||||||
|
const errorMessageService = accessor.get(IErrorMessageService);
|
||||||
|
const progressService = accessor.get(IProgressService);
|
||||||
|
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||||
|
const baseContext: BaseActionContext = {
|
||||||
|
profile: profile,
|
||||||
|
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||||
|
};
|
||||||
|
const scriptDeleteAction = new ScriptDeleteAction(ScriptDeleteAction.ID, ScriptDeleteAction.LABEL,
|
||||||
|
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||||
|
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptDeleteAction.run(baseContext));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Script as Select
|
// Script as Select
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: SCRIPT_AS_SELECT_COMMAND_ID,
|
id: SCRIPT_AS_SELECT_COMMAND_ID,
|
||||||
|
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||||
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
|
const oeShimService = accessor.get(IOEShimService);
|
||||||
|
const queryEditorService = accessor.get(IQueryEditorService);
|
||||||
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
|
const scriptingService = accessor.get(IScriptingService);
|
||||||
|
const progressService = accessor.get(IProgressService);
|
||||||
|
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||||
|
const baseContext: BaseActionContext = {
|
||||||
|
profile: profile,
|
||||||
|
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||||
|
};
|
||||||
|
const scriptSelectAction = new ScriptSelectAction(ScriptSelectAction.ID, ScriptSelectAction.LABEL,
|
||||||
|
queryEditorService, connectionManagementService, scriptingService);
|
||||||
|
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptSelectAction.run(baseContext));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script as Execute
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: SCRIPT_AS_EXECUTE_COMMAND_ID,
|
||||||
|
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||||
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
|
const oeShimService = accessor.get(IOEShimService);
|
||||||
|
const queryEditorService = accessor.get(IQueryEditorService);
|
||||||
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
|
const scriptingService = accessor.get(IScriptingService);
|
||||||
|
const progressService = accessor.get(IProgressService);
|
||||||
|
const errorMessageService = accessor.get(IErrorMessageService);
|
||||||
|
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||||
|
const baseContext: BaseActionContext = {
|
||||||
|
profile: profile,
|
||||||
|
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||||
|
};
|
||||||
|
const scriptExecuteAction = new ScriptExecuteAction(ScriptExecuteAction.ID, ScriptExecuteAction.LABEL,
|
||||||
|
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||||
|
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptExecuteAction.run(baseContext));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Script as Alter
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: SCRIPT_AS_ALTER_COMMAND_ID,
|
||||||
|
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||||
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
|
const oeShimService = accessor.get(IOEShimService);
|
||||||
|
const queryEditorService = accessor.get(IQueryEditorService);
|
||||||
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
|
const scriptingService = accessor.get(IScriptingService);
|
||||||
|
const progressService = accessor.get(IProgressService);
|
||||||
|
const errorMessageService = accessor.get(IErrorMessageService);
|
||||||
|
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||||
|
const baseContext: BaseActionContext = {
|
||||||
|
profile: profile,
|
||||||
|
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||||
|
};
|
||||||
|
const scriptAlterAction = new ScriptAlterAction(ScriptAlterAction.ID, ScriptAlterAction.LABEL,
|
||||||
|
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||||
|
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptAlterAction.run(baseContext));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Edit Data
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: EDIT_DATA_COMMAND_ID,
|
||||||
|
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||||
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
|
const oeShimService = accessor.get(IOEShimService);
|
||||||
|
const queryEditorService = accessor.get(IQueryEditorService);
|
||||||
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
|
const scriptingService = accessor.get(IScriptingService);
|
||||||
|
const progressService = accessor.get(IProgressService);
|
||||||
|
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||||
|
const baseContext: BaseActionContext = {
|
||||||
|
profile: profile,
|
||||||
|
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||||
|
};
|
||||||
|
const editDataAction = new EditDataAction(EditDataAction.ID, EditDataAction.LABEL,
|
||||||
|
queryEditorService, connectionManagementService, scriptingService);
|
||||||
|
return progressService.withProgress({ location: VIEWLET_ID }, () => editDataAction.run(baseContext));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region -- Object Explorer
|
||||||
|
|
||||||
|
export const OE_SCRIPT_AS_CREATE_COMMAND_ID = 'objectExplorer.scriptAsCreate';
|
||||||
|
export const OE_SCRIPT_AS_DELETE_COMMAND_ID = 'objectExplorer.scriptAsDelete';
|
||||||
|
export const OE_SCRIPT_AS_SELECT_COMMAND_ID = 'objectExplorer.scriptAsSelect';
|
||||||
|
export const OE_SCRIPT_AS_EXECUTE_COMMAND_ID = 'objectExplorer.scriptAsExecute';
|
||||||
|
export const OE_SCRIPT_AS_ALTER_COMMAND_ID = 'objectExplorer.scriptAsAlter';
|
||||||
|
export const OE_EDIT_DATA_COMMAND_ID = 'objectExplorer.scriptAsEdit';
|
||||||
|
export const OE_REFRESH_COMMAND_ID = 'objectExplorer.refreshNode';
|
||||||
|
|
||||||
|
// Script as Select
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: OE_SCRIPT_AS_SELECT_COMMAND_ID,
|
||||||
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
||||||
const instantiationService = accessor.get(IInstantiationService);
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
@@ -49,7 +197,7 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
// Edit Data
|
// Edit Data
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: EDIT_DATA_COMMAND_ID,
|
id: OE_EDIT_DATA_COMMAND_ID,
|
||||||
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
||||||
const instantiationService = accessor.get(IInstantiationService);
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
const objectExplorerService = accessor.get(IObjectExplorerService);
|
const objectExplorerService = accessor.get(IObjectExplorerService);
|
||||||
@@ -68,7 +216,7 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
// Script as Create
|
// Script as Create
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: SCRIPT_AS_CREATE_COMMAND_ID,
|
id: OE_SCRIPT_AS_CREATE_COMMAND_ID,
|
||||||
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
||||||
const instantiationService = accessor.get(IInstantiationService);
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
@@ -90,7 +238,7 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
// Script as Execute
|
// Script as Execute
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: SCRIPT_AS_EXECUTE_COMMAND_ID,
|
id: OE_SCRIPT_AS_EXECUTE_COMMAND_ID,
|
||||||
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
||||||
const instantiationService = accessor.get(IInstantiationService);
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
@@ -112,7 +260,7 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
// Script as Alter
|
// Script as Alter
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: SCRIPT_AS_ALTER_COMMAND_ID,
|
id: OE_SCRIPT_AS_ALTER_COMMAND_ID,
|
||||||
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
||||||
const instantiationService = accessor.get(IInstantiationService);
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
@@ -135,7 +283,7 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
// Script as Delete
|
// Script as Delete
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: SCRIPT_AS_DELETE_COMMAND_ID,
|
id: OE_SCRIPT_AS_DELETE_COMMAND_ID,
|
||||||
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
||||||
const instantiationService = accessor.get(IInstantiationService);
|
const instantiationService = accessor.get(IInstantiationService);
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
@@ -158,7 +306,7 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
// Refresh Action for Scriptable objects
|
// Refresh Action for Scriptable objects
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: REFRESH_OE_COMMAND_ID,
|
id: OE_REFRESH_COMMAND_ID,
|
||||||
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
handler: async (accessor, args: ObjectExplorerActionsContext) => {
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||||
@@ -194,3 +342,4 @@ CommandsRegistry.registerCommand({
|
|||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//#endregion
|
||||||
@@ -47,10 +47,7 @@ import { ExplorerItem, NewExplorerItem } from 'vs/workbench/contrib/files/common
|
|||||||
import { onUnexpectedError, getErrorMessage } from 'vs/base/common/errors';
|
import { onUnexpectedError, getErrorMessage } from 'vs/base/common/errors';
|
||||||
|
|
||||||
// {{SQL CARBON EDIT}}
|
// {{SQL CARBON EDIT}}
|
||||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
import { openNewQuery } from 'sql/workbench/parts/query/browser/queryActions';
|
||||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
|
||||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
|
||||||
import * as TaskUtilities from 'sql/workbench/browser/taskUtilities';
|
|
||||||
|
|
||||||
export const NEW_FILE_COMMAND_ID = 'explorer.newFile';
|
export const NEW_FILE_COMMAND_ID = 'explorer.newFile';
|
||||||
export const NEW_FILE_LABEL = nls.localize('newFile', "New File");
|
export const NEW_FILE_LABEL = nls.localize('newFile', "New File");
|
||||||
@@ -160,16 +157,14 @@ export class GlobalNewUntitledFileAction extends Action {
|
|||||||
label: string,
|
label: string,
|
||||||
// {{SQL CARBON EDIT}} - Make editorService protected and add other services
|
// {{SQL CARBON EDIT}} - Make editorService protected and add other services
|
||||||
@IEditorService protected readonly editorService: IEditorService,
|
@IEditorService protected readonly editorService: IEditorService,
|
||||||
@IQueryEditorService private queryEditorService: IQueryEditorService,
|
@IInstantiationService private readonly instantiationService: IInstantiationService
|
||||||
@IConnectionManagementService private connectionManagementService: IConnectionManagementService,
|
|
||||||
@IObjectExplorerService protected _objectExplorerService: IObjectExplorerService
|
|
||||||
) {
|
) {
|
||||||
super(id, label);
|
super(id, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
public run(): Promise<any> {
|
public run(): Promise<any> {
|
||||||
// {{SQL CARBON EDIT}}
|
// {{SQL CARBON EDIT}}
|
||||||
return TaskUtilities.newQuery(undefined, this.connectionManagementService, this.queryEditorService, this._objectExplorerService, this.editorService);
|
return this.instantiationService.invokeFunction(openNewQuery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -266,14 +266,14 @@ import 'sql/workbench/update/electron-browser/releaseNotes.contribution';
|
|||||||
|
|
||||||
// data explorer
|
// data explorer
|
||||||
import 'sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution';
|
import 'sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution';
|
||||||
import 'sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet';
|
|
||||||
import 'sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint';
|
|
||||||
import 'sql/workbench/parts/dataExplorer/common/nodeActions.common.contribution';
|
import 'sql/workbench/parts/dataExplorer/common/nodeActions.common.contribution';
|
||||||
import 'sql/workbench/parts/dataExplorer/electron-browser/nodeActions.contribution';
|
|
||||||
|
|
||||||
import 'sql/workbench/parts/telemetry/common/telemetry.contribution';
|
import 'sql/workbench/parts/telemetry/common/telemetry.contribution';
|
||||||
import 'sql/workbench/parts/connection/browser/connection.contribution';
|
import 'sql/workbench/parts/connection/browser/connection.contribution';
|
||||||
|
|
||||||
|
// Scripting
|
||||||
|
import 'sql/workbench/parts/scripting/electron-browser/scripting.contribution';
|
||||||
|
|
||||||
// query editor
|
// query editor
|
||||||
import 'sql/workbench/parts/query/browser/query.contribution';
|
import 'sql/workbench/parts/query/browser/query.contribution';
|
||||||
import 'sql/workbench/parts/query/common/resultsGridContribution';
|
import 'sql/workbench/parts/query/common/resultsGridContribution';
|
||||||
@@ -290,7 +290,6 @@ import 'sql/workbench/parts/accounts/browser/accounts.contribution';
|
|||||||
import 'sql/workbench/parts/profiler/browser/profiler.contribution';
|
import 'sql/workbench/parts/profiler/browser/profiler.contribution';
|
||||||
import 'sql/workbench/parts/profiler/browser/profilerActions.contribution';
|
import 'sql/workbench/parts/profiler/browser/profilerActions.contribution';
|
||||||
import 'sql/workbench/parts/objectExplorer/common/serverGroup.contribution';
|
import 'sql/workbench/parts/objectExplorer/common/serverGroup.contribution';
|
||||||
import 'sql/workbench/parts/objectExplorer/electron-browser/objectExplorerScripting.contribution';
|
|
||||||
import 'sql/platform/accounts/browser/accountManagement.contribution';
|
import 'sql/platform/accounts/browser/accountManagement.contribution';
|
||||||
|
|
||||||
// dashboard
|
// dashboard
|
||||||
@@ -304,16 +303,15 @@ import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/type
|
|||||||
import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/countInsight.contribution';
|
import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/countInsight.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/imageInsight.contribution';
|
import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/imageInsight.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/tableInsight.contribution';
|
import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/tableInsight.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/dashboard.contribution';
|
|
||||||
/* Tasks */
|
|
||||||
import 'sql/workbench/common/actions.contribution';
|
|
||||||
/* Widgets */
|
/* Widgets */
|
||||||
import 'sql/workbench/parts/dashboard/browser/widgets/insights/insightsWidget.contribution';
|
import 'sql/workbench/parts/dashboard/browser/widgets/insights/insightsWidget.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerWidget.common.contribution';
|
import 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerWidget.common.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/electron-browser/widgets/explorer/explorerWidget.contribution';
|
import 'sql/workbench/parts/dashboard/electron-browser/widgets/explorer/explorerWidget.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/widgets/tasks/tasksWidget.contribution';
|
import 'sql/workbench/parts/dashboard/browser/widgets/tasks/tasksWidget.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/widgets/webview/webviewWidget.contribution';
|
import 'sql/workbench/parts/dashboard/browser/widgets/webview/webviewWidget.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/dashboardConfig.contribution';
|
import 'sql/workbench/parts/dashboard/browser/dashboard.contribution';
|
||||||
|
/* Tasks */
|
||||||
|
import 'sql/workbench/common/actions.contribution';
|
||||||
/* Model-based Views */
|
/* Model-based Views */
|
||||||
import 'sql/workbench/browser/modelComponents/components.contribution';
|
import 'sql/workbench/browser/modelComponents/components.contribution';
|
||||||
/* View Model Editor */
|
/* View Model Editor */
|
||||||
|
|||||||
Reference in New Issue
Block a user