提交 b557d59b 编写于 作者: J Joao Moreno

tree model: cleanup interface

上级 94ee300f
......@@ -321,11 +321,11 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
}
expandAll(): void {
this.model.expandAll();
this.model.setCollapsed(this.model.rootRef, false, true);
}
collapseAll(): void {
this.model.collapseAll();
this.model.setCollapsed(this.model.rootRef, true, true);
}
isCollapsible(location: TRef): boolean {
......
......@@ -45,6 +45,8 @@ export interface IIndexTreeModelOptions<T, TFilterData> {
export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = void> implements ITreeModel<T, TFilterData, number[]> {
readonly rootRef = [];
private root: IMutableTreeNode<T, TFilterData>;
private eventBufferer = new EventBufferer(); // TODO@joao is this really necessary
......@@ -123,6 +125,14 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
return this.getTreeNodeWithListIndex(location).listIndex;
}
isCollapsible(location: number[]): boolean {
return this.getTreeNode(location).collapsible;
}
isCollapsed(location: number[]): boolean {
return this.getTreeNode(location).collapsed;
}
setCollapsed(location: number[], collapsed?: boolean, recursive = false): boolean {
const { node, listIndex, revealed } = this.getTreeNodeWithListIndex(location);
......@@ -167,22 +177,6 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
return result;
}
expandAll(): void {
this.setCollapsed([], false, true);
}
collapseAll(): void {
this.setCollapsed([], true, true);
}
isCollapsible(location: number[]): boolean {
return this.getTreeNode(location).collapsible;
}
isCollapsed(location: number[]): boolean {
return this.getTreeNode(location).collapsed;
}
refilter(): void {
const previousRenderNodeCount = this.root.renderNodeCount;
const toInsert = this.updateNodeAfterFilterChange(this.root);
......
......@@ -13,6 +13,8 @@ export interface IObjectTreeModelOptions<T, TFilterData> extends IIndexTreeModel
export class ObjectTreeModel<T extends NonNullable<any>, TFilterData extends NonNullable<any> = void> implements ITreeModel<T | null, TFilterData, T | null> {
readonly rootRef = null;
private model: IndexTreeModel<T | null, TFilterData>;
private nodes = new Map<T | null, ITreeNode<T, TFilterData>>();
......@@ -106,19 +108,6 @@ export class ObjectTreeModel<T extends NonNullable<any>, TFilterData extends Non
return this.model.getListIndex(location);
}
setCollapsed(element: T, collapsed: boolean): boolean {
const location = this.getElementLocation(element);
return this.model.setCollapsed(location, collapsed);
}
expandAll(): void {
this.model.expandAll();
}
collapseAll(): void {
this.model.collapseAll();
}
isCollapsible(element: T): boolean {
const location = this.getElementLocation(element);
return this.model.isCollapsible(location);
......@@ -129,6 +118,11 @@ export class ObjectTreeModel<T extends NonNullable<any>, TFilterData extends Non
return this.model.isCollapsed(location);
}
setCollapsed(element: T, collapsed: boolean): boolean {
const location = this.getElementLocation(element);
return this.model.setCollapsed(location, collapsed);
}
refilter(): void {
this.model.refilter();
}
......
......@@ -86,6 +86,7 @@ export interface ITreeNode<T, TFilterData = void> {
}
export interface ITreeModel<T, TFilterData, TRef> {
readonly rootRef: TRef;
readonly onDidChangeCollapseState: Event<ITreeNode<T, TFilterData>>;
readonly onDidChangeRenderNodeCount: Event<ITreeNode<T, TFilterData>>;
......@@ -101,8 +102,6 @@ export interface ITreeModel<T, TFilterData, TRef> {
isCollapsible(location: TRef): boolean;
isCollapsed(location: TRef): boolean;
setCollapsed(location: TRef, collapsed?: boolean, recursive?: boolean): boolean;
expandAll(): void;
collapseAll(): void;
refilter(): void;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册