Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce CompressibleObjectTree #77876

Merged
merged 23 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c0753cb
introduce CompressibleObjectTreeModel
joaomoreno Jul 24, 2019
6e091c4
CompressibleObjectTree
joaomoreno Jul 24, 2019
0a3fc51
relax splice/setChildren return value
joaomoreno Jul 24, 2019
f46a733
CompressibleObjectTree: getting ready for testing
joaomoreno Jul 24, 2019
e8685cb
Merge remote-tracking branch 'origin/master' into joao/compressed-trees
joaomoreno Jul 24, 2019
678141f
remove ITreeNode.parent and ITreeModel.getParentElement
joaomoreno Jul 24, 2019
70a6210
first CompressibleObjectTree test
joaomoreno Jul 24, 2019
3641571
more CompressibleObjectTree tests
joaomoreno Jul 24, 2019
7d58131
CompressibleObjectTree tests: enableCompression
joaomoreno Jul 24, 2019
9acc66e
Merge branch 'master' into joao/compressed-trees
joaomoreno Sep 9, 2019
7434a77
fix manual tree tests
joaomoreno Sep 9, 2019
0a15552
compressed object tree model: use proxy
joaomoreno Sep 9, 2019
4cad4df
Merge branch 'master' into joao/compressed-trees
joaomoreno Sep 10, 2019
435ce2e
wip: CompressibleAsyncDataTree
joaomoreno Sep 10, 2019
60fa1de
wip: more tree node mappers
joaomoreno Sep 10, 2019
6fbb757
wip: comment out bad code
joaomoreno Sep 10, 2019
2353dde
Merge remote-tracking branch 'origin/master' into joao/compressed-trees
joaomoreno Sep 11, 2019
b1c9430
CompressibleAsyncDataTree
joaomoreno Sep 11, 2019
ee6db8c
fixed AsyncDataTree.asTreeElement
joaomoreno Sep 11, 2019
cee8dae
undo explorer work
joaomoreno Sep 11, 2019
ab021bf
remove proxy usage
joaomoreno Sep 11, 2019
69b97db
Merge branch 'master' into joao/compressed-trees
joaomoreno Sep 11, 2019
3d93cac
Merge branch 'master' into joao/compressed-trees
joaomoreno Sep 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/list/listWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ export interface IListStyles {
}

const defaultStyles: IListStyles = {
listFocusBackground: Color.fromHex('#073655'),
listFocusBackground: Color.fromHex('#7FB0D0'),
listActiveSelectionBackground: Color.fromHex('#0E639C'),
listActiveSelectionForeground: Color.fromHex('#FFFFFF'),
listFocusAndSelectionBackground: Color.fromHex('#094771'),
Expand Down
63 changes: 35 additions & 28 deletions src/vs/base/browser/ui/tree/abstractTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ class TreeNodeListDragAndDrop<T, TFilterData, TRef> implements IListDragAndDrop<
}

