move code from parts to contrib (#8319)

This commit is contained in:
Anthony Dresser
2019-11-14 12:23:11 -08:00
committed by GitHub
parent 6438967202
commit 7a2c30e159
619 changed files with 848 additions and 848 deletions

View File

@@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ITree } from 'vs/base/parts/tree/browser/tree';
import { ContributableActionProvider } from 'vs/workbench/browser/actions';
import { IAction } from 'vs/base/common/actions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { TaskNode, TaskStatus, TaskExecutionMode } from 'sql/platform/tasks/common/tasksNode';
import { CancelAction, ScriptAction } from 'sql/workbench/contrib/tasks/common/tasksAction';
/**
* Provides actions for the history tasks
*/
export class TaskHistoryActionProvider extends ContributableActionProvider {
constructor(
@IInstantiationService private _instantiationService: IInstantiationService
) {
super();
}
public hasActions(tree: ITree, element: any): boolean {
return element instanceof TaskNode;
}
/**
* Return actions given an element in the tree
*/
public getActions(tree: ITree, element: any): IAction[] {
if (element instanceof TaskNode) {
return this.getTaskHistoryActions(tree, element);
}
return [];
}
public hasSecondaryActions(tree: ITree, element: any): boolean {
return false;
}
/**
* Return actions for history task
*/
public getTaskHistoryActions(tree: ITree, element: TaskNode): IAction[] {
let actions = [];
// get actions for tasks in progress
if (element.status === TaskStatus.InProgress && element.isCancelable) {
actions.push(this._instantiationService.createInstance(CancelAction, CancelAction.ID, CancelAction.LABEL));
}
// get actions for tasks succeeded
if (element.status === TaskStatus.Succeeded || element.status === TaskStatus.SucceededWithWarning) {
if (element.taskExecutionMode === TaskExecutionMode.executeAndScript) {
actions.push(this._instantiationService.createInstance(ScriptAction, ScriptAction.ID, ScriptAction.LABEL));
}
}
return actions;
}
}