mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Task contribution (#742)
* work in progress * set up necessary code. need to work on getting it working * formatting * work in progress * work in progress * formatting * work in progress * work in progress * work in progress * formatting * needs a lot of work regarding how we do actions vs how extensions do actions * formatting * use connection profile for actions * change action to be
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
import { GlobalNewProfilerAction } from './profilerWorkbenchActions';
|
||||
|
||||
import { registerTask } from 'sql/platform/tasks/taskRegistry';
|
||||
import { TaskRegistry } from 'sql/platform/tasks/common/tasks';
|
||||
import { NewProfilerAction } from './profilerActions';
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
@@ -27,6 +27,5 @@ const newProfilerSchema: IJSONSchema = {
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalNewProfilerAction, GlobalNewProfilerAction.ID, GlobalNewProfilerAction.LABEL), 'Profiler: New Profiler', category);
|
||||
|
||||
registerTask('new-profiler', '', newProfilerSchema, NewProfilerAction);
|
||||
new NewProfilerAction().registerTask();
|
||||
}
|
||||
|
||||
@@ -9,17 +9,18 @@ import { IProfilerService } from 'sql/parts/profiler/service/interfaces';
|
||||
import { IProfilerController } from 'sql/parts/profiler/editor/controller/interfaces';
|
||||
import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput';
|
||||
import { BaseActionContext } from 'sql/workbench/common/actions';
|
||||
import { TaskAction } from 'sql/platform/tasks/taskRegistry';
|
||||
import { Task } from 'sql/platform/tasks/common/tasks';
|
||||
import { ObjectExplorerActionsContext } from 'sql/parts/registeredServer/viewlet/objectExplorerActions';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IEditorAction } from 'vs/editor/common/editorCommon';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ObjectExplorerActionsContext } from 'sql/parts/registeredServer/viewlet/objectExplorerActions';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export class ProfilerConnect extends Action {
|
||||
public static ID = 'profiler.connect';
|
||||
@@ -226,29 +227,20 @@ export class ProfilerFindPrevious implements IEditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
export class NewProfilerAction extends TaskAction {
|
||||
public static ID = 'newProfiler';
|
||||
public static LABEL = nls.localize('newProfiler', 'New Profiler');
|
||||
public static ICON = 'profile';
|
||||
export class NewProfilerAction extends Task {
|
||||
public static readonly ID = 'newProfiler';
|
||||
public static readonly LABEL = nls.localize('newProfiler', 'New Profiler');
|
||||
public static readonly ICON = 'profile';
|
||||
|
||||
private _connectionProfile: ConnectionProfile;
|
||||
|
||||
constructor(
|
||||
id: string, label: string, icon: string,
|
||||
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService
|
||||
) {
|
||||
super(id, label, icon);
|
||||
constructor() {
|
||||
super({ id: NewProfilerAction.ID, title: NewProfilerAction.LABEL, iconClass: NewProfilerAction.ICON });
|
||||
}
|
||||
|
||||
run(actionContext: BaseActionContext): TPromise<boolean> {
|
||||
if (actionContext instanceof ObjectExplorerActionsContext) {
|
||||
this._connectionProfile = actionContext.connectionProfile;
|
||||
}
|
||||
|
||||
let profilerInput = this._instantiationService.createInstance(ProfilerInput, actionContext.profile);
|
||||
return this._editorService.openEditor(profilerInput, { pinned: true }, false).then(() => {
|
||||
public runTask(accessor: ServicesAccessor, profile: IConnectionProfile): TPromise<void> {
|
||||
let profilerInput = accessor.get<IInstantiationService>(IInstantiationService).createInstance(ProfilerInput, profile);
|
||||
return accessor.get<IWorkbenchEditorService>(IWorkbenchEditorService).openEditor(profilerInput, { pinned: true }, false).then(() => {
|
||||
let options: IConnectionCompletionOptions = {
|
||||
params: undefined,
|
||||
saveTheConnection: false,
|
||||
@@ -256,11 +248,9 @@ export class NewProfilerAction extends TaskAction {
|
||||
showDashboard: false,
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
this._connectionService.connect(this._connectionProfile, profilerInput.id, options).then(() => {
|
||||
TPromise.as(true);
|
||||
});
|
||||
accessor.get<IConnectionManagementService>(IConnectionManagementService).connect(this._connectionProfile, profilerInput.id, options);
|
||||
|
||||
return TPromise.as(true);
|
||||
return TPromise.as(void 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user