@theia/plugin-ext 1.27.0-next.22 → 1.27.0-next.23

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.
@@ -33,7 +33,7 @@ export class PluginTreeViewNodeLabelProvider implements LabelProviderContributio
33
33
 
34
34
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
35
  canHandle(element: TreeViewNode | any): number {
36
- if (TreeNode.is(element) && ('resourceUri' in element || 'themeIconId' in element)) {
36
+ if (TreeNode.is(element) && ('resourceUri' in element || 'themeIcon' in element)) {
37
37
  return this.treeLabelProvider.canHandle(element) + 1;
38
38
  }
39
39
  return 0;
@@ -43,12 +43,14 @@ export class PluginTreeViewNodeLabelProvider implements LabelProviderContributio
43
43
  if (node.icon) {
44
44
  return node.icon;
45
45
  }
46
- if (node.themeIconId) {
47
- if (node.themeIconId === 'file' || node.themeIconId === 'folder') {
46
+ if (node.themeIcon) {
47
+ if (node.themeIcon.id === 'file' || node.themeIcon.id === 'folder') {
48
48
  const uri = node.resourceUri && new URI(node.resourceUri) || undefined;
49
- return this.labelProvider.getIcon(URIIconReference.create(node.themeIconId, uri));
49
+ if (uri) {
50
+ return this.labelProvider.getIcon(URIIconReference.create(node.themeIcon.id, uri));
51
+ }
50
52
  }
51
- return ThemeIcon.asClassName({ id: node.themeIconId });
53
+ return ThemeIcon.asClassName(node.themeIcon);
52
54
  }
53
55
  if (node.resourceUri) {
54
56
  return this.labelProvider.getIcon(new URI(node.resourceUri));
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { URI } from '@theia/core/shared/vscode-uri';
18
18
  import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
19
- import { TreeViewsExt, TreeViewItemCollapsibleState, TreeViewItem, TreeViewSelection } from '../../../common/plugin-api-rpc';
19
+ import { TreeViewsExt, TreeViewItemCollapsibleState, TreeViewItem, TreeViewSelection, ThemeIcon } from '../../../common/plugin-api-rpc';
20
20
  import { Command } from '../../../common/plugin-api-rpc-model';
21
21
  import {
22
22
  TreeNode,
@@ -46,6 +46,7 @@ import * as markdownit from '@theia/core/shared/markdown-it';
46
46
  import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
47
47
  import { LabelParser } from '@theia/core/lib/browser/label-parser';
48
48
  import { AccessibilityInformation } from '@theia/plugin';
49
+ import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
49
50
 
50
51
  export const TREE_NODE_HYPERLINK = 'theia-TreeNodeHyperlink';
51
52
  export const VIEW_ITEM_CONTEXT_MENU: MenuPath = ['view-item-context-menu'];
@@ -60,7 +61,7 @@ export interface TreeViewNode extends SelectableTreeNode {
60
61
  contextValue?: string;
61
62
  command?: Command;
62
63
  resourceUri?: string;
63
- themeIconId?: string | 'folder' | 'file';
64
+ themeIcon?: ThemeIcon;
64
65
  tooltip?: string;
65
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
67
  description?: string | boolean | any;
@@ -68,7 +69,7 @@ export interface TreeViewNode extends SelectableTreeNode {
68
69
  }
69
70
  export namespace TreeViewNode {
70
71
  export function is(arg: TreeNode | undefined): arg is TreeViewNode {
71
- return !!arg && SelectableTreeNode.is(arg) && !ExpandableTreeNode.is(arg) && !CompositeTreeNode.is(arg);
72
+ return !!arg && SelectableTreeNode.is(arg);
72
73
  }
73
74
  }
74
75
 
@@ -151,12 +152,12 @@ export class PluginTree extends TreeImpl {
151
152
  protected createTreeNode(item: TreeViewItem, parent: CompositeTreeNode): TreeNode {
152
153
  const icon = this.toIconClass(item);
153
154
  const resourceUri = item.resourceUri && URI.revive(item.resourceUri).toString();
154
- const themeIconId = item.themeIconId ? item.themeIconId : item.collapsibleState !== TreeViewItemCollapsibleState.None ? 'folder' : 'file';
155
+ const themeIcon = item.themeIcon ? item.themeIcon : item.collapsibleState !== TreeViewItemCollapsibleState.None ? { id: 'folder' } : { id: 'file' };
155
156
  const update: Partial<TreeViewNode> = {
156
157
  name: item.label,
157
158
  icon,
158
159
  description: item.description,
159
- themeIconId,
160
+ themeIcon,
160
161
  resourceUri,
161
162
  tooltip: item.tooltip,
162
163
  contextValue: item.contextValue,
@@ -178,7 +179,7 @@ export class PluginTree extends TreeImpl {
178
179
  command: item.command
179
180
  }, update);
180
181
  }
181
- if (TreeViewNode.is(node)) {
182
+ if (TreeViewNode.is(node) && !ExpandableTreeNode.is(node)) {
182
183
  return Object.assign(node, update, { command: item.command });
183
184
  }
184
185
  return Object.assign({
@@ -257,6 +258,9 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
257
258
  @inject(LabelParser)
258
259
  protected readonly labelParser: LabelParser;
259
260
 
261
+ @inject(ColorRegistry)
262
+ protected readonly colorRegistry: ColorRegistry;
263
+
260
264
  protected readonly markdownIt = markdownit();
261
265
 
262
266
  @postConstruct()
@@ -286,7 +290,14 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
286
290
  protected override renderIcon(node: TreeNode, props: NodeProps): React.ReactNode {
287
291
  const icon = this.toNodeIcon(node);
288
292
  if (icon) {
289
- return <div className={icon + ' theia-tree-view-icon'}></div>;
293
+ let style: React.CSSProperties | undefined;
294
+ if (TreeViewNode.is(node) && node.themeIcon?.color) {
295
+ const color = this.colorRegistry.getCurrentColor(node.themeIcon.color.id);
296
+ if (color) {
297
+ style = { color };
298
+ }
299
+ }
300
+ return <div className={icon + ' theia-tree-view-icon'} style={style}></div>;
290
301
  }
291
302
  return undefined;
292
303
  }
@@ -366,12 +366,12 @@ class TreeViewExtImpl<T> implements Disposable {
366
366
 
367
367
  let icon;
368
368
  let iconUrl;
369
- let themeIconId;
369
+ let themeIcon;
370
370
  const { iconPath } = treeItem;
371
371
  if (typeof iconPath === 'string' && iconPath.indexOf('fa-') !== -1) {
372
372
  icon = iconPath;
373
373
  } else if (ThemeIcon.is(iconPath)) {
374
- themeIconId = iconPath.id;
374
+ themeIcon = iconPath;
375
375
  } else {
376
376
  iconUrl = PluginIconPath.toUrl(<PluginIconPath | undefined>iconPath, this.plugin);
377
377
  }
@@ -381,7 +381,7 @@ class TreeViewExtImpl<T> implements Disposable {
381
381
  label,
382
382
  icon,
383
383
  iconUrl,
384
- themeIconId,
384
+ themeIcon,
385
385
  description: treeItem.description,
386
386
  resourceUri: treeItem.resourceUri,
387
387
  tooltip: treeItem.tooltip,
@@ -732,7 +732,7 @@ export class ThemeIcon {
732
732
 
733
733
  static readonly Folder: ThemeIcon = new ThemeIcon('folder');
734
734
 
735
- private constructor(public id: string) {
735
+ private constructor(public id: string, public color?: ThemeColor) {
736
736
  }
737
737
 
738
738
  }