if (result.bubble === TreeDragOverBubble.Up) {
const parentNode = targetNode.parent;
const model = this.modelProvider();
const parentIndex = parentNode && model.getListIndex(model.getNodeLocation(parentNode));
const ref = model.getNodeLocation(targetNode);
const parentRef = model.getParentNodeLocation(ref);
const parentNode = model.getNode(parentRef);
const parentIndex = parentRef && model.getListIndex(parentRef);

return this.onDragOver(data, parentNode, parentIndex, originalEvent, false);
}
Expand Down Expand Up @@ -155,7 +157,12 @@ function asListOptions<T, TFilterData, TRef>(modelProvider: () => ITreeModel<T,
enableKeyboardNavigation: options.simpleKeyboardNavigation,
ariaProvider: {
getSetSize(node) {
return node.parent!.visibleChildrenCount;
const model = modelProvider();
const ref = model.getNodeLocation(node);
const parentRef = model.getParentNodeLocation(ref);
const parentNode = model.getNode(parentRef);

return parentNode.visibleChildrenCount;
},
getPosInSet(node) {
return node.visibleChildIndex + 1;
Expand Down Expand Up @@ -233,7 +240,7 @@ class EventCollection<T> implements Collection<T> {
}
}

class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITreeNode<T, TFilterData>, ITreeListTemplateData<TTemplateData>> {
class TreeRenderer<T, TFilterData, TRef, TTemplateData> implements IListRenderer<ITreeNode<T, TFilterData>, ITreeListTemplateData<TTemplateData>> {

private static DefaultIndent = 8;

Expand All @@ -251,6 +258,7 @@ class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITree

constructor(
private renderer: ITreeRenderer<T, TFilterData, TTemplateData>,
private modelProvider: () => ITreeModel<T, TFilterData, TRef>,
onDidChangeCollapseState: Event<ICollapseStateChangeEvent<T, TFilterData>>,
private activeNodes: Collection<ITreeNode<T, TFilterData>>,
options: ITreeRendererOptions = {}
Expand Down Expand Up @@ -381,10 +389,19 @@ class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITree
}

const disposableStore = new DisposableStore();
const model = this.modelProvider();

let node = target;

while (node.parent && node.parent.parent) {
const parent = node.parent;
while (true) {
const ref = model.getNodeLocation(node);
const parentRef = model.getParentNodeLocation(ref);

if (!parentRef) {
break;
}

const parent = model.getNode(parentRef);
const guide = $<HTMLDivElement>('.indent-guide', { style: `width: ${this.indent}px` });

if (this.activeIndentNodes.has(parent)) {
Expand Down Expand Up @@ -412,12 +429,16 @@ class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITree
}

const set = new Set<ITreeNode<T, TFilterData>>();
const model = this.modelProvider();

nodes.forEach(node => {
const ref = model.getNodeLocation(node);
const parentRef = model.getParentNodeLocation(ref);

if (node.collapsible && node.children.length > 0 && !node.collapsed) {
set.add(node);
} else if (node.parent) {
set.add(node.parent);
} else if (parentRef) {
set.add(model.getNode(parentRef));
}
});

Expand Down Expand Up @@ -1153,7 +1174,7 @@ class TreeNodeList<T, TFilterData, TRef> extends List<ITreeNode<T, TFilterData>>
export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable {

protected view: TreeNodeList<T, TFilterData, TRef>;
private renderers: TreeRenderer<T, TFilterData, any>[];
private renderers: TreeRenderer<T, TFilterData, TRef, any>[];
protected model: ITreeModel<T, TFilterData, TRef>;
private focus: Trait<T>;
private selection: Trait<T>;
Expand Down Expand Up @@ -1211,7 +1232,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
const activeNodes = new EventCollection(onDidChangeActiveNodes.event);
this.disposables.push(activeNodes);

this.renderers = renderers.map(r => new TreeRenderer<T, TFilterData, any>(r, onDidChangeCollapseStateRelay.event, activeNodes, _options));
this.renderers = renderers.map(r => new TreeRenderer<T, TFilterData, TRef, any>(r, () => this.model, onDidChangeCollapseStateRelay.event, activeNodes, _options));
this.disposables.push(...this.renderers);

let filter: TypeFilter<T> | undefined;
Expand Down Expand Up @@ -1383,7 +1404,9 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
// Tree navigation

getParentElement(location: TRef): T {
return this.model.getParentElement(location);
const parentRef = this.model.getParentNodeLocation(location);
const parentNode = this.model.getNode(parentRef);
return parentNode.element;
}

getFirstElementChild(location: TRef): T | undefined {
Expand Down Expand Up @@ -1539,7 +1562,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
if (!didChange) {
const parentLocation = this.model.getParentNodeLocation(location);

if (parentLocation === null) {
if (!parentLocation) {
return;
}

Expand Down Expand Up @@ -1641,22 +1664,6 @@ class TreeNavigator<T extends NonNullable<any>, TFilterData, TRef> implements IT
return this.current();
}

parent(): T | null {
if (this.index < 0 || this.index >= this.view.length) {
return null;
}

const node = this.view.element(this.index);

if (!node.parent) {
this.index = -1;
return this.current();
}

this.index = this.model.getListIndex(this.model.getNodeLocation(node.parent));
return this.current();
}

first(): T | null {
this.index = 0;
return this.current();
Expand Down
Loading