mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Add scripting contributions for explorer widget (#7830)
* add scripting contributions for explorer widget * utilize or
This commit is contained in:
@@ -1,79 +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 { ScriptSelectAction, ScriptCreateAction, ScriptAlterAction, ScriptExecuteAction } from 'sql/workbench/browser/scriptingActions';
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
|
||||
import { IEditorProgressService, IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
import { BaseActionContext } from 'sql/workbench/browser/actions';
|
||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||
|
||||
export class ExplorerScriptSelectAction extends ScriptSelectAction {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IQueryEditorService queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IScriptingService scriptingService: IScriptingService,
|
||||
@IProgressService private readonly progressService: IProgressService
|
||||
) {
|
||||
super(id, label, queryEditorService, connectionManagementService, scriptingService);
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return this.progressService.withProgress({ location: ProgressLocation.Window }, () => super.run(actionContext));
|
||||
}
|
||||
}
|
||||
|
||||
export class ExplorerScriptCreateAction extends ScriptCreateAction {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IQueryEditorService queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IScriptingService scriptingService: IScriptingService,
|
||||
@IErrorMessageService errorMessageService: IErrorMessageService,
|
||||
@IProgressService private readonly progressService: IProgressService
|
||||
) {
|
||||
super(id, label, queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return this.progressService.withProgress({ location: ProgressLocation.Window }, () => super.run(actionContext));
|
||||
}
|
||||
}
|
||||
|
||||
export class ExplorerScriptAlterAction extends ScriptAlterAction {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IQueryEditorService queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IScriptingService scriptingService: IScriptingService,
|
||||
@IErrorMessageService errorMessageService: IErrorMessageService,
|
||||
@IProgressService private readonly progressService: IProgressService
|
||||
) {
|
||||
super(id, label, queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return this.progressService.withProgress({ location: ProgressLocation.Window }, () => super.run(actionContext));
|
||||
}
|
||||
}
|
||||
|
||||
export class ExplorerScriptExecuteAction extends ScriptExecuteAction {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IQueryEditorService queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IScriptingService scriptingService: IScriptingService,
|
||||
@IErrorMessageService errorMessageService: IErrorMessageService,
|
||||
@IProgressService private readonly progressService: IProgressService
|
||||
) {
|
||||
super(id, label, queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return this.progressService.withProgress({ location: ProgressLocation.Window }, () => super.run(actionContext));
|
||||
}
|
||||
}
|
||||
@@ -1,109 +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 { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { ExplorerScriptSelectAction, ExplorerScriptExecuteAction, ExplorerScriptAlterAction, ExplorerScriptCreateAction } from 'sql/workbench/parts/dashboard/electron-browser/widgets/explorer/explorerTreeActions';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ItemContextKey } from 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { EditDataAction } from 'sql/workbench/browser/scriptingActions';
|
||||
|
||||
CommandsRegistry.registerCommand(ExplorerScriptSelectAction.ID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(ExplorerScriptSelectAction, ExplorerScriptSelectAction.ID, ExplorerScriptSelectAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerScriptSelectAction.ID,
|
||||
title: ExplorerScriptSelectAction.LABEL
|
||||
},
|
||||
when: ItemContextKey.ItemType.isEqualTo('view'),
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerScriptSelectAction.ID,
|
||||
title: ExplorerScriptSelectAction.LABEL
|
||||
},
|
||||
when: ItemContextKey.ItemType.isEqualTo('table'),
|
||||
order: 2
|
||||
});
|
||||
|
||||
const ExplorerEditDataActionID = 'explorer.editData';
|
||||
CommandsRegistry.registerCommand(ExplorerEditDataActionID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(EditDataAction, EditDataAction.ID, EditDataAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerEditDataActionID,
|
||||
title: EditDataAction.LABEL
|
||||
},
|
||||
when: ItemContextKey.ItemType.isEqualTo('table'),
|
||||
order: 2
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(ExplorerScriptExecuteAction.ID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(ExplorerScriptExecuteAction, ExplorerScriptExecuteAction.ID, ExplorerScriptExecuteAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerScriptExecuteAction.ID,
|
||||
title: ExplorerScriptExecuteAction.LABEL
|
||||
},
|
||||
when: ItemContextKey.ItemType.isEqualTo('sproc'),
|
||||
order: 2
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(ExplorerScriptAlterAction.ID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(ExplorerScriptAlterAction, ExplorerScriptAlterAction.ID, ExplorerScriptAlterAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerScriptAlterAction.ID,
|
||||
title: ExplorerScriptAlterAction.LABEL
|
||||
},
|
||||
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('sproc'), ItemContextKey.ConnectionProvider.isEqualTo('mssql')),
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerScriptAlterAction.ID,
|
||||
title: ExplorerScriptAlterAction.LABEL
|
||||
},
|
||||
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('function'), ItemContextKey.ConnectionProvider.isEqualTo('mssql')),
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerScriptAlterAction.ID,
|
||||
title: ExplorerScriptAlterAction.LABEL
|
||||
},
|
||||
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('view'), ItemContextKey.ConnectionProvider.isEqualTo('mssql')),
|
||||
order: 2
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(ExplorerScriptCreateAction.ID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(ExplorerScriptCreateAction, ExplorerScriptCreateAction.ID, ExplorerScriptCreateAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerScriptCreateAction.ID,
|
||||
title: ExplorerScriptCreateAction.LABEL
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
@@ -11,6 +11,10 @@ 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 { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ItemContextKey } from 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerTreeContext';
|
||||
import { EditDataAction } from 'sql/workbench/browser/scriptingActions';
|
||||
|
||||
//#region -- Data Explorer
|
||||
// Script as Create
|
||||
@@ -203,3 +207,94 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
|
||||
});
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region -- explorer widget
|
||||
|
||||
CommandsRegistry.registerCommand(commands.ExplorerScriptSelectAction.ID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(commands.ExplorerScriptSelectAction, commands.ExplorerScriptSelectAction.ID, commands.ExplorerScriptSelectAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: commands.ExplorerScriptSelectAction.ID,
|
||||
title: commands.ExplorerScriptSelectAction.LABEL
|
||||
},
|
||||
when: ContextKeyExpr.or(ItemContextKey.ItemType.isEqualTo('view'), ItemContextKey.ItemType.isEqualTo('table')),
|
||||
order: 2
|
||||
});
|
||||
|
||||
const ExplorerEditDataActionID = 'explorer.editData';
|
||||
CommandsRegistry.registerCommand(ExplorerEditDataActionID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(EditDataAction, EditDataAction.ID, EditDataAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: ExplorerEditDataActionID,
|
||||
title: EditDataAction.LABEL
|
||||
},
|
||||
when: ItemContextKey.ItemType.isEqualTo('table'),
|
||||
order: 2
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(commands.ExplorerScriptExecuteAction.ID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(commands.ExplorerScriptExecuteAction, commands.ExplorerScriptExecuteAction.ID, commands.ExplorerScriptExecuteAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: commands.ExplorerScriptExecuteAction.ID,
|
||||
title: commands.ExplorerScriptExecuteAction.LABEL
|
||||
},
|
||||
when: ItemContextKey.ItemType.isEqualTo('sproc'),
|
||||
order: 2
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(commands.ExplorerScriptAlterAction.ID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(commands.ExplorerScriptAlterAction, commands.ExplorerScriptAlterAction.ID, commands.ExplorerScriptAlterAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: commands.ExplorerScriptAlterAction.ID,
|
||||
title: commands.ExplorerScriptAlterAction.LABEL
|
||||
},
|
||||
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('sproc'), ItemContextKey.ConnectionProvider.isEqualTo('mssql')),
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: commands.ExplorerScriptAlterAction.ID,
|
||||
title: commands.ExplorerScriptAlterAction.LABEL
|
||||
},
|
||||
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('function'), ItemContextKey.ConnectionProvider.isEqualTo('mssql')),
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: commands.ExplorerScriptAlterAction.ID,
|
||||
title: commands.ExplorerScriptAlterAction.LABEL
|
||||
},
|
||||
when: ContextKeyExpr.and(ItemContextKey.ItemType.isEqualTo('view'), ItemContextKey.ConnectionProvider.isEqualTo('mssql')),
|
||||
order: 2
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(commands.ExplorerScriptCreateAction.ID, (accessor, context) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
instantiationService.createInstance(commands.ExplorerScriptCreateAction, commands.ExplorerScriptCreateAction.ID, commands.ExplorerScriptCreateAction.LABEL).run(context);
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
||||
command: {
|
||||
id: commands.ExplorerScriptCreateAction.ID,
|
||||
title: commands.ExplorerScriptCreateAction.LABEL
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
//#endregion
|
||||
|
||||
@@ -11,7 +11,7 @@ import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilit
|
||||
import { IOEShimService } from 'sql/workbench/parts/objectExplorer/browser/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 { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
import { BaseActionContext } from 'sql/workbench/browser/actions';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ScriptCreateAction, ScriptDeleteAction, ScriptSelectAction, ScriptExecuteAction, ScriptAlterAction, EditDataAction } from 'sql/workbench/browser/scriptingActions';
|
||||
@@ -343,3 +343,73 @@ CommandsRegistry.registerCommand({
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region -- explorer widget
|
||||
|
||||
export class ExplorerScriptSelectAction extends ScriptSelectAction {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IQueryEditorService queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IScriptingService scriptingService: IScriptingService,
|
||||
@IProgressService private readonly progressService: IProgressService
|
||||
) {
|
||||
super(id, label, queryEditorService, connectionManagementService, scriptingService);
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return this.progressService.withProgress({ location: ProgressLocation.Window }, () => super.run(actionContext));
|
||||
}
|
||||
}
|
||||
|
||||
export class ExplorerScriptCreateAction extends ScriptCreateAction {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IQueryEditorService queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IScriptingService scriptingService: IScriptingService,
|
||||
@IErrorMessageService errorMessageService: IErrorMessageService,
|
||||
@IProgressService private readonly progressService: IProgressService
|
||||
) {
|
||||
super(id, label, queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return this.progressService.withProgress({ location: ProgressLocation.Window }, () => super.run(actionContext));
|
||||
}
|
||||
}
|
||||
|
||||
export class ExplorerScriptAlterAction extends ScriptAlterAction {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IQueryEditorService queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IScriptingService scriptingService: IScriptingService,
|
||||
@IErrorMessageService errorMessageService: IErrorMessageService,
|
||||
@IProgressService private readonly progressService: IProgressService
|
||||
) {
|
||||
super(id, label, queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return this.progressService.withProgress({ location: ProgressLocation.Window }, () => super.run(actionContext));
|
||||
}
|
||||
}
|
||||
|
||||
export class ExplorerScriptExecuteAction extends ScriptExecuteAction {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IQueryEditorService queryEditorService: IQueryEditorService,
|
||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||
@IScriptingService scriptingService: IScriptingService,
|
||||
@IErrorMessageService errorMessageService: IErrorMessageService,
|
||||
@IProgressService private readonly progressService: IProgressService
|
||||
) {
|
||||
super(id, label, queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return this.progressService.withProgress({ location: ProgressLocation.Window }, () => super.run(actionContext));
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
@@ -407,7 +407,7 @@ import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/imageInsigh
|
||||
import 'sql/workbench/parts/dashboard/browser/widgets/insights/views/tableInsight.contribution';
|
||||
import 'sql/workbench/parts/dashboard/browser/dashboard.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.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/containers/dashboardWebviewContainer.contribution';
|
||||
|
||||
Reference in New Issue
Block a user