@theia/timeline 1.53.0-next.55 → 1.53.0-next.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,120 +1,120 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 RedHat and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable, inject } from '@theia/core/shared/inversify';
18
- import { CommandRegistry, MenuModelRegistry, MenuPath } from '@theia/core/lib/common';
19
- import { TreeWidget, TreeProps, NodeProps, TREE_NODE_SEGMENT_GROW_CLASS } from '@theia/core/lib/browser/tree';
20
- import { ContextMenuRenderer } from '@theia/core/lib/browser';
21
- import { TimelineNode, TimelineTreeModel } from './timeline-tree-model';
22
- import { TimelineService } from './timeline-service';
23
- import { TimelineContextKeyService } from './timeline-context-key-service';
24
- import * as React from '@theia/core/shared/react';
25
- import { TimelineItem } from '../common/timeline-model';
26
-
27
- export const TIMELINE_ITEM_CONTEXT_MENU: MenuPath = ['timeline-item-context-menu'];
28
-
29
- @injectable()
30
- export class TimelineTreeWidget extends TreeWidget {
31
-
32
- static ID = 'timeline-tree-widget';
33
- static PAGE_SIZE = 20;
34
-
35
- @inject(MenuModelRegistry) protected readonly menus: MenuModelRegistry;
36
- @inject(TimelineContextKeyService) protected readonly contextKeys: TimelineContextKeyService;
37
- @inject(TimelineService) protected readonly timelineService: TimelineService;
38
- @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
39
-
40
- constructor(
41
- @inject(TreeProps) props: TreeProps,
42
- @inject(TimelineTreeModel) override readonly model: TimelineTreeModel,
43
- @inject(ContextMenuRenderer) contextMenuRenderer: ContextMenuRenderer,
44
- ) {
45
- super(props, model, contextMenuRenderer);
46
- this.id = TimelineTreeWidget.ID;
47
- this.addClass('timeline-outer-container');
48
- }
49
-
50
- protected override renderNode(node: TimelineNode, props: NodeProps): React.ReactNode {
51
- const attributes = this.createNodeAttributes(node, props);
52
- const content = <TimelineItemNode
53
- timelineItem={node.timelineItem}
54
- commandRegistry={this.commandRegistry}
55
- contextKeys={this.contextKeys}
56
- contextMenuRenderer={this.contextMenuRenderer} />;
57
- return React.createElement('div', attributes, content);
58
- }
59
-
60
- protected override handleEnter(event: KeyboardEvent): void {
61
- const node = this.model.getFocusedNode() as TimelineNode;
62
- const command = node?.timelineItem?.command;
63
- if (command) {
64
- this.commandRegistry.executeCommand(command.id, ...(command.arguments ? command.arguments : []));
65
- }
66
- }
67
-
68
- protected override async handleLeft(event: KeyboardEvent): Promise<void> {
69
- this.model.selectPrevNode();
70
- }
71
- }
72
-
73
- export namespace TimelineItemNode {
74
- export interface Props {
75
- timelineItem: TimelineItem;
76
- commandRegistry: CommandRegistry;
77
- contextKeys: TimelineContextKeyService;
78
- contextMenuRenderer: ContextMenuRenderer;
79
- }
80
- }
81
-
82
- export class TimelineItemNode extends React.Component<TimelineItemNode.Props> {
83
- override render(): JSX.Element | undefined {
84
- const { label, description, detail } = this.props.timelineItem;
85
- return <div className='timeline-item'
86
- title={detail}
87
- onContextMenu={this.renderContextMenu}
88
- onClick={this.open}>
89
- <div className={`noWrapInfo ${TREE_NODE_SEGMENT_GROW_CLASS}`} >
90
- <span className='name'>{label}</span>
91
- <span className='label'>{description}</span>
92
- </div>
93
- </div>;
94
- }
95
-
96
- protected open = () => {
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- const command: any = this.props.timelineItem.command;
99
- if (command) {
100
- this.props.commandRegistry.executeCommand(command.id, ...command.arguments ? command.arguments : []);
101
- }
102
- };
103
-
104
- protected renderContextMenu = (event: React.MouseEvent<HTMLElement>) => {
105
- event.preventDefault();
106
- event.stopPropagation();
107
- const { timelineItem, contextKeys, contextMenuRenderer } = this.props;
108
- const currentTimelineItem = contextKeys.timelineItem.get();
109
- contextKeys.timelineItem.set(timelineItem.contextValue);
110
- try {
111
- contextMenuRenderer.render({
112
- menuPath: TIMELINE_ITEM_CONTEXT_MENU,
113
- anchor: event.nativeEvent,
114
- args: [timelineItem]
115
- });
116
- } finally {
117
- contextKeys.timelineItem.set(currentTimelineItem);
118
- }
119
- };
120
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 RedHat and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject } from '@theia/core/shared/inversify';
18
+ import { CommandRegistry, MenuModelRegistry, MenuPath } from '@theia/core/lib/common';
19
+ import { TreeWidget, TreeProps, NodeProps, TREE_NODE_SEGMENT_GROW_CLASS } from '@theia/core/lib/browser/tree';
20
+ import { ContextMenuRenderer } from '@theia/core/lib/browser';
21
+ import { TimelineNode, TimelineTreeModel } from './timeline-tree-model';
22
+ import { TimelineService } from './timeline-service';
23
+ import { TimelineContextKeyService } from './timeline-context-key-service';
24
+ import * as React from '@theia/core/shared/react';
25
+ import { TimelineItem } from '../common/timeline-model';
26
+
27
+ export const TIMELINE_ITEM_CONTEXT_MENU: MenuPath = ['timeline-item-context-menu'];
28
+
29
+ @injectable()
30
+ export class TimelineTreeWidget extends TreeWidget {
31
+
32
+ static ID = 'timeline-tree-widget';
33
+ static PAGE_SIZE = 20;
34
+
35
+ @inject(MenuModelRegistry) protected readonly menus: MenuModelRegistry;
36
+ @inject(TimelineContextKeyService) protected readonly contextKeys: TimelineContextKeyService;
37
+ @inject(TimelineService) protected readonly timelineService: TimelineService;
38
+ @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
39
+
40
+ constructor(
41
+ @inject(TreeProps) props: TreeProps,
42
+ @inject(TimelineTreeModel) override readonly model: TimelineTreeModel,
43
+ @inject(ContextMenuRenderer) contextMenuRenderer: ContextMenuRenderer,
44
+ ) {
45
+ super(props, model, contextMenuRenderer);
46
+ this.id = TimelineTreeWidget.ID;
47
+ this.addClass('timeline-outer-container');
48
+ }
49
+
50
+ protected override renderNode(node: TimelineNode, props: NodeProps): React.ReactNode {
51
+ const attributes = this.createNodeAttributes(node, props);
52
+ const content = <TimelineItemNode
53
+ timelineItem={node.timelineItem}
54
+ commandRegistry={this.commandRegistry}
55
+ contextKeys={this.contextKeys}
56
+ contextMenuRenderer={this.contextMenuRenderer} />;
57
+ return React.createElement('div', attributes, content);
58
+ }
59
+
60
+ protected override handleEnter(event: KeyboardEvent): void {
61
+ const node = this.model.getFocusedNode() as TimelineNode;
62
+ const command = node?.timelineItem?.command;
63
+ if (command) {
64
+ this.commandRegistry.executeCommand(command.id, ...(command.arguments ? command.arguments : []));
65
+ }
66
+ }
67
+
68
+ protected override async handleLeft(event: KeyboardEvent): Promise<void> {
69
+ this.model.selectPrevNode();
70
+ }
71
+ }
72
+
73
+ export namespace TimelineItemNode {
74
+ export interface Props {
75
+ timelineItem: TimelineItem;
76
+ commandRegistry: CommandRegistry;
77
+ contextKeys: TimelineContextKeyService;
78
+ contextMenuRenderer: ContextMenuRenderer;
79
+ }
80
+ }
81
+
82
+ export class TimelineItemNode extends React.Component<TimelineItemNode.Props> {
83
+ override render(): JSX.Element | undefined {
84
+ const { label, description, detail } = this.props.timelineItem;
85
+ return <div className='timeline-item'
86
+ title={detail}
87
+ onContextMenu={this.renderContextMenu}
88
+ onClick={this.open}>
89
+ <div className={`noWrapInfo ${TREE_NODE_SEGMENT_GROW_CLASS}`} >
90
+ <span className='name'>{label}</span>
91
+ <span className='label'>{description}</span>
92
+ </div>
93
+ </div>;
94
+ }
95
+
96
+ protected open = () => {
97
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
+ const command: any = this.props.timelineItem.command;
99
+ if (command) {
100
+ this.props.commandRegistry.executeCommand(command.id, ...command.arguments ? command.arguments : []);
101
+ }
102
+ };
103
+
104
+ protected renderContextMenu = (event: React.MouseEvent<HTMLElement>) => {
105
+ event.preventDefault();
106
+ event.stopPropagation();
107
+ const { timelineItem, contextKeys, contextMenuRenderer } = this.props;
108
+ const currentTimelineItem = contextKeys.timelineItem.get();
109
+ contextKeys.timelineItem.set(timelineItem.contextValue);
110
+ try {
111
+ contextMenuRenderer.render({
112
+ menuPath: TIMELINE_ITEM_CONTEXT_MENU,
113
+ anchor: event.nativeEvent,
114
+ args: [timelineItem]
115
+ });
116
+ } finally {
117
+ contextKeys.timelineItem.set(currentTimelineItem);
118
+ }
119
+ };
120
+ }
@@ -1,179 +1,179 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 RedHat and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { Message } from '@theia/core/shared/@phosphor/messaging';
18
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
19
- import {
20
- ApplicationShell,
21
- BaseWidget,
22
- MessageLoop, Navigatable,
23
- NavigatableWidget,
24
- Panel,
25
- PanelLayout
26
- } from '@theia/core/lib/browser';
27
- import { TimelineTreeWidget } from './timeline-tree-widget';
28
- import { TimelineService, TimelineAggregate } from './timeline-service';
29
- import { CommandRegistry, SelectionService } from '@theia/core/lib/common';
30
- import { TimelineEmptyWidget } from './timeline-empty-widget';
31
- import { toArray } from '@theia/core/shared/@phosphor/algorithm';
32
- import URI from '@theia/core/lib/common/uri';
33
- import { URI as CodeURI } from '@theia/core/shared/vscode-uri';
34
- import { nls } from '@theia/core/lib/common/nls';
35
-
36
- @injectable()
37
- export class TimelineWidget extends BaseWidget {
38
-
39
- protected panel: Panel;
40
- static ID = 'timeline-view';
41
-
42
- private readonly timelinesBySource = new Map<string, TimelineAggregate>();
43
-
44
- @inject(TimelineTreeWidget) protected readonly resourceWidget: TimelineTreeWidget;
45
- @inject(TimelineService) protected readonly timelineService: TimelineService;
46
- @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
47
- @inject(ApplicationShell) protected readonly applicationShell: ApplicationShell;
48
- @inject(TimelineEmptyWidget) protected readonly timelineEmptyWidget: TimelineEmptyWidget;
49
- @inject(SelectionService) protected readonly selectionService: SelectionService;
50
-
51
- constructor() {
52
- super();
53
- this.id = TimelineWidget.ID;
54
- this.title.label = nls.localizeByDefault('Timeline');
55
- this.title.caption = this.title.label;
56
- this.addClass('theia-timeline');
57
- }
58
-
59
- @postConstruct()
60
- protected init(): void {
61
- const layout = new PanelLayout();
62
- this.layout = layout;
63
- this.panel = new Panel({ layout: new PanelLayout({}) });
64
- this.panel.node.tabIndex = -1;
65
- layout.addWidget(this.panel);
66
- this.containerLayout!.addWidget(this.resourceWidget);
67
- this.containerLayout!.addWidget(this.timelineEmptyWidget);
68
-
69
- this.refresh();
70
- this.toDispose.push(this.timelineService.onDidChangeTimeline(event => {
71
- const currentWidgetUri = this.getCurrentWidgetUri();
72
- if (currentWidgetUri) {
73
- this.loadTimeline(currentWidgetUri, event.reset);
74
- }
75
- })
76
- );
77
- this.toDispose.push(this.selectionService.onSelectionChanged(selection => {
78
- if (Array.isArray(selection) && !!selection[0] && 'uri' in selection[0]) {
79
- this.refresh(selection[0].uri);
80
- }
81
- }));
82
- this.toDispose.push(this.applicationShell.onDidChangeCurrentWidget(async e => {
83
- if ((e.newValue && Navigatable.is(e.newValue)) || !this.suitableWidgetsOpened()) {
84
- this.refresh();
85
- }
86
- }));
87
- this.toDispose.push(this.applicationShell.onDidRemoveWidget(widget => {
88
- if (NavigatableWidget.is(widget)) {
89
- this.refresh();
90
- }
91
- }));
92
- this.toDispose.push(this.timelineService.onDidChangeProviders(() => this.refresh()));
93
- }
94
-
95
- protected async loadTimelineForSource(source: string, uri: CodeURI, reset: boolean): Promise<void> {
96
- if (reset) {
97
- this.timelinesBySource.delete(source);
98
- }
99
- let timeline = this.timelinesBySource.get(source);
100
- const cursor = timeline?.cursor;
101
- const options = { cursor: reset ? undefined : cursor, limit: TimelineTreeWidget.PAGE_SIZE };
102
- const timelineResult = await this.timelineService.getTimeline(source, uri, options, { cacheResults: true, resetCache: reset });
103
- if (timelineResult) {
104
- const items = timelineResult.items;
105
- if (items) {
106
- if (timeline) {
107
- timeline.add(items);
108
- timeline.cursor = timelineResult.paging?.cursor;
109
- } else {
110
- timeline = new TimelineAggregate(timelineResult);
111
- }
112
- this.timelinesBySource.set(source, timeline);
113
- this.resourceWidget.model.updateTree(timeline.items, !!timeline.cursor);
114
- }
115
- }
116
- }
117
-
118
- async loadTimeline(uri: URI, reset: boolean): Promise<void> {
119
- for (const source of this.timelineService.getSources().map(s => s.id)) {
120
- this.loadTimelineForSource(source, CodeURI.parse(uri.toString()), reset);
121
- }
122
- }
123
-
124
- refresh(uri?: URI): void {
125
- if (!uri) {
126
- uri = this.getCurrentWidgetUri();
127
- }
128
- if (uri) {
129
- this.timelineEmptyWidget.hide();
130
- this.resourceWidget.show();
131
- this.loadTimeline(uri, true);
132
- } else if (!this.suitableWidgetsOpened()) {
133
- this.timelineEmptyWidget.show();
134
- this.resourceWidget.hide();
135
- }
136
- }
137
-
138
- private suitableWidgetsOpened(): boolean {
139
- return !!toArray(this.applicationShell.mainPanel.widgets()).find(widget => {
140
- if (NavigatableWidget.is(widget)) {
141
- const uri = widget.getResourceUri();
142
- if (uri?.scheme && this.timelineService.getSchemas().indexOf(uri?.scheme) > -1) {
143
- return true;
144
- }
145
- }
146
- });
147
- }
148
-
149
- private getCurrentWidgetUri(): URI | undefined {
150
- let current = this.applicationShell.currentWidget;
151
- if (!NavigatableWidget.is(current)) {
152
- current = toArray(this.applicationShell.mainPanel.widgets()).find(widget => {
153
- if (widget.isVisible && !widget.isHidden) {
154
- return widget;
155
- }
156
- });
157
- }
158
- return NavigatableWidget.is(current) ? current.getResourceUri() : undefined;
159
- }
160
-
161
- protected get containerLayout(): PanelLayout | undefined {
162
- return this.panel.layout as PanelLayout;
163
- }
164
-
165
- protected override onUpdateRequest(msg: Message): void {
166
- MessageLoop.sendMessage(this.resourceWidget, msg);
167
- MessageLoop.sendMessage(this.timelineEmptyWidget, msg);
168
- this.refresh();
169
- super.onUpdateRequest(msg);
170
- }
171
-
172
- protected override onAfterAttach(msg: Message): void {
173
- this.node.appendChild(this.resourceWidget.node);
174
- this.node.appendChild(this.timelineEmptyWidget.node);
175
- super.onAfterAttach(msg);
176
- this.update();
177
- }
178
-
179
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 RedHat and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { Message } from '@theia/core/shared/@phosphor/messaging';
18
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
19
+ import {
20
+ ApplicationShell,
21
+ BaseWidget,
22
+ MessageLoop, Navigatable,
23
+ NavigatableWidget,
24
+ Panel,
25
+ PanelLayout
26
+ } from '@theia/core/lib/browser';
27
+ import { TimelineTreeWidget } from './timeline-tree-widget';
28
+ import { TimelineService, TimelineAggregate } from './timeline-service';
29
+ import { CommandRegistry, SelectionService } from '@theia/core/lib/common';
30
+ import { TimelineEmptyWidget } from './timeline-empty-widget';
31
+ import { toArray } from '@theia/core/shared/@phosphor/algorithm';
32
+ import URI from '@theia/core/lib/common/uri';
33
+ import { URI as CodeURI } from '@theia/core/shared/vscode-uri';
34
+ import { nls } from '@theia/core/lib/common/nls';
35
+
36
+ @injectable()
37
+ export class TimelineWidget extends BaseWidget {
38
+
39
+ protected panel: Panel;
40
+ static ID = 'timeline-view';
41
+
42
+ private readonly timelinesBySource = new Map<string, TimelineAggregate>();
43
+
44
+ @inject(TimelineTreeWidget) protected readonly resourceWidget: TimelineTreeWidget;
45
+ @inject(TimelineService) protected readonly timelineService: TimelineService;
46
+ @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
47
+ @inject(ApplicationShell) protected readonly applicationShell: ApplicationShell;
48
+ @inject(TimelineEmptyWidget) protected readonly timelineEmptyWidget: TimelineEmptyWidget;
49
+ @inject(SelectionService) protected readonly selectionService: SelectionService;
50
+
51
+ constructor() {
52
+ super();
53
+ this.id = TimelineWidget.ID;
54
+ this.title.label = nls.localizeByDefault('Timeline');
55
+ this.title.caption = this.title.label;
56
+ this.addClass('theia-timeline');
57
+ }
58
+
59
+ @postConstruct()
60
+ protected init(): void {
61
+ const layout = new PanelLayout();
62
+ this.layout = layout;
63
+ this.panel = new Panel({ layout: new PanelLayout({}) });
64
+ this.panel.node.tabIndex = -1;
65
+ layout.addWidget(this.panel);
66
+ this.containerLayout!.addWidget(this.resourceWidget);
67
+ this.containerLayout!.addWidget(this.timelineEmptyWidget);
68
+
69
+ this.refresh();
70
+ this.toDispose.push(this.timelineService.onDidChangeTimeline(event => {
71
+ const currentWidgetUri = this.getCurrentWidgetUri();
72
+ if (currentWidgetUri) {
73
+ this.loadTimeline(currentWidgetUri, event.reset);
74
+ }
75
+ })
76
+ );
77
+ this.toDispose.push(this.selectionService.onSelectionChanged(selection => {
78
+ if (Array.isArray(selection) && !!selection[0] && 'uri' in selection[0]) {
79
+ this.refresh(selection[0].uri);
80
+ }
81
+ }));
82
+ this.toDispose.push(this.applicationShell.onDidChangeCurrentWidget(async e => {
83
+ if ((e.newValue && Navigatable.is(e.newValue)) || !this.suitableWidgetsOpened()) {
84
+ this.refresh();
85
+ }
86
+ }));
87
+ this.toDispose.push(this.applicationShell.onDidRemoveWidget(widget => {
88
+ if (NavigatableWidget.is(widget)) {
89
+ this.refresh();
90
+ }
91
+ }));
92
+ this.toDispose.push(this.timelineService.onDidChangeProviders(() => this.refresh()));
93
+ }
94
+
95
+ protected async loadTimelineForSource(source: string, uri: CodeURI, reset: boolean): Promise<void> {
96
+ if (reset) {
97
+ this.timelinesBySource.delete(source);
98
+ }
99
+ let timeline = this.timelinesBySource.get(source);
100
+ const cursor = timeline?.cursor;
101
+ const options = { cursor: reset ? undefined : cursor, limit: TimelineTreeWidget.PAGE_SIZE };
102
+ const timelineResult = await this.timelineService.getTimeline(source, uri, options, { cacheResults: true, resetCache: reset });
103
+ if (timelineResult) {
104
+ const items = timelineResult.items;
105
+ if (items) {
106
+ if (timeline) {
107
+ timeline.add(items);
108
+ timeline.cursor = timelineResult.paging?.cursor;
109
+ } else {
110
+ timeline = new TimelineAggregate(timelineResult);
111
+ }
112
+ this.timelinesBySource.set(source, timeline);
113
+ this.resourceWidget.model.updateTree(timeline.items, !!timeline.cursor);
114
+ }
115
+ }
116
+ }
117
+
118
+ async loadTimeline(uri: URI, reset: boolean): Promise<void> {
119
+ for (const source of this.timelineService.getSources().map(s => s.id)) {
120
+ this.loadTimelineForSource(source, CodeURI.parse(uri.toString()), reset);
121
+ }
122
+ }
123
+
124
+ refresh(uri?: URI): void {
125
+ if (!uri) {
126
+ uri = this.getCurrentWidgetUri();
127
+ }
128
+ if (uri) {
129
+ this.timelineEmptyWidget.hide();
130
+ this.resourceWidget.show();
131
+ this.loadTimeline(uri, true);
132
+ } else if (!this.suitableWidgetsOpened()) {
133
+ this.timelineEmptyWidget.show();
134
+ this.resourceWidget.hide();
135
+ }
136
+ }
137
+
138
+ private suitableWidgetsOpened(): boolean {
139
+ return !!toArray(this.applicationShell.mainPanel.widgets()).find(widget => {
140
+ if (NavigatableWidget.is(widget)) {
141
+ const uri = widget.getResourceUri();
142
+ if (uri?.scheme && this.timelineService.getSchemas().indexOf(uri?.scheme) > -1) {
143
+ return true;
144
+ }
145
+ }
146
+ });
147
+ }
148
+
149
+ private getCurrentWidgetUri(): URI | undefined {
150
+ let current = this.applicationShell.currentWidget;
151
+ if (!NavigatableWidget.is(current)) {
152
+ current = toArray(this.applicationShell.mainPanel.widgets()).find(widget => {
153
+ if (widget.isVisible && !widget.isHidden) {
154
+ return widget;
155
+ }
156
+ });
157
+ }
158
+ return NavigatableWidget.is(current) ? current.getResourceUri() : undefined;
159
+ }
160
+
161
+ protected get containerLayout(): PanelLayout | undefined {
162
+ return this.panel.layout as PanelLayout;
163
+ }
164
+
165
+ protected override onUpdateRequest(msg: Message): void {
166
+ MessageLoop.sendMessage(this.resourceWidget, msg);
167
+ MessageLoop.sendMessage(this.timelineEmptyWidget, msg);
168
+ this.refresh();
169
+ super.onUpdateRequest(msg);
170
+ }
171
+
172
+ protected override onAfterAttach(msg: Message): void {
173
+ this.node.appendChild(this.resourceWidget.node);
174
+ this.node.appendChild(this.timelineEmptyWidget.node);
175
+ super.onAfterAttach(msg);
176
+ this.update();
177
+ }
178
+
179
+ }