Reworks ExplorerNode base class

Adds TextExplorerNode for messages
This commit is contained in:
Eric Amodio
2017-08-27 04:10:02 -04:00
parent 6518279937
commit 208d549c1c
10 changed files with 49 additions and 31 deletions

View File

@@ -1,14 +1,14 @@
'use strict';
import { Command, Event, ExtensionContext, TreeItem } from 'vscode';
import { GitService, GitUri } from '../gitService';
import { Command, Event, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { GitUri } from '../gitService';
export declare type ResourceType = 'status' | 'branches' | 'repository' | 'branch-history' | 'file-history' | 'stash-history' | 'commit' | 'stash-commit' | 'commit-file';
export declare type ResourceType = 'text' | 'status' | 'branches' | 'repository' | 'branch-history' | 'file-history' | 'stash-history' | 'commit' | 'stash-commit' | 'commit-file';
export abstract class ExplorerNode {
abstract readonly resourceType: ResourceType;
constructor(public readonly uri: GitUri, protected readonly context: ExtensionContext, protected readonly git: GitService) { }
constructor(public readonly uri: GitUri) { }
abstract getChildren(): ExplorerNode[] | Promise<ExplorerNode[]>;
abstract getTreeItem(): TreeItem | Promise<TreeItem>;
@@ -20,4 +20,23 @@ export abstract class ExplorerNode {
onDidChangeTreeData?: Event<ExplorerNode>;
refresh?(): void;
}
export class TextExplorerNode extends ExplorerNode {
readonly resourceType: ResourceType = 'text';
constructor(private text: string) {
super(new GitUri());
}
getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> {
return [];
}
getTreeItem(): TreeItem | Promise<TreeItem> {
const item = new TreeItem(this.text, TreeItemCollapsibleState.None);
item.contextValue = this.resourceType;
return item;
}
}