|
| 1 | +import * as vscode from 'vscode'; |
| 2 | +import * as models from '../models'; |
| 3 | + |
| 4 | +export type TreeItem = WorkspaceTreeItem | NamespaceTreeItem | TaskTreeItem; |
| 5 | + |
| 6 | +export class WorkspaceTreeItem extends vscode.TreeItem { |
| 7 | + constructor( |
| 8 | + readonly label: string, |
| 9 | + readonly workspace: string, |
| 10 | + readonly tasks: models.Task[], |
| 11 | + readonly collapsibleState: vscode.TreeItemCollapsibleState, |
| 12 | + readonly command?: vscode.Command |
| 13 | + ) { |
| 14 | + super(label, collapsibleState); |
| 15 | + this.description = this.workspace; |
| 16 | + this.iconPath = new vscode.ThemeIcon('folder', new vscode.ThemeColor('vscodetask.workspaceIcon')); |
| 17 | + this.contextValue = `workspaceTreeItem`; |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +export class NamespaceTreeItem extends vscode.TreeItem { |
| 22 | + constructor( |
| 23 | + readonly label: string, |
| 24 | + readonly workspace: string, |
| 25 | + readonly namespace: string, |
| 26 | + readonly tasks: models.Task[], |
| 27 | + readonly collapsibleState: vscode.TreeItemCollapsibleState, |
| 28 | + readonly command?: vscode.Command |
| 29 | + ) { |
| 30 | + super(label, collapsibleState); |
| 31 | + this.iconPath = new vscode.ThemeIcon('symbol-namespace', new vscode.ThemeColor('vscodetask.namespaceIcon')); |
| 32 | + this.contextValue = `namespaceTreeItem`; |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +export class TaskTreeItem extends vscode.TreeItem { |
| 37 | + constructor( |
| 38 | + readonly label: string, |
| 39 | + readonly workspace: string, |
| 40 | + readonly task: models.Task, |
| 41 | + readonly collapsibleState: vscode.TreeItemCollapsibleState, |
| 42 | + readonly command?: vscode.Command |
| 43 | + ) { |
| 44 | + super(label, collapsibleState); |
| 45 | + this.description = this.task?.desc; |
| 46 | + if (this.task.up_to_date) { |
| 47 | + this.iconPath = new vscode.ThemeIcon('debug-breakpoint-log-unverified', new vscode.ThemeColor('vscodetask.upToDateIcon')); |
| 48 | + } else { |
| 49 | + this.iconPath = new vscode.ThemeIcon('debug-breakpoint-data-unverified', new vscode.ThemeColor('vscodetask.outOfDateIcon')); |
| 50 | + } |
| 51 | + this.contextValue = `taskTreeItem`; |
| 52 | + } |
| 53 | +} |
0 commit comments