Skip to content

Commit

Permalink
[tree] fix #3450: display node busy state
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Mar 1, 2020
1 parent 137b87c commit d848a02
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 21 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/browser/icons/chevron-right-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/core/src/browser/icons/chevron-right-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/core/src/browser/icons/loading-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/core/src/browser/icons/loading-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/core/src/browser/style/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@
.theia-add-icon {
background: var(--theia-icon-add) center center no-repeat;
}

@keyframes theia-spin {
100% {
transform:rotate(360deg);
}
}

.theia-animation-spin {
animation: theia-spin 1.5s linear infinite;
}
27 changes: 13 additions & 14 deletions packages/core/src/browser/style/tree.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,27 @@
}

.theia-ExpansionToggle {
min-width: 10px;
display: flex;
justify-content: center;
padding-left: calc(var(--theia-ui-padding)*2/3);
padding-right: calc(var(--theia-ui-padding)*2/3);
padding-left: calc(var(--theia-ui-padding)/2);
padding-right: calc(var(--theia-ui-padding)/2);
width: var(--theia-icon-size);
height: var(--theia-icon-size);
background-size: var(--theia-icon-size);
background: var(--theia-icon-chevron-right) center center no-repeat;
}

.theia-ExpansionToggle:hover {
cursor: pointer;
.theia-ExpansionToggle.theia-mod-busy {
background: var(--theia-icon-loading) center center no-repeat;
animation: theia-spin 1.25s linear infinite;
}

.theia-ExpansionToggle.theia-mod-collapsed::before {
font-family: FontAwesome;
font-size: calc(var(--theia-content-font-size) * 0.8);
content: "\f0da";
.theia-ExpansionToggle:not(.theia-mod-busy):hover {
cursor: pointer;
}

.theia-ExpansionToggle:not(.theia-mod-collapsed)::before {
font-family: FontAwesome;
font-size: calc(var(--theia-content-font-size) * 0.8);
content: "\f0da";
transform: rotate(45deg);
.theia-ExpansionToggle:not(.theia-mod-busy):not(.theia-mod-collapsed) {
transform: rotate(90deg);
}

.theia-Tree:focus .theia-TreeNode.theia-mod-selected,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/browser/style/variables-bright.useable.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ is not optimized for dense, information rich UIs.
--theia-ui-padding: 6px;

/* Icons */
--theia-icon-chevron-right: url(../icons/chevron-right-light.svg);
--theia-icon-loading: url(../icons/loading-light.svg);
--theia-icon-close: url(../icons/close-bright.svg);
--theia-icon-arrow-up: url(../icons/arrow-up-bright.svg);
--theia-icon-arrow-down: url(../icons/arrow-down-bright.svg);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/browser/style/variables-dark.useable.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ is not optimized for dense, information rich UIs.
--theia-ui-padding: 6px;

/* Icons */
--theia-icon-chevron-right: url(../icons/chevron-right-dark.svg);
--theia-icon-loading: url(../icons/loading-dark.svg);
--theia-icon-close: url(../icons/close-dark.svg);
--theia-icon-arrow-up: url(../icons/arrow-up-dark.svg);
--theia-icon-arrow-down: url(../icons/arrow-down-dark.svg);
Expand Down
15 changes: 13 additions & 2 deletions packages/core/src/browser/tree/tree-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
********************************************************************************/

import { inject, injectable, postConstruct } from 'inversify';
import { DisposableCollection, Event, Emitter, SelectionProvider, ILogger, WaitUntilEvent } from '../../common';
import { Event, Emitter, WaitUntilEvent } from '../../common/event';
import { DisposableCollection } from '../../common/disposable';
import { CancellationToken } from '../../common/cancellation';
import { ILogger } from '../../common/logger';
import { SelectionProvider, } from '../../common/selection-service';
import { Tree, TreeNode, CompositeTreeNode } from './tree';
import { TreeSelectionService, SelectableTreeNode, TreeSelection } from './tree-selection';
import { TreeExpansionService, ExpandableTreeNode } from './tree-expansion';
Expand Down Expand Up @@ -130,7 +134,6 @@ export interface TreeModel extends Tree, TreeSelectionService, TreeExpansionServ
* If no node was selected previously, invoking this method does nothing.
*/
selectRange(node: Readonly<SelectableTreeNode>): void;

}

@injectable()
Expand Down Expand Up @@ -431,6 +434,14 @@ export class TreeModelImpl implements TreeModel, SelectionProvider<ReadonlyArray
}
}

get onDidChangeBusy(): Event<TreeNode> {
return this.tree.onDidChangeBusy;
}

markAsBusy(node: Readonly<TreeNode>, ms: number, token: CancellationToken): Promise<void> {
return this.tree.markAsBusy(node, ms, token);
}

}
export namespace TreeModelImpl {
export interface State {
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/browser/tree/tree-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Disposable, MenuPath, SelectionService } from '../../common';
import { Key, KeyCode, KeyModifier } from '../keyboard/keys';
import { ContextMenuRenderer } from '../context-menu-renderer';
import { StatefulWidget } from '../shell';
import { EXPANSION_TOGGLE_CLASS, SELECTED_CLASS, COLLAPSED_CLASS, FOCUS_CLASS, Widget } from '../widgets';
import { EXPANSION_TOGGLE_CLASS, SELECTED_CLASS, COLLAPSED_CLASS, FOCUS_CLASS, Widget, BUSY_CLASS } from '../widgets';
import { TreeNode, CompositeTreeNode } from './tree';
import { TreeModel } from './tree-model';
import { ExpandableTreeNode } from './tree-expansion';
Expand Down Expand Up @@ -218,6 +218,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
this.model,
this.model.onChanged(() => this.updateRows()),
this.model.onSelectionChanged(() => this.updateScrollToRow({ resize: false })),
this.model.onDidChangeBusy(() => this.update()),
this.model.onNodeRefreshed(() => this.updateDecorations()),
this.model.onExpansionChanged(() => this.updateDecorations()),
this.decoratorService,
Expand Down Expand Up @@ -521,6 +522,9 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
if (!node.expanded) {
classes.push(COLLAPSED_CLASS);
}
if (node.busy) {
classes.push(BUSY_CLASS);
}
const className = classes.join(' ');
return <div
data-node-id={node.id}
Expand Down Expand Up @@ -1172,6 +1176,9 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
if ('nextSibling' in copy) {
delete copy.nextSibling;
}
if ('busy' in copy) {
delete copy.busy;
}
if (CompositeTreeNode.is(node)) {
copy.children = [];
for (const child of node.children) {
Expand Down
Loading

0 comments on commit d848a02

Please sign in to comment.