@theia/timeline 1.34.3 → 1.34.4
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/LICENSE +641 -641
- package/README.md +30 -30
- package/lib/browser/timeline-context-key-service.d.ts +7 -7
- package/lib/browser/timeline-context-key-service.js +51 -51
- package/lib/browser/timeline-contribution.d.ts +17 -17
- package/lib/browser/timeline-contribution.js +128 -128
- package/lib/browser/timeline-empty-widget.d.ts +8 -8
- package/lib/browser/timeline-empty-widget.js +48 -48
- package/lib/browser/timeline-frontend-module.d.ts +5 -5
- package/lib/browser/timeline-frontend-module.js +68 -68
- package/lib/browser/timeline-service.d.ts +25 -25
- package/lib/browser/timeline-service.js +110 -110
- package/lib/browser/timeline-tree-model.d.ts +10 -10
- package/lib/browser/timeline-tree-model.js +68 -68
- package/lib/browser/timeline-tree-widget.d.ts +36 -36
- package/lib/browser/timeline-tree-widget.js +128 -128
- package/lib/browser/timeline-widget.d.ts +29 -29
- package/lib/browser/timeline-widget.js +194 -194
- package/lib/common/timeline-model.d.ts +56 -56
- package/lib/common/timeline-model.js +17 -17
- package/lib/package.spec.js +25 -25
- package/package.json +5 -5
- package/src/browser/style/index.css +51 -51
- 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,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 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 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 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 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,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 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 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
|
+
}
|