@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.
- package/README.md +30 -30
- package/package.json +4 -4
- package/src/browser/style/index.css +49 -49
- package/src/browser/timeline-context-key-service.ts +36 -36
- package/src/browser/timeline-contribution.ts +112 -112
- package/src/browser/timeline-empty-widget.tsx +40 -40
- package/src/browser/timeline-frontend-module.ts +71 -71
- package/src/browser/timeline-service.ts +124 -124
- package/src/browser/timeline-tree-model.ts +72 -72
- package/src/browser/timeline-tree-widget.tsx +120 -120
- package/src/browser/timeline-widget.tsx +179 -179
- package/src/common/timeline-model.ts +84 -84
- package/src/package.spec.ts +29 -29
|
@@ -1,71 +1,71 @@
|
|
|
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 { Container, ContainerModule, interfaces } from '@theia/core/shared/inversify';
|
|
18
|
-
import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
|
|
19
|
-
import { TimelineService } from './timeline-service';
|
|
20
|
-
import { TimelineWidget } from './timeline-widget';
|
|
21
|
-
import { TimelineTreeWidget } from './timeline-tree-widget';
|
|
22
|
-
import { createTreeContainer, } from '@theia/core/lib/browser';
|
|
23
|
-
import { TimelineTreeModel } from './timeline-tree-model';
|
|
24
|
-
import { TimelineEmptyWidget } from './timeline-empty-widget';
|
|
25
|
-
import { TimelineContextKeyService } from './timeline-context-key-service';
|
|
26
|
-
import { TimelineContribution } from './timeline-contribution';
|
|
27
|
-
|
|
28
|
-
import '../../src/browser/style/index.css';
|
|
29
|
-
import { CommandContribution } from '@theia/core/lib/common';
|
|
30
|
-
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
31
|
-
|
|
32
|
-
export default new ContainerModule(bind => {
|
|
33
|
-
bind(TimelineContribution).toSelf().inSingletonScope();
|
|
34
|
-
bind(CommandContribution).toService(TimelineContribution);
|
|
35
|
-
bind(TabBarToolbarContribution).toService(TimelineContribution);
|
|
36
|
-
|
|
37
|
-
bind(TimelineContextKeyService).toSelf().inSingletonScope();
|
|
38
|
-
bind(TimelineService).toSelf().inSingletonScope();
|
|
39
|
-
|
|
40
|
-
bind(TimelineWidget).toSelf();
|
|
41
|
-
bind(WidgetFactory).toDynamicValue(({ container }) => ({
|
|
42
|
-
id: TimelineWidget.ID,
|
|
43
|
-
createWidget: () => container.get(TimelineWidget)
|
|
44
|
-
})).inSingletonScope();
|
|
45
|
-
bind(TimelineTreeWidget).toDynamicValue(ctx => {
|
|
46
|
-
const child = createTimelineTreeContainer(ctx.container);
|
|
47
|
-
return child.get(TimelineTreeWidget);
|
|
48
|
-
});
|
|
49
|
-
bind(WidgetFactory).toDynamicValue(({ container }) => ({
|
|
50
|
-
id: TimelineTreeWidget.ID,
|
|
51
|
-
createWidget: () => container.get(TimelineTreeWidget)
|
|
52
|
-
})).inSingletonScope();
|
|
53
|
-
bind(TimelineEmptyWidget).toSelf();
|
|
54
|
-
bind(WidgetFactory).toDynamicValue(({ container }) => ({
|
|
55
|
-
id: TimelineEmptyWidget.ID,
|
|
56
|
-
createWidget: () => container.get(TimelineEmptyWidget)
|
|
57
|
-
})).inSingletonScope();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
export function createTimelineTreeContainer(parent: interfaces.Container): Container {
|
|
61
|
-
const child = createTreeContainer(parent, {
|
|
62
|
-
props: {
|
|
63
|
-
virtualized: true,
|
|
64
|
-
search: true
|
|
65
|
-
},
|
|
66
|
-
widget: TimelineTreeWidget,
|
|
67
|
-
model: TimelineTreeModel
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return child;
|
|
71
|
-
}
|
|
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 { Container, ContainerModule, interfaces } from '@theia/core/shared/inversify';
|
|
18
|
+
import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
|
|
19
|
+
import { TimelineService } from './timeline-service';
|
|
20
|
+
import { TimelineWidget } from './timeline-widget';
|
|
21
|
+
import { TimelineTreeWidget } from './timeline-tree-widget';
|
|
22
|
+
import { createTreeContainer, } from '@theia/core/lib/browser';
|
|
23
|
+
import { TimelineTreeModel } from './timeline-tree-model';
|
|
24
|
+
import { TimelineEmptyWidget } from './timeline-empty-widget';
|
|
25
|
+
import { TimelineContextKeyService } from './timeline-context-key-service';
|
|
26
|
+
import { TimelineContribution } from './timeline-contribution';
|
|
27
|
+
|
|
28
|
+
import '../../src/browser/style/index.css';
|
|
29
|
+
import { CommandContribution } from '@theia/core/lib/common';
|
|
30
|
+
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
31
|
+
|
|
32
|
+
export default new ContainerModule(bind => {
|
|
33
|
+
bind(TimelineContribution).toSelf().inSingletonScope();
|
|
34
|
+
bind(CommandContribution).toService(TimelineContribution);
|
|
35
|
+
bind(TabBarToolbarContribution).toService(TimelineContribution);
|
|
36
|
+
|
|
37
|
+
bind(TimelineContextKeyService).toSelf().inSingletonScope();
|
|
38
|
+
bind(TimelineService).toSelf().inSingletonScope();
|
|
39
|
+
|
|
40
|
+
bind(TimelineWidget).toSelf();
|
|
41
|
+
bind(WidgetFactory).toDynamicValue(({ container }) => ({
|
|
42
|
+
id: TimelineWidget.ID,
|
|
43
|
+
createWidget: () => container.get(TimelineWidget)
|
|
44
|
+
})).inSingletonScope();
|
|
45
|
+
bind(TimelineTreeWidget).toDynamicValue(ctx => {
|
|
46
|
+
const child = createTimelineTreeContainer(ctx.container);
|
|
47
|
+
return child.get(TimelineTreeWidget);
|
|
48
|
+
});
|
|
49
|
+
bind(WidgetFactory).toDynamicValue(({ container }) => ({
|
|
50
|
+
id: TimelineTreeWidget.ID,
|
|
51
|
+
createWidget: () => container.get(TimelineTreeWidget)
|
|
52
|
+
})).inSingletonScope();
|
|
53
|
+
bind(TimelineEmptyWidget).toSelf();
|
|
54
|
+
bind(WidgetFactory).toDynamicValue(({ container }) => ({
|
|
55
|
+
id: TimelineEmptyWidget.ID,
|
|
56
|
+
createWidget: () => container.get(TimelineEmptyWidget)
|
|
57
|
+
})).inSingletonScope();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export function createTimelineTreeContainer(parent: interfaces.Container): Container {
|
|
61
|
+
const child = createTreeContainer(parent, {
|
|
62
|
+
props: {
|
|
63
|
+
virtualized: true,
|
|
64
|
+
search: true
|
|
65
|
+
},
|
|
66
|
+
widget: TimelineTreeWidget,
|
|
67
|
+
model: TimelineTreeModel
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return child;
|
|
71
|
+
}
|
|
@@ -1,124 +1,124 @@
|
|
|
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 } from '@theia/core/shared/inversify';
|
|
18
|
-
import { Disposable, Emitter, Event } from '@theia/core/lib/common';
|
|
19
|
-
import { URI } from '@theia/core/shared/vscode-uri';
|
|
20
|
-
import {
|
|
21
|
-
InternalTimelineOptions,
|
|
22
|
-
Timeline,
|
|
23
|
-
TimelineChangeEvent, TimelineItem, TimelineOptions,
|
|
24
|
-
TimelineProvider,
|
|
25
|
-
TimelineProvidersChangeEvent,
|
|
26
|
-
TimelineSource
|
|
27
|
-
} from '../common/timeline-model';
|
|
28
|
-
|
|
29
|
-
@injectable()
|
|
30
|
-
export class TimelineService {
|
|
31
|
-
private readonly providers = new Map<string, TimelineProvider>();
|
|
32
|
-
|
|
33
|
-
private readonly onDidChangeProvidersEmitter = new Emitter<TimelineProvidersChangeEvent>();
|
|
34
|
-
readonly onDidChangeProviders: Event<TimelineProvidersChangeEvent> = this.onDidChangeProvidersEmitter.event;
|
|
35
|
-
|
|
36
|
-
private readonly onDidChangeTimelineEmitter = new Emitter<TimelineChangeEvent>();
|
|
37
|
-
readonly onDidChangeTimeline: Event<TimelineChangeEvent> = this.onDidChangeTimelineEmitter.event;
|
|
38
|
-
|
|
39
|
-
registerTimelineProvider(provider: TimelineProvider): Disposable {
|
|
40
|
-
const id = provider.id;
|
|
41
|
-
|
|
42
|
-
this.providers.set(id, provider);
|
|
43
|
-
if (provider.onDidChange) {
|
|
44
|
-
provider.onDidChange(e => this.onDidChangeTimelineEmitter.fire(e));
|
|
45
|
-
}
|
|
46
|
-
this.onDidChangeProvidersEmitter.fire({ added: [id] });
|
|
47
|
-
|
|
48
|
-
return Disposable.create(() => this.unregisterTimelineProvider(id));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
unregisterTimelineProvider(id: string): void {
|
|
52
|
-
const provider = this.providers.get(id);
|
|
53
|
-
if (provider) {
|
|
54
|
-
provider.dispose();
|
|
55
|
-
this.providers.delete(id);
|
|
56
|
-
this.onDidChangeProvidersEmitter.fire({ removed: [id] });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
getSources(): TimelineSource[] {
|
|
61
|
-
return [...this.providers.values()].map(p => ({ id: p.id, label: p.label }));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
getSchemas(): string[] {
|
|
65
|
-
const result: string[] = [];
|
|
66
|
-
Array.from(this.providers.values()).forEach(provider => {
|
|
67
|
-
const scheme = provider.scheme;
|
|
68
|
-
if (typeof scheme === 'string') {
|
|
69
|
-
result.push(scheme);
|
|
70
|
-
} else {
|
|
71
|
-
scheme.forEach(s => result.push(s));
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
getTimeline(id: string, uri: URI, options: TimelineOptions, internalOptions?: InternalTimelineOptions): Promise<Timeline | undefined> {
|
|
78
|
-
const provider = this.providers.get(id);
|
|
79
|
-
if (!provider) {
|
|
80
|
-
return Promise.resolve(undefined);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (typeof provider.scheme === 'string') {
|
|
84
|
-
if (provider.scheme !== '*' && provider.scheme !== uri.scheme) {
|
|
85
|
-
return Promise.resolve(undefined);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return provider.provideTimeline(uri, options, internalOptions)
|
|
90
|
-
.then(result => {
|
|
91
|
-
if (!result) {
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
result.items = result.items.map(item => ({ ...item, source: provider.id }));
|
|
95
|
-
return result;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export class TimelineAggregate {
|
|
101
|
-
readonly items: TimelineItem[];
|
|
102
|
-
readonly source: string;
|
|
103
|
-
readonly uri: string;
|
|
104
|
-
|
|
105
|
-
private _cursor?: string;
|
|
106
|
-
get cursor(): string | undefined {
|
|
107
|
-
return this._cursor;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
set cursor(cursor: string | undefined) {
|
|
111
|
-
this._cursor = cursor;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
constructor(timeline: Timeline) {
|
|
115
|
-
this.source = timeline.source;
|
|
116
|
-
this.items = timeline.items;
|
|
117
|
-
this._cursor = timeline.paging?.cursor;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
add(items: TimelineItem[]): void {
|
|
121
|
-
this.items.push(...items);
|
|
122
|
-
this.items.sort((a, b) => b.timestamp - a.timestamp);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
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 } from '@theia/core/shared/inversify';
|
|
18
|
+
import { Disposable, Emitter, Event } from '@theia/core/lib/common';
|
|
19
|
+
import { URI } from '@theia/core/shared/vscode-uri';
|
|
20
|
+
import {
|
|
21
|
+
InternalTimelineOptions,
|
|
22
|
+
Timeline,
|
|
23
|
+
TimelineChangeEvent, TimelineItem, TimelineOptions,
|
|
24
|
+
TimelineProvider,
|
|
25
|
+
TimelineProvidersChangeEvent,
|
|
26
|
+
TimelineSource
|
|
27
|
+
} from '../common/timeline-model';
|
|
28
|
+
|
|
29
|
+
@injectable()
|
|
30
|
+
export class TimelineService {
|
|
31
|
+
private readonly providers = new Map<string, TimelineProvider>();
|
|
32
|
+
|
|
33
|
+
private readonly onDidChangeProvidersEmitter = new Emitter<TimelineProvidersChangeEvent>();
|
|
34
|
+
readonly onDidChangeProviders: Event<TimelineProvidersChangeEvent> = this.onDidChangeProvidersEmitter.event;
|
|
35
|
+
|
|
36
|
+
private readonly onDidChangeTimelineEmitter = new Emitter<TimelineChangeEvent>();
|
|
37
|
+
readonly onDidChangeTimeline: Event<TimelineChangeEvent> = this.onDidChangeTimelineEmitter.event;
|
|
38
|
+
|
|
39
|
+
registerTimelineProvider(provider: TimelineProvider): Disposable {
|
|
40
|
+
const id = provider.id;
|
|
41
|
+
|
|
42
|
+
this.providers.set(id, provider);
|
|
43
|
+
if (provider.onDidChange) {
|
|
44
|
+
provider.onDidChange(e => this.onDidChangeTimelineEmitter.fire(e));
|
|
45
|
+
}
|
|
46
|
+
this.onDidChangeProvidersEmitter.fire({ added: [id] });
|
|
47
|
+
|
|
48
|
+
return Disposable.create(() => this.unregisterTimelineProvider(id));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
unregisterTimelineProvider(id: string): void {
|
|
52
|
+
const provider = this.providers.get(id);
|
|
53
|
+
if (provider) {
|
|
54
|
+
provider.dispose();
|
|
55
|
+
this.providers.delete(id);
|
|
56
|
+
this.onDidChangeProvidersEmitter.fire({ removed: [id] });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
getSources(): TimelineSource[] {
|
|
61
|
+
return [...this.providers.values()].map(p => ({ id: p.id, label: p.label }));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getSchemas(): string[] {
|
|
65
|
+
const result: string[] = [];
|
|
66
|
+
Array.from(this.providers.values()).forEach(provider => {
|
|
67
|
+
const scheme = provider.scheme;
|
|
68
|
+
if (typeof scheme === 'string') {
|
|
69
|
+
result.push(scheme);
|
|
70
|
+
} else {
|
|
71
|
+
scheme.forEach(s => result.push(s));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getTimeline(id: string, uri: URI, options: TimelineOptions, internalOptions?: InternalTimelineOptions): Promise<Timeline | undefined> {
|
|
78
|
+
const provider = this.providers.get(id);
|
|
79
|
+
if (!provider) {
|
|
80
|
+
return Promise.resolve(undefined);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (typeof provider.scheme === 'string') {
|
|
84
|
+
if (provider.scheme !== '*' && provider.scheme !== uri.scheme) {
|
|
85
|
+
return Promise.resolve(undefined);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return provider.provideTimeline(uri, options, internalOptions)
|
|
90
|
+
.then(result => {
|
|
91
|
+
if (!result) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
result.items = result.items.map(item => ({ ...item, source: provider.id }));
|
|
95
|
+
return result;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class TimelineAggregate {
|
|
101
|
+
readonly items: TimelineItem[];
|
|
102
|
+
readonly source: string;
|
|
103
|
+
readonly uri: string;
|
|
104
|
+
|
|
105
|
+
private _cursor?: string;
|
|
106
|
+
get cursor(): string | undefined {
|
|
107
|
+
return this._cursor;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
set cursor(cursor: string | undefined) {
|
|
111
|
+
this._cursor = cursor;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
constructor(timeline: Timeline) {
|
|
115
|
+
this.source = timeline.source;
|
|
116
|
+
this.items = timeline.items;
|
|
117
|
+
this._cursor = timeline.paging?.cursor;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
add(items: TimelineItem[]): void {
|
|
121
|
+
this.items.push(...items);
|
|
122
|
+
this.items.sort((a, b) => b.timestamp - a.timestamp);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -1,72 +1,72 @@
|
|
|
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 } from '@theia/core/shared/inversify';
|
|
18
|
-
import {
|
|
19
|
-
CompositeTreeNode,
|
|
20
|
-
SelectableTreeNode,
|
|
21
|
-
TreeModelImpl,
|
|
22
|
-
} from '@theia/core/lib/browser/tree';
|
|
23
|
-
import { TimelineItem } from '../common/timeline-model';
|
|
24
|
-
import { Command } from '@theia/core';
|
|
25
|
-
|
|
26
|
-
export const LOAD_MORE_COMMAND: Command = {
|
|
27
|
-
id: 'timeline-load-more'
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export interface TimelineNode extends SelectableTreeNode {
|
|
31
|
-
timelineItem: TimelineItem;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@injectable()
|
|
35
|
-
export class TimelineTreeModel extends TreeModelImpl {
|
|
36
|
-
|
|
37
|
-
updateTree(items: TimelineItem[], hasMoreItems: boolean): void {
|
|
38
|
-
const root = {
|
|
39
|
-
id: 'timeline-tree-root',
|
|
40
|
-
parent: undefined,
|
|
41
|
-
visible: false,
|
|
42
|
-
children: []
|
|
43
|
-
} as CompositeTreeNode;
|
|
44
|
-
const children = items.map(item =>
|
|
45
|
-
({
|
|
46
|
-
timelineItem: item,
|
|
47
|
-
id: item.id ? item.id : item.timestamp.toString(),
|
|
48
|
-
parent: root,
|
|
49
|
-
detail: item.detail,
|
|
50
|
-
selected: false,
|
|
51
|
-
visible: true
|
|
52
|
-
} as TimelineNode)
|
|
53
|
-
);
|
|
54
|
-
let loadMore;
|
|
55
|
-
if (hasMoreItems) {
|
|
56
|
-
const loadMoreNode: TimelineItem = { label: 'Load-more', timestamp: 0, handle: '', uri: '', source: '' };
|
|
57
|
-
loadMoreNode.command = LOAD_MORE_COMMAND;
|
|
58
|
-
loadMore = {
|
|
59
|
-
timelineItem: loadMoreNode,
|
|
60
|
-
id: 'load-more',
|
|
61
|
-
parent: root,
|
|
62
|
-
selected: true
|
|
63
|
-
} as TimelineNode;
|
|
64
|
-
children.push(loadMore);
|
|
65
|
-
}
|
|
66
|
-
root.children = children;
|
|
67
|
-
this.root = root;
|
|
68
|
-
if (loadMore) {
|
|
69
|
-
this.selectionService.addSelection(loadMore);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
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 } from '@theia/core/shared/inversify';
|
|
18
|
+
import {
|
|
19
|
+
CompositeTreeNode,
|
|
20
|
+
SelectableTreeNode,
|
|
21
|
+
TreeModelImpl,
|
|
22
|
+
} from '@theia/core/lib/browser/tree';
|
|
23
|
+
import { TimelineItem } from '../common/timeline-model';
|
|
24
|
+
import { Command } from '@theia/core';
|
|
25
|
+
|
|
26
|
+
export const LOAD_MORE_COMMAND: Command = {
|
|
27
|
+
id: 'timeline-load-more'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export interface TimelineNode extends SelectableTreeNode {
|
|
31
|
+
timelineItem: TimelineItem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@injectable()
|
|
35
|
+
export class TimelineTreeModel extends TreeModelImpl {
|
|
36
|
+
|
|
37
|
+
updateTree(items: TimelineItem[], hasMoreItems: boolean): void {
|
|
38
|
+
const root = {
|
|
39
|
+
id: 'timeline-tree-root',
|
|
40
|
+
parent: undefined,
|
|
41
|
+
visible: false,
|
|
42
|
+
children: []
|
|
43
|
+
} as CompositeTreeNode;
|
|
44
|
+
const children = items.map(item =>
|
|
45
|
+
({
|
|
46
|
+
timelineItem: item,
|
|
47
|
+
id: item.id ? item.id : item.timestamp.toString(),
|
|
48
|
+
parent: root,
|
|
49
|
+
detail: item.detail,
|
|
50
|
+
selected: false,
|
|
51
|
+
visible: true
|
|
52
|
+
} as TimelineNode)
|
|
53
|
+
);
|
|
54
|
+
let loadMore;
|
|
55
|
+
if (hasMoreItems) {
|
|
56
|
+
const loadMoreNode: TimelineItem = { label: 'Load-more', timestamp: 0, handle: '', uri: '', source: '' };
|
|
57
|
+
loadMoreNode.command = LOAD_MORE_COMMAND;
|
|
58
|
+
loadMore = {
|
|
59
|
+
timelineItem: loadMoreNode,
|
|
60
|
+
id: 'load-more',
|
|
61
|
+
parent: root,
|
|
62
|
+
selected: true
|
|
63
|
+
} as TimelineNode;
|
|
64
|
+
children.push(loadMore);
|
|
65
|
+
}
|
|
66
|
+
root.children = children;
|
|
67
|
+
this.root = root;
|
|
68
|
+
if (loadMore) {
|
|
69
|
+
this.selectionService.addSelection(loadMore);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|