@theia/plugin-ext 1.34.0-next.39 → 1.34.0
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/lib/common/plugin-api-rpc.d.ts +12 -6
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js +6 -6
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/main/browser/authentication-main.js +1 -1
- package/lib/main/browser/authentication-main.js.map +1 -1
- package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
- package/lib/main/browser/debug/debug-main.js +1 -0
- package/lib/main/browser/debug/debug-main.js.map +1 -1
- package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts +2 -2
- package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts.map +1 -1
- package/lib/main/browser/menus/plugin-menu-command-adapter.js +6 -2
- package/lib/main/browser/menus/plugin-menu-command-adapter.js.map +1 -1
- package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts +2 -2
- package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts.map +1 -1
- package/lib/main/browser/menus/vscode-theia-menu-mappings.js +6 -0
- package/lib/main/browser/menus/vscode-theia-menu-mappings.js.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.js +4 -3
- package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
- package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
- package/lib/main/browser/view/plugin-view-registry.js +1 -1
- package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
- package/lib/main/browser/view/tree-view-widget.d.ts +6 -5
- package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
- package/lib/main/browser/view/tree-view-widget.js +19 -15
- package/lib/main/browser/view/tree-view-widget.js.map +1 -1
- package/lib/main/browser/view/tree-views-main.d.ts +2 -2
- package/lib/main/browser/view/tree-views-main.d.ts.map +1 -1
- package/lib/main/browser/view/tree-views-main.js +4 -3
- package/lib/main/browser/view/tree-views-main.js.map +1 -1
- package/lib/main/browser/webview/webview.d.ts +1 -1
- package/lib/main/browser/webview/webview.d.ts.map +1 -1
- package/lib/main/browser/webview/webview.js +7 -2
- package/lib/main/browser/webview/webview.js.map +1 -1
- package/lib/plugin/debug/debug-ext.d.ts +3 -0
- package/lib/plugin/debug/debug-ext.d.ts.map +1 -1
- package/lib/plugin/debug/debug-ext.js +10 -0
- package/lib/plugin/debug/debug-ext.js.map +1 -1
- package/lib/plugin/terminal-ext.d.ts.map +1 -1
- package/lib/plugin/terminal-ext.js +1 -2
- package/lib/plugin/terminal-ext.js.map +1 -1
- package/lib/plugin/tree/tree-views.d.ts +6 -8
- package/lib/plugin/tree/tree-views.d.ts.map +1 -1
- package/lib/plugin/tree/tree-views.js +41 -33
- package/lib/plugin/tree/tree-views.js.map +1 -1
- package/package.json +26 -26
- package/src/common/plugin-api-rpc.ts +15 -8
- package/src/main/browser/authentication-main.ts +1 -1
- package/src/main/browser/debug/debug-main.ts +1 -0
- package/src/main/browser/menus/plugin-menu-command-adapter.ts +7 -4
- package/src/main/browser/menus/vscode-theia-menu-mappings.ts +6 -0
- package/src/main/browser/plugin-ext-frontend-module.ts +4 -3
- package/src/main/browser/view/plugin-view-registry.ts +4 -1
- package/src/main/browser/view/tree-view-widget.tsx +20 -16
- package/src/main/browser/view/tree-views-main.ts +5 -5
- package/src/main/browser/webview/webview.ts +7 -3
- package/src/plugin/debug/debug-ext.ts +12 -0
- package/src/plugin/terminal-ext.ts +1 -2
- package/src/plugin/tree/tree-views.ts +38 -39
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
-
import { TreeViewsExt, TreeViewItemCollapsibleState, TreeViewItem,
|
|
18
|
+
import { TreeViewsExt, TreeViewItemCollapsibleState, TreeViewItem, TreeViewItemReference, ThemeIcon, DataTransferFileDTO } from '../../../common/plugin-api-rpc';
|
|
19
19
|
import { Command } from '../../../common/plugin-api-rpc-model';
|
|
20
20
|
import {
|
|
21
21
|
TreeNode,
|
|
@@ -164,6 +164,7 @@ export namespace CompositeTreeViewNode {
|
|
|
164
164
|
@injectable()
|
|
165
165
|
export class TreeViewWidgetOptions {
|
|
166
166
|
id: string;
|
|
167
|
+
multiSelect: boolean | undefined;
|
|
167
168
|
dragMimeTypes: string[] | undefined;
|
|
168
169
|
dropMimeTypes: string[] | undefined;
|
|
169
170
|
}
|
|
@@ -696,41 +697,44 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
|
|
|
696
697
|
}
|
|
697
698
|
}
|
|
698
699
|
|
|
699
|
-
protected override renderTailDecorations(
|
|
700
|
-
return this.contextKeys.with({ view: this.id, viewItem:
|
|
700
|
+
protected override renderTailDecorations(treeViewNode: TreeViewNode, props: NodeProps): React.ReactNode {
|
|
701
|
+
return this.contextKeys.with({ view: this.id, viewItem: treeViewNode.contextValue }, () => {
|
|
701
702
|
const menu = this.menus.getMenu(VIEW_ITEM_INLINE_MENU);
|
|
702
|
-
const
|
|
703
|
+
const args = this.toContextMenuArgs(treeViewNode);
|
|
703
704
|
const inlineCommands = menu.children.filter((item): item is ActionMenuNode => item instanceof ActionMenuNode);
|
|
704
|
-
const tailDecorations = super.renderTailDecorations(
|
|
705
|
+
const tailDecorations = super.renderTailDecorations(treeViewNode, props);
|
|
705
706
|
return <React.Fragment>
|
|
706
707
|
{inlineCommands.length > 0 && <div className={TREE_NODE_SEGMENT_CLASS + ' flex'}>
|
|
707
|
-
{inlineCommands.map((item, index) => this.renderInlineCommand(item, index, this.focusService.hasFocus(
|
|
708
|
+
{inlineCommands.map((item, index) => this.renderInlineCommand(item, index, this.focusService.hasFocus(treeViewNode), args))}
|
|
708
709
|
</div>}
|
|
709
710
|
{tailDecorations !== undefined && <div className={TREE_NODE_SEGMENT_CLASS + ' flex'}>{tailDecorations}</div>}
|
|
710
711
|
</React.Fragment>;
|
|
711
712
|
});
|
|
712
713
|
}
|
|
713
714
|
|
|
714
|
-
|
|
715
|
-
return {
|
|
715
|
+
toTreeViewItemReference(treeNode: TreeNode): TreeViewItemReference {
|
|
716
|
+
return { viewId: this.id, itemId: treeNode.id };
|
|
716
717
|
}
|
|
717
718
|
|
|
718
719
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
719
|
-
protected renderInlineCommand(
|
|
720
|
-
|
|
721
|
-
if (!icon || !this.commands.isVisible(node.command, arg) || !node.when || !this.contextKeys.match(node.when)) {
|
|
720
|
+
protected renderInlineCommand(actionMenuNode: ActionMenuNode, index: number, tabbable: boolean, args: any[]): React.ReactNode {
|
|
721
|
+
if (!actionMenuNode.icon || !this.commands.isVisible(actionMenuNode.command, ...args) || !actionMenuNode.when || !this.contextKeys.match(actionMenuNode.when)) {
|
|
722
722
|
return false;
|
|
723
723
|
}
|
|
724
|
-
const className = [TREE_NODE_SEGMENT_CLASS, TREE_NODE_TAIL_CLASS, icon, ACTION_ITEM, 'theia-tree-view-inline-action'].join(' ');
|
|
724
|
+
const className = [TREE_NODE_SEGMENT_CLASS, TREE_NODE_TAIL_CLASS, actionMenuNode.icon, ACTION_ITEM, 'theia-tree-view-inline-action'].join(' ');
|
|
725
725
|
const tabIndex = tabbable ? 0 : undefined;
|
|
726
|
-
return <div key={index} className={className} title={
|
|
726
|
+
return <div key={index} className={className} title={actionMenuNode.label} tabIndex={tabIndex} onClick={e => {
|
|
727
727
|
e.stopPropagation();
|
|
728
|
-
this.commands.executeCommand(
|
|
728
|
+
this.commands.executeCommand(actionMenuNode.command, ...args);
|
|
729
729
|
}} />;
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
-
protected override toContextMenuArgs(
|
|
733
|
-
|
|
732
|
+
protected override toContextMenuArgs(target: SelectableTreeNode): [TreeViewItemReference, TreeViewItemReference[]] | [TreeViewItemReference] {
|
|
733
|
+
if (this.options.multiSelect) {
|
|
734
|
+
return [this.toTreeViewItemReference(target), this.model.selectedNodes.map(node => this.toTreeViewItemReference(node))];
|
|
735
|
+
} else {
|
|
736
|
+
return [this.toTreeViewItemReference(target)];
|
|
737
|
+
}
|
|
734
738
|
}
|
|
735
739
|
|
|
736
740
|
override setFlag(flag: Widget.Flag): void {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { interfaces } from '@theia/core/shared/inversify';
|
|
18
|
-
import { MAIN_RPC_CONTEXT, TreeViewsMain, TreeViewsExt, TreeViewRevealOptions } from '../../../common/plugin-api-rpc';
|
|
18
|
+
import { MAIN_RPC_CONTEXT, TreeViewsMain, TreeViewsExt, TreeViewRevealOptions, RegisterTreeDataProviderOptions } from '../../../common/plugin-api-rpc';
|
|
19
19
|
import { RPCProtocol } from '../../../common/rpc-protocol';
|
|
20
20
|
import { PluginViewRegistry, PLUGIN_VIEW_DATA_FACTORY_ID } from './plugin-view-registry';
|
|
21
21
|
import {
|
|
@@ -58,14 +58,14 @@ export class TreeViewsMainImpl implements TreeViewsMain, Disposable {
|
|
|
58
58
|
this.toDispose.dispose();
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
async $registerTreeDataProvider(treeViewId: string,
|
|
61
|
+
async $registerTreeDataProvider(treeViewId: string, $options: RegisterTreeDataProviderOptions): Promise<void> {
|
|
62
62
|
this.treeViewProviders.set(treeViewId, this.viewRegistry.registerViewDataProvider(treeViewId, async ({ state, viewInfo }) => {
|
|
63
63
|
const options: TreeViewWidgetOptions = {
|
|
64
64
|
id: treeViewId,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
multiSelect: $options.canSelectMany,
|
|
66
|
+
dragMimeTypes: $options.dragMimeTypes,
|
|
67
|
+
dropMimeTypes: $options.dropMimeTypes
|
|
67
68
|
};
|
|
68
|
-
|
|
69
69
|
const widget = await this.widgetManager.getOrCreateWidget<TreeViewWidget>(PLUGIN_VIEW_DATA_FACTORY_ID, options);
|
|
70
70
|
widget.model.viewInfo = viewInfo;
|
|
71
71
|
if (state) {
|
|
@@ -76,7 +76,7 @@ export interface WebviewContentOptions {
|
|
|
76
76
|
readonly allowForms?: boolean;
|
|
77
77
|
readonly localResourceRoots?: ReadonlyArray<string>;
|
|
78
78
|
readonly portMapping?: ReadonlyArray<WebviewPortMapping>;
|
|
79
|
-
readonly enableCommandUris?: boolean;
|
|
79
|
+
readonly enableCommandUris?: boolean | readonly string[];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
@injectable()
|
|
@@ -450,8 +450,12 @@ export class WebviewWidget extends BaseWidget implements StatefulWidget, Extract
|
|
|
450
450
|
}
|
|
451
451
|
return link;
|
|
452
452
|
}
|
|
453
|
-
if (
|
|
454
|
-
|
|
453
|
+
if (link.scheme === Schemes.command) {
|
|
454
|
+
if (Array.isArray(this.contentOptions.enableCommandUris) && this.contentOptions.enableCommandUris.some(value => value === link.path.toString())) {
|
|
455
|
+
return link;
|
|
456
|
+
} else if (this.contentOptions.enableCommandUris === true) {
|
|
457
|
+
return link;
|
|
458
|
+
}
|
|
455
459
|
}
|
|
456
460
|
return undefined;
|
|
457
461
|
}
|
|
@@ -67,6 +67,7 @@ export class DebugExtImpl implements DebugExt {
|
|
|
67
67
|
private readonly onDidChangeBreakpointsEmitter = new Emitter<theia.BreakpointsChangeEvent>();
|
|
68
68
|
private readonly onDidChangeActiveDebugSessionEmitter = new Emitter<theia.DebugSession | undefined>();
|
|
69
69
|
private readonly onDidTerminateDebugSessionEmitter = new Emitter<theia.DebugSession>();
|
|
70
|
+
private readonly onDidCreateDebugSessionEmitter = new Emitter<theia.DebugSession>();
|
|
70
71
|
private readonly onDidStartDebugSessionEmitter = new Emitter<theia.DebugSession>();
|
|
71
72
|
private readonly onDidReceiveDebugSessionCustomEmitter = new Emitter<theia.DebugSessionCustomEvent>();
|
|
72
73
|
|
|
@@ -131,6 +132,10 @@ export class DebugExtImpl implements DebugExt {
|
|
|
131
132
|
return this.onDidTerminateDebugSessionEmitter.event;
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
get onDidCreateDebugSession(): theia.Event<theia.DebugSession> {
|
|
136
|
+
return this.onDidCreateDebugSessionEmitter.event;
|
|
137
|
+
}
|
|
138
|
+
|
|
134
139
|
get onDidStartDebugSession(): theia.Event<theia.DebugSession> {
|
|
135
140
|
return this.onDidStartDebugSessionEmitter.event;
|
|
136
141
|
}
|
|
@@ -253,6 +258,13 @@ export class DebugExtImpl implements DebugExt {
|
|
|
253
258
|
}
|
|
254
259
|
|
|
255
260
|
async $sessionDidCreate(sessionId: string): Promise<void> {
|
|
261
|
+
const session = this.sessions.get(sessionId);
|
|
262
|
+
if (session) {
|
|
263
|
+
this.onDidCreateDebugSessionEmitter.fire(session);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async $sessionDidStart(sessionId: string): Promise<void> {
|
|
256
268
|
const session = this.sessions.get(sessionId);
|
|
257
269
|
if (session) {
|
|
258
270
|
this.onDidStartDebugSessionEmitter.fire(session);
|
|
@@ -189,8 +189,7 @@ export class TerminalServiceExtImpl implements TerminalServiceExt {
|
|
|
189
189
|
terminal.deferredProcessId = new Deferred<number>();
|
|
190
190
|
terminal.deferredProcessId.resolve(processId);
|
|
191
191
|
}
|
|
192
|
-
|
|
193
|
-
const pseudoTerminal = this._pseudoTerminals.get(id);
|
|
192
|
+
const pseudoTerminal = this._pseudoTerminals.get(terminalId.toString());
|
|
194
193
|
if (pseudoTerminal) {
|
|
195
194
|
pseudoTerminal.emitOnOpen(cols, rows);
|
|
196
195
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
20
|
TreeDataProvider, TreeView, TreeViewExpansionEvent, TreeItem, TreeItemLabel,
|
|
21
|
-
TreeViewSelectionChangeEvent, TreeViewVisibilityChangeEvent, CancellationToken,
|
|
21
|
+
TreeViewSelectionChangeEvent, TreeViewVisibilityChangeEvent, CancellationToken, DataTransferFile, TreeViewOptions
|
|
22
22
|
} from '@theia/plugin';
|
|
23
23
|
// TODO: extract `@theia/util` for event, disposable, cancellation and common types
|
|
24
24
|
// don't use @theia/core directly from plugin host
|
|
@@ -28,7 +28,7 @@ import { DataTransfer, DataTransferItem, Disposable as PluginDisposable, ThemeIc
|
|
|
28
28
|
import { Plugin, PLUGIN_RPC_CONTEXT, TreeViewsExt, TreeViewsMain, TreeViewItem, TreeViewRevealOptions, DataTransferFileDTO } from '../../common/plugin-api-rpc';
|
|
29
29
|
import { RPCProtocol } from '../../common/rpc-protocol';
|
|
30
30
|
import { CommandRegistryImpl, CommandsConverter } from '../command-registry';
|
|
31
|
-
import {
|
|
31
|
+
import { TreeViewItemReference } from '../../common';
|
|
32
32
|
import { PluginIconPath } from '../plugin-icon-path';
|
|
33
33
|
import { URI } from '@theia/core/shared/vscode-uri';
|
|
34
34
|
import { UriComponents } from '@theia/core/lib/common/uri';
|
|
@@ -41,14 +41,16 @@ export class TreeViewsExtImpl implements TreeViewsExt {
|
|
|
41
41
|
|
|
42
42
|
constructor(rpc: RPCProtocol, readonly commandRegistry: CommandRegistryImpl) {
|
|
43
43
|
this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.TREE_VIEWS_MAIN);
|
|
44
|
+
|
|
44
45
|
commandRegistry.registerArgumentProcessor({
|
|
45
46
|
processArgument: arg => {
|
|
46
|
-
if (
|
|
47
|
+
if (TreeViewItemReference.is(arg)) {
|
|
48
|
+
return this.toTreeItem(arg);
|
|
49
|
+
} else if (Array.isArray(arg)) {
|
|
50
|
+
return arg.map(param => TreeViewItemReference.is(param) ? this.toTreeItem(param) : param);
|
|
51
|
+
} else {
|
|
47
52
|
return arg;
|
|
48
53
|
}
|
|
49
|
-
const { treeViewId, treeItemId } = arg;
|
|
50
|
-
const treeView = this.treeViews.get(treeViewId);
|
|
51
|
-
return treeView && treeView.getTreeItem(treeItemId);
|
|
52
54
|
}
|
|
53
55
|
});
|
|
54
56
|
}
|
|
@@ -60,6 +62,10 @@ export class TreeViewsExtImpl implements TreeViewsExt {
|
|
|
60
62
|
return this.getTreeView(treeViewId).handleDrop!(treeItemId, dataTransferItems, token);
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
protected toTreeItem(treeViewItemRef: TreeViewItemReference): any {
|
|
66
|
+
return this.treeViews.get(treeViewItemRef.viewId)?.getTreeItem(treeViewItemRef.itemId);
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
registerTreeDataProvider<T>(plugin: Plugin, treeViewId: string, treeDataProvider: TreeDataProvider<T>): PluginDisposable {
|
|
64
70
|
const treeView = this.createTreeView(plugin, treeViewId, { treeDataProvider });
|
|
65
71
|
|
|
@@ -69,12 +75,12 @@ export class TreeViewsExtImpl implements TreeViewsExt {
|
|
|
69
75
|
});
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
createTreeView<T>(plugin: Plugin, treeViewId: string, options:
|
|
78
|
+
createTreeView<T>(plugin: Plugin, treeViewId: string, options: TreeViewOptions<T>): TreeView<T> {
|
|
73
79
|
if (!options || !options.treeDataProvider) {
|
|
74
80
|
throw new Error('Options with treeDataProvider is mandatory');
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
const treeView = new TreeViewExtImpl(plugin, treeViewId, options
|
|
83
|
+
const treeView = new TreeViewExtImpl<T>(plugin, treeViewId, options, this.proxy, this.commandRegistry.converter);
|
|
78
84
|
this.treeViews.set(treeViewId, treeView);
|
|
79
85
|
|
|
80
86
|
return {
|
|
@@ -209,23 +215,18 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
209
215
|
constructor(
|
|
210
216
|
private plugin: Plugin,
|
|
211
217
|
private treeViewId: string,
|
|
212
|
-
private
|
|
213
|
-
private dragAndDropController: TreeDragAndDropController<T> | undefined,
|
|
218
|
+
private options: TreeViewOptions<T>,
|
|
214
219
|
private proxy: TreeViewsMain,
|
|
215
|
-
readonly commandsConverter: CommandsConverter
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
proxy.$registerTreeDataProvider(treeViewId,
|
|
221
|
-
|
|
220
|
+
readonly commandsConverter: CommandsConverter
|
|
221
|
+
) {
|
|
222
|
+
// make copies of optionally provided MIME types:
|
|
223
|
+
const dragMimeTypes = options.dragAndDropController?.dragMimeTypes?.slice();
|
|
224
|
+
const dropMimeTypes = options.dragAndDropController?.dropMimeTypes?.slice();
|
|
225
|
+
proxy.$registerTreeDataProvider(treeViewId, { canSelectMany: options.canSelectMany, dragMimeTypes, dropMimeTypes });
|
|
222
226
|
this.toDispose.push(Disposable.create(() => this.proxy.$unregisterTreeDataProvider(treeViewId)));
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
this.pendingRefresh = proxy.$refresh(treeViewId);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
227
|
+
options.treeDataProvider.onDidChangeTreeData?.(() => {
|
|
228
|
+
this.pendingRefresh = proxy.$refresh(treeViewId);
|
|
229
|
+
});
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
dispose(): void {
|
|
@@ -274,8 +275,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
274
275
|
}
|
|
275
276
|
|
|
276
277
|
getTreeItem(treeItemId: string): T | undefined {
|
|
277
|
-
|
|
278
|
-
return element && element.value;
|
|
278
|
+
return this.nodes.get(treeItemId)?.value;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
/**
|
|
@@ -292,15 +292,14 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
292
292
|
// root
|
|
293
293
|
return [];
|
|
294
294
|
}
|
|
295
|
-
const
|
|
296
|
-
const parent = result ? result : undefined;
|
|
295
|
+
const parent = await this.options.treeDataProvider.getParent?.(element) ?? undefined;
|
|
297
296
|
const chain = await this.calculateRevealParentChain(parent);
|
|
298
297
|
if (!chain) {
|
|
299
298
|
// parents are inconsistent
|
|
300
299
|
return undefined;
|
|
301
300
|
}
|
|
302
301
|
const parentId = chain.length ? chain[chain.length - 1] : '';
|
|
303
|
-
const treeItem = await this.treeDataProvider.getTreeItem(element);
|
|
302
|
+
const treeItem = await this.options.treeDataProvider.getTreeItem(element);
|
|
304
303
|
if (treeItem.id) {
|
|
305
304
|
return chain.concat(treeItem.id);
|
|
306
305
|
}
|
|
@@ -310,7 +309,8 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
310
309
|
// If not in cache, getChildren fills this.nodes and generate ids for them which are needed later
|
|
311
310
|
const children = cachedParentNode?.children || await this.getChildren(parentId);
|
|
312
311
|
if (!children) {
|
|
313
|
-
|
|
312
|
+
// parent is inconsistent
|
|
313
|
+
return undefined;
|
|
314
314
|
}
|
|
315
315
|
const idLabel = this.getTreeItemIdLabel(treeItem);
|
|
316
316
|
let possibleIndex = children.length;
|
|
@@ -367,13 +367,13 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
367
367
|
this.nodes.set(parentId, { id: '', disposables: rootNodeDisposables, dispose: () => { rootNodeDisposables.dispose(); } });
|
|
368
368
|
}
|
|
369
369
|
// ask data provider for children for cached element
|
|
370
|
-
const result = await this.treeDataProvider.getChildren(parent);
|
|
370
|
+
const result = await this.options.treeDataProvider.getChildren(parent);
|
|
371
371
|
if (result) {
|
|
372
372
|
const treeItemPromises = result.map(async (value, index) => {
|
|
373
373
|
|
|
374
374
|
// Ask data provider for a tree item for the value
|
|
375
375
|
// Data provider must return theia.TreeItem
|
|
376
|
-
const treeItem = await this.treeDataProvider.getTreeItem(value);
|
|
376
|
+
const treeItem = await this.options.treeDataProvider.getTreeItem(value);
|
|
377
377
|
// Convert theia.TreeItem to the TreeViewItem
|
|
378
378
|
|
|
379
379
|
const label = this.getTreeItemLabel(treeItem);
|
|
@@ -490,13 +490,13 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
490
490
|
}
|
|
491
491
|
|
|
492
492
|
async resolveTreeItem(treeItemId: string, token: CancellationToken): Promise<TreeViewItem | undefined> {
|
|
493
|
-
if (!this.treeDataProvider.resolveTreeItem) {
|
|
493
|
+
if (!this.options.treeDataProvider.resolveTreeItem) {
|
|
494
494
|
return undefined;
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
const node = this.nodes.get(treeItemId);
|
|
498
498
|
if (node && node.treeViewItem && node.pluginTreeItem && node.value) {
|
|
499
|
-
const resolved = await this.treeDataProvider.resolveTreeItem(node.pluginTreeItem, node.value, token) ?? node.pluginTreeItem;
|
|
499
|
+
const resolved = await this.options.treeDataProvider.resolveTreeItem(node.pluginTreeItem, node.value, token) ?? node.pluginTreeItem;
|
|
500
500
|
node.treeViewItem.command = this.commandsConverter.toSafeCommand(resolved.command, node.disposables);
|
|
501
501
|
node.treeViewItem.tooltip = resolved.tooltip;
|
|
502
502
|
return node.treeViewItem;
|
|
@@ -506,7 +506,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
506
506
|
}
|
|
507
507
|
|
|
508
508
|
hasResolveTreeItem(): boolean {
|
|
509
|
-
return !!this.treeDataProvider.resolveTreeItem;
|
|
509
|
+
return !!this.options.treeDataProvider.resolveTreeItem;
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
private selectedItemIds = new Set<string>();
|
|
@@ -559,9 +559,9 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
559
559
|
treeItems.push(item);
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
|
-
if (this.
|
|
562
|
+
if (this.options.dragAndDropController?.handleDrag) {
|
|
563
563
|
this.localDataTransfer.clear();
|
|
564
|
-
await this.dragAndDropController.handleDrag(treeItems, this.localDataTransfer, token);
|
|
564
|
+
await this.options.dragAndDropController.handleDrag(treeItems, this.localDataTransfer, token);
|
|
565
565
|
const uriList = await this.localDataTransfer.get('text/uri-list')?.asString();
|
|
566
566
|
if (uriList) {
|
|
567
567
|
return uriList.split('\n').map(str => URI.parse(str));
|
|
@@ -573,7 +573,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
573
573
|
async handleDrop(treeItemId: string | undefined, dataTransferItems: [string, string | DataTransferFileDTO][], token: CancellationToken): Promise<void> {
|
|
574
574
|
const treeItem = treeItemId ? this.getTreeItem(treeItemId) : undefined;
|
|
575
575
|
const dropTransfer = new DataTransfer();
|
|
576
|
-
if (this.
|
|
576
|
+
if (this.options.dragAndDropController?.handleDrop) {
|
|
577
577
|
this.localDataTransfer.forEach((item, type) => {
|
|
578
578
|
dropTransfer.set(type, item);
|
|
579
579
|
});
|
|
@@ -599,8 +599,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
|
|
603
|
-
return Promise.resolve(this.dragAndDropController.handleDrop(treeItem, dropTransfer, token));
|
|
602
|
+
return this.options.dragAndDropController.handleDrop(treeItem, dropTransfer, token);
|
|
604
603
|
}
|
|
605
604
|
}
|
|
606
605
|
}
|