mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-22 15:34:49 +01:00
fix: expandability, context value in tree
This commit is contained in:
parent
4d2a7407e2
commit
045c0bddc8
1 changed files with 19 additions and 15 deletions
34
src/tree.ts
34
src/tree.ts
|
@ -22,19 +22,20 @@ export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeIte
|
||||||
case Type.Workspace:
|
case Type.Workspace:
|
||||||
if (workspace === null) { return [] };
|
if (workspace === null) { return [] };
|
||||||
if (element.label == workspace.id()) {
|
if (element.label == workspace.id()) {
|
||||||
return [
|
// return [
|
||||||
new CodempTreeItem("Buffers", Type.BufferContainer),
|
// new CodempTreeItem("Buffers", Type.BufferContainer, true),
|
||||||
new CodempTreeItem("Users", Type.UserContainer)
|
// new CodempTreeItem("Users", Type.UserContainer, true)
|
||||||
];
|
// ];
|
||||||
|
return workspace.filetree().map((x) => new CodempTreeItem(x, Type.Buffer, false));
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
case Type.BufferContainer:
|
case Type.BufferContainer:
|
||||||
if (workspace === null) { return [] };
|
if (workspace === null) { return [] };
|
||||||
return workspace.filetree().map((x) => new CodempTreeItem(x, Type.Buffer));
|
return workspace.filetree().map((x) => new CodempTreeItem(x, Type.Buffer, false));
|
||||||
case Type.UserContainer:
|
case Type.UserContainer:
|
||||||
if (workspace === null) { return [] };
|
if (workspace === null) { return [] };
|
||||||
return [new CodempTreeItem("TODO", Type.User)]; // TODO keep track of users
|
return [new CodempTreeItem("TODO", Type.User, false)]; // TODO keep track of users
|
||||||
case Type.Buffer:
|
case Type.Buffer:
|
||||||
return [];
|
return [];
|
||||||
case Type.User:
|
case Type.User:
|
||||||
|
@ -42,7 +43,7 @@ export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeIte
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(client === null) return [];
|
if(client === null) return [];
|
||||||
return workspace_list.map((x) => new CodempTreeItem(x, Type.Workspace));
|
return workspace_list.map((x) => new CodempTreeItem(x, Type.Workspace, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,16 +51,19 @@ export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeIte
|
||||||
|
|
||||||
class CodempTreeItem extends vscode.TreeItem {
|
class CodempTreeItem extends vscode.TreeItem {
|
||||||
type: Type;
|
type: Type;
|
||||||
constructor(label: string | vscode.TreeItemLabel, type: Type){
|
constructor(label: string | vscode.TreeItemLabel, type: Type, expandable: boolean){
|
||||||
super(label, vscode.TreeItemCollapsibleState.Expanded);
|
let state = expandable ? vscode.TreeItemCollapsibleState.Expanded : vscode.TreeItemCollapsibleState.None;
|
||||||
this.type=type;
|
console.log(type.toString());
|
||||||
|
super(label, state);
|
||||||
|
this.type = type;
|
||||||
|
this.contextValue = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
Workspace,
|
Workspace = "workspace",
|
||||||
BufferContainer,
|
BufferContainer = "container_buffer",
|
||||||
UserContainer,
|
UserContainer = "container_user",
|
||||||
Buffer,
|
Buffer = "buffer",
|
||||||
User,
|
User = "user",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue