|
1 | 1 | import * as vscode from "vscode"; |
2 | 2 |
|
3 | | -import { NodeBase } from "./nodeBase"; |
| 3 | +import { NodeBase, NodeOptions } from "./nodeBase"; |
4 | 4 | import { RootNode } from "./rootNode"; |
| 5 | +import { workspaceState } from "../../extension"; |
5 | 6 |
|
6 | 7 | export class WorkspaceNode extends NodeBase { |
7 | 8 | public eventEmitter: vscode.EventEmitter<NodeBase>; |
8 | | - public constructor(label: string, eventEmitter: vscode.EventEmitter<NodeBase>, namespace?: string) { |
9 | | - super(label, label, label, namespace); |
| 9 | + public uniqueId: string; |
| 10 | + public constructor(label: string, eventEmitter: vscode.EventEmitter<NodeBase>, options: NodeOptions) { |
| 11 | + super(label, label, options); |
| 12 | + this.uniqueId = `serverNode${this.extraNode ? ":extra:" + this.namespace : ""}`; |
| 13 | + this.options.generated = workspaceState.get(`ExplorerGenerated:${this.uniqueId}`); |
10 | 14 | this.eventEmitter = eventEmitter; |
11 | 15 | } |
12 | 16 |
|
13 | 17 | public getTreeItem(): vscode.TreeItem { |
14 | 18 | return { |
15 | 19 | collapsibleState: vscode.TreeItemCollapsibleState.Expanded, |
16 | | - contextValue: `serverNode${this.extraNode ? "Extra:" + this.namespace : ""}`, |
17 | | - label: `${this.label}${this.extraNode ? `[${this.namespace}]` : ""}`, |
| 20 | + contextValue: `${this.uniqueId}${this.options.generated ? ":generated:" : ""}`, |
| 21 | + label: `${this.label}[${this.namespace}]`, |
18 | 22 | }; |
19 | 23 | } |
20 | 24 |
|
21 | 25 | public async getChildren(element): Promise<NodeBase[]> { |
22 | 26 | const children = []; |
23 | 27 | let node: RootNode; |
24 | 28 |
|
25 | | - node = new RootNode("Classes", "", "dataRootNode:classesRootNode", "CLS", this.workspaceFolder, this.namespace); |
| 29 | + node = new RootNode("Classes", "", "dataRootNode:classesRootNode", "CLS", this.options); |
26 | 30 | children.push(node); |
27 | 31 |
|
28 | | - node = new RootNode("Routines", "", "dataRootNode:routinesRootNode", "RTN", this.workspaceFolder, this.namespace); |
| 32 | + node = new RootNode("Routines", "", "dataRootNode:routinesRootNode", "RTN", this.options); |
29 | 33 | children.push(node); |
30 | 34 |
|
31 | | - node = new RootNode("Includes", "", "dataRootNode:routinesRootNode", "INC", this.workspaceFolder, this.namespace); |
| 35 | + node = new RootNode("Includes", "", "dataRootNode:routinesRootNode", "INC", this.options); |
32 | 36 | children.push(node); |
33 | 37 |
|
34 | 38 | return children; |
|
0 commit comments