@theia/property-view 1.45.0 → 1.46.0-next.72

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.
Files changed (56) hide show
  1. package/README.md +44 -44
  2. package/lib/browser/empty-property-view-widget-provider.d.ts +32 -32
  3. package/lib/browser/empty-property-view-widget-provider.js +83 -83
  4. package/lib/browser/property-data-service.d.ts +28 -28
  5. package/lib/browser/property-data-service.js +19 -19
  6. package/lib/browser/property-view-content-widget.d.ts +10 -10
  7. package/lib/browser/property-view-content-widget.js +17 -17
  8. package/lib/browser/property-view-contribution.d.ts +5 -5
  9. package/lib/browser/property-view-contribution.js +48 -48
  10. package/lib/browser/property-view-frontend-module.d.ts +4 -4
  11. package/lib/browser/property-view-frontend-module.js +42 -42
  12. package/lib/browser/property-view-service.d.ts +17 -17
  13. package/lib/browser/property-view-service.js +81 -81
  14. package/lib/browser/property-view-widget-provider.d.ts +57 -57
  15. package/lib/browser/property-view-widget-provider.js +84 -84
  16. package/lib/browser/property-view-widget.d.ts +26 -26
  17. package/lib/browser/property-view-widget.js +130 -130
  18. package/lib/browser/resource-property-view/index.d.ts +1 -1
  19. package/lib/browser/resource-property-view/index.js +28 -28
  20. package/lib/browser/resource-property-view/resource-property-data-service.d.ts +17 -17
  21. package/lib/browser/resource-property-view/resource-property-data-service.js +72 -72
  22. package/lib/browser/resource-property-view/resource-property-data-service.spec.d.ts +1 -1
  23. package/lib/browser/resource-property-view/resource-property-data-service.spec.js +101 -101
  24. package/lib/browser/resource-property-view/resource-property-view-label-provider.d.ts +10 -10
  25. package/lib/browser/resource-property-view/resource-property-view-label-provider.js +60 -60
  26. package/lib/browser/resource-property-view/resource-property-view-label-provider.spec.d.ts +1 -1
  27. package/lib/browser/resource-property-view/resource-property-view-label-provider.spec.js +129 -129
  28. package/lib/browser/resource-property-view/resource-property-view-tree-container.d.ts +2 -2
  29. package/lib/browser/resource-property-view/resource-property-view-tree-container.js +43 -43
  30. package/lib/browser/resource-property-view/resource-property-view-tree-items.d.ts +27 -27
  31. package/lib/browser/resource-property-view/resource-property-view-tree-items.js +41 -41
  32. package/lib/browser/resource-property-view/resource-property-view-tree-widget.d.ts +40 -40
  33. package/lib/browser/resource-property-view/resource-property-view-tree-widget.js +191 -191
  34. package/lib/browser/resource-property-view/resource-property-view-widget-provider.d.ts +16 -16
  35. package/lib/browser/resource-property-view/resource-property-view-widget-provider.js +66 -66
  36. package/lib/package.spec.js +25 -25
  37. package/package.json +5 -5
  38. package/src/browser/empty-property-view-widget-provider.tsx +83 -83
  39. package/src/browser/property-data-service.ts +48 -48
  40. package/src/browser/property-view-content-widget.ts +27 -27
  41. package/src/browser/property-view-contribution.ts +36 -36
  42. package/src/browser/property-view-frontend-module.ts +47 -47
  43. package/src/browser/property-view-service.ts +62 -62
  44. package/src/browser/property-view-widget-provider.ts +112 -112
  45. package/src/browser/property-view-widget.tsx +118 -118
  46. package/src/browser/resource-property-view/index.ts +17 -17
  47. package/src/browser/resource-property-view/resource-property-data-service.spec.ts +127 -127
  48. package/src/browser/resource-property-view/resource-property-data-service.ts +64 -64
  49. package/src/browser/resource-property-view/resource-property-view-label-provider.spec.ts +153 -153
  50. package/src/browser/resource-property-view/resource-property-view-label-provider.ts +49 -49
  51. package/src/browser/resource-property-view/resource-property-view-tree-container.ts +47 -47
  52. package/src/browser/resource-property-view/resource-property-view-tree-items.ts +53 -53
  53. package/src/browser/resource-property-view/resource-property-view-tree-widget.tsx +219 -219
  54. package/src/browser/resource-property-view/resource-property-view-widget-provider.ts +55 -55
  55. package/src/browser/style/property-view.css +51 -51
  56. package/src/package.spec.ts +29 -29
@@ -1,219 +1,219 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 EclipseSource 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 {
18
- ContextMenuRenderer,
19
- NodeProps,
20
- TreeModel,
21
- TreeNode,
22
- TreeProps,
23
- TreeWidget
24
- } from '@theia/core/lib/browser';
25
- import { FileStat } from '@theia/filesystem/lib/common/files';
26
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
27
- import * as React from '@theia/core/shared/react';
28
- import { PropertyDataService } from '../property-data-service';
29
- import { PropertyViewContentWidget } from '../property-view-content-widget';
30
- import {
31
- ResourcePropertiesCategoryNode,
32
- ResourcePropertiesItemNode,
33
- ResourcePropertiesRoot,
34
- ROOT_ID
35
- } from './resource-property-view-tree-items';
36
- import { nls } from '@theia/core/lib/common/nls';
37
-
38
- /**
39
- * This widget fetches the property data for {@link FileSelection}s and selections of {@link Navigatable}s
40
- * and renders that property data as a {@link TreeWidget}.
41
- * This widget is provided by the registered `ResourcePropertyViewWidgetProvider`.
42
- */
43
- @injectable()
44
- export class ResourcePropertyViewTreeWidget extends TreeWidget implements PropertyViewContentWidget {
45
-
46
- static readonly ID = 'resource-properties-tree-widget';
47
- static readonly LABEL = 'Resource Properties Tree';
48
-
49
- protected propertiesTree: Map<string, ResourcePropertiesCategoryNode>;
50
- protected currentSelection: Object | undefined;
51
-
52
- constructor(
53
- @inject(TreeProps) props: TreeProps,
54
- @inject(TreeModel) model: TreeModel,
55
- @inject(ContextMenuRenderer) contextMenuRenderer: ContextMenuRenderer
56
- ) {
57
- super(props, model, contextMenuRenderer);
58
-
59
- model.root = {
60
- id: ROOT_ID,
61
- name: ResourcePropertyViewTreeWidget.LABEL,
62
- parent: undefined,
63
- visible: false,
64
- children: []
65
- } as ResourcePropertiesRoot;
66
-
67
- this.propertiesTree = new Map<string, ResourcePropertiesCategoryNode>();
68
- }
69
-
70
- @postConstruct()
71
- protected override init(): void {
72
- super.init();
73
-
74
- this.id = ResourcePropertyViewTreeWidget.ID + '-treeContainer';
75
- this.addClass('treeContainer');
76
-
77
- this.fillPropertiesTree();
78
- }
79
-
80
- protected updateNeeded(selection: Object | undefined): boolean {
81
- return this.currentSelection !== selection;
82
- }
83
-
84
- updatePropertyViewContent(propertyDataService?: PropertyDataService, selection?: Object | undefined): void {
85
- if (this.updateNeeded(selection)) {
86
- this.currentSelection = selection;
87
- if (propertyDataService) {
88
- propertyDataService.providePropertyData(selection).then((fileStatObject?: FileStat) => {
89
- this.fillPropertiesTree(fileStatObject);
90
- });
91
- }
92
- }
93
- }
94
-
95
- protected fillPropertiesTree(fileStatObject?: FileStat): void {
96
- if (fileStatObject) {
97
- this.propertiesTree.clear();
98
- const infoNode = this.createCategoryNode('info', nls.localizeByDefault('Info'));
99
- this.propertiesTree.set('info', infoNode);
100
-
101
- infoNode.children.push(this.createResultLineNode('isDirectory', nls.localize('theia/property-view/directory', 'Directory'), fileStatObject.isDirectory, infoNode));
102
- infoNode.children.push(this.createResultLineNode('isFile', nls.localizeByDefault('File'), fileStatObject.isFile, infoNode));
103
- infoNode.children.push(this.createResultLineNode('isSymbolicLink', nls.localize('theia/property-view/symbolicLink', 'Symbolic link'),
104
- fileStatObject.isSymbolicLink, infoNode));
105
- infoNode.children.push(this.createResultLineNode('location', nls.localize('theia/property-view/location', 'Location'),
106
- this.getLocationString(fileStatObject), infoNode));
107
- infoNode.children.push(this.createResultLineNode('name', nls.localizeByDefault('Name'), this.getFileName(fileStatObject), infoNode));
108
- infoNode.children.push(this.createResultLineNode('path', nls.localizeByDefault('Path'), this.getFilePath(fileStatObject), infoNode));
109
- infoNode.children.push(this.createResultLineNode('lastModification', nls.localize('theia/property-view/lastModified', 'Last modified'),
110
- this.getLastModificationString(fileStatObject), infoNode));
111
- infoNode.children.push(this.createResultLineNode('created', nls.localize('theia/property-view/created', 'Created'),
112
- this.getCreationTimeString(fileStatObject), infoNode));
113
- infoNode.children.push(this.createResultLineNode('size', nls.localize('theia/property-view/size', 'Size'), this.getSizeString(fileStatObject), infoNode));
114
- this.refreshModelChildren();
115
- }
116
- }
117
-
118
- protected getLocationString(fileStat: FileStat): string {
119
- return fileStat.resource.path.fsPath();
120
- }
121
-
122
- protected getFileName(fileStat: FileStat): string {
123
- return this.labelProvider.getName(fileStat.resource);
124
- }
125
-
126
- protected getFilePath(fileStat: FileStat): string {
127
- return this.labelProvider.getLongName(fileStat.resource);
128
- }
129
-
130
- protected getLastModificationString(fileStat: FileStat): string {
131
- return fileStat.mtime ? new Date(fileStat.mtime).toLocaleString() : '';
132
- }
133
-
134
- protected getCreationTimeString(fileStat: FileStat): string {
135
- return fileStat.ctime ? new Date(fileStat.ctime).toLocaleString() : '';
136
- }
137
-
138
- protected getSizeString(fileStat: FileStat): string {
139
- return fileStat.size ? nls.localizeByDefault('{0}B', fileStat.size.toString()) : '';
140
- }
141
-
142
- /*
143
- * Creating TreeNodes
144
- */
145
-
146
- protected createCategoryNode(categoryId: string, name: string): ResourcePropertiesCategoryNode {
147
- return {
148
- id: categoryId,
149
- parent: this.model.root as ResourcePropertiesRoot,
150
- name,
151
- children: [],
152
- categoryId,
153
- selected: false,
154
- expanded: true
155
- };
156
- }
157
-
158
- protected createResultLineNode(id: string, name: string, property: boolean | string | undefined, parent: ResourcePropertiesCategoryNode): ResourcePropertiesItemNode {
159
- return {
160
- id: `${parent.id}::${id}`,
161
- parent,
162
- name: name,
163
- property: property !== undefined ? String(property) : '',
164
- selected: false
165
- };
166
- }
167
-
168
- /**
169
- * Rendering
170
- */
171
-
172
- protected async refreshModelChildren(): Promise<void> {
173
- if (ResourcePropertiesRoot.is(this.model.root)) {
174
- this.model.root.children = Array.from(this.propertiesTree.values());
175
- this.model.refresh();
176
- }
177
- }
178
-
179
- protected override renderCaption(node: TreeNode, props: NodeProps): React.ReactNode {
180
- if (ResourcePropertiesCategoryNode.is(node)) {
181
- return this.renderExpandableNode(node);
182
- } else if (ResourcePropertiesItemNode.is(node)) {
183
- return this.renderItemNode(node);
184
- }
185
- return undefined;
186
- }
187
-
188
- protected renderExpandableNode(node: ResourcePropertiesCategoryNode): React.ReactNode {
189
- return <React.Fragment>
190
- <div className={`theia-resource-tree-node-icon ${this.toNodeIcon(node)}`}></div>
191
- <div className={'theia-resource-tree-node-name theia-TreeNodeSegment theia-TreeNodeSegmentGrow'}>{this.toNodeName(node)}</div>
192
- </React.Fragment>;
193
- }
194
-
195
- protected renderItemNode(node: ResourcePropertiesItemNode): React.ReactNode {
196
- return <React.Fragment>
197
- <div className={`theia-resource-tree-node-icon ${this.toNodeIcon(node)}`}></div>
198
- <div className={'theia-resource-tree-node-name theia-TreeNodeSegment theia-TreeNodeSegmentGrow'}>{this.toNodeName(node)}</div>
199
- <div className={'theia-resource-tree-node-property theia-TreeNodeSegment theia-TreeNodeSegmentGrow'}>{this.toNodeDescription(node)}</div>
200
- </React.Fragment>;
201
- }
202
-
203
- protected override createNodeAttributes(node: TreeNode, props: NodeProps): React.Attributes & React.HTMLAttributes<HTMLElement> {
204
- return {
205
- ...super.createNodeAttributes(node, props),
206
- title: this.getNodeTooltip(node)
207
- };
208
- }
209
-
210
- protected getNodeTooltip(node: TreeNode): string | undefined {
211
- if (ResourcePropertiesCategoryNode.is(node)) {
212
- return this.labelProvider.getName(node);
213
- } else if (ResourcePropertiesItemNode.is(node)) {
214
- return `${this.labelProvider.getName(node)}: ${this.labelProvider.getLongName(node)}`;
215
- }
216
- return undefined;
217
- }
218
-
219
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 EclipseSource 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 {
18
+ ContextMenuRenderer,
19
+ NodeProps,
20
+ TreeModel,
21
+ TreeNode,
22
+ TreeProps,
23
+ TreeWidget
24
+ } from '@theia/core/lib/browser';
25
+ import { FileStat } from '@theia/filesystem/lib/common/files';
26
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
27
+ import * as React from '@theia/core/shared/react';
28
+ import { PropertyDataService } from '../property-data-service';
29
+ import { PropertyViewContentWidget } from '../property-view-content-widget';
30
+ import {
31
+ ResourcePropertiesCategoryNode,
32
+ ResourcePropertiesItemNode,
33
+ ResourcePropertiesRoot,
34
+ ROOT_ID
35
+ } from './resource-property-view-tree-items';
36
+ import { nls } from '@theia/core/lib/common/nls';
37
+
38
+ /**
39
+ * This widget fetches the property data for {@link FileSelection}s and selections of {@link Navigatable}s
40
+ * and renders that property data as a {@link TreeWidget}.
41
+ * This widget is provided by the registered `ResourcePropertyViewWidgetProvider`.
42
+ */
43
+ @injectable()
44
+ export class ResourcePropertyViewTreeWidget extends TreeWidget implements PropertyViewContentWidget {
45
+
46
+ static readonly ID = 'resource-properties-tree-widget';
47
+ static readonly LABEL = 'Resource Properties Tree';
48
+
49
+ protected propertiesTree: Map<string, ResourcePropertiesCategoryNode>;
50
+ protected currentSelection: Object | undefined;
51
+
52
+ constructor(
53
+ @inject(TreeProps) props: TreeProps,
54
+ @inject(TreeModel) model: TreeModel,
55
+ @inject(ContextMenuRenderer) contextMenuRenderer: ContextMenuRenderer
56
+ ) {
57
+ super(props, model, contextMenuRenderer);
58
+
59
+ model.root = {
60
+ id: ROOT_ID,
61
+ name: ResourcePropertyViewTreeWidget.LABEL,
62
+ parent: undefined,
63
+ visible: false,
64
+ children: []
65
+ } as ResourcePropertiesRoot;
66
+
67
+ this.propertiesTree = new Map<string, ResourcePropertiesCategoryNode>();
68
+ }
69
+
70
+ @postConstruct()
71
+ protected override init(): void {
72
+ super.init();
73
+
74
+ this.id = ResourcePropertyViewTreeWidget.ID + '-treeContainer';
75
+ this.addClass('treeContainer');
76
+
77
+ this.fillPropertiesTree();
78
+ }
79
+
80
+ protected updateNeeded(selection: Object | undefined): boolean {
81
+ return this.currentSelection !== selection;
82
+ }
83
+
84
+ updatePropertyViewContent(propertyDataService?: PropertyDataService, selection?: Object | undefined): void {
85
+ if (this.updateNeeded(selection)) {
86
+ this.currentSelection = selection;
87
+ if (propertyDataService) {
88
+ propertyDataService.providePropertyData(selection).then((fileStatObject?: FileStat) => {
89
+ this.fillPropertiesTree(fileStatObject);
90
+ });
91
+ }
92
+ }
93
+ }
94
+
95
+ protected fillPropertiesTree(fileStatObject?: FileStat): void {
96
+ if (fileStatObject) {
97
+ this.propertiesTree.clear();
98
+ const infoNode = this.createCategoryNode('info', nls.localizeByDefault('Info'));
99
+ this.propertiesTree.set('info', infoNode);
100
+
101
+ infoNode.children.push(this.createResultLineNode('isDirectory', nls.localize('theia/property-view/directory', 'Directory'), fileStatObject.isDirectory, infoNode));
102
+ infoNode.children.push(this.createResultLineNode('isFile', nls.localizeByDefault('File'), fileStatObject.isFile, infoNode));
103
+ infoNode.children.push(this.createResultLineNode('isSymbolicLink', nls.localize('theia/property-view/symbolicLink', 'Symbolic link'),
104
+ fileStatObject.isSymbolicLink, infoNode));
105
+ infoNode.children.push(this.createResultLineNode('location', nls.localize('theia/property-view/location', 'Location'),
106
+ this.getLocationString(fileStatObject), infoNode));
107
+ infoNode.children.push(this.createResultLineNode('name', nls.localizeByDefault('Name'), this.getFileName(fileStatObject), infoNode));
108
+ infoNode.children.push(this.createResultLineNode('path', nls.localizeByDefault('Path'), this.getFilePath(fileStatObject), infoNode));
109
+ infoNode.children.push(this.createResultLineNode('lastModification', nls.localize('theia/property-view/lastModified', 'Last modified'),
110
+ this.getLastModificationString(fileStatObject), infoNode));
111
+ infoNode.children.push(this.createResultLineNode('created', nls.localize('theia/property-view/created', 'Created'),
112
+ this.getCreationTimeString(fileStatObject), infoNode));
113
+ infoNode.children.push(this.createResultLineNode('size', nls.localize('theia/property-view/size', 'Size'), this.getSizeString(fileStatObject), infoNode));
114
+ this.refreshModelChildren();
115
+ }
116
+ }
117
+
118
+ protected getLocationString(fileStat: FileStat): string {
119
+ return fileStat.resource.path.fsPath();
120
+ }
121
+
122
+ protected getFileName(fileStat: FileStat): string {
123
+ return this.labelProvider.getName(fileStat.resource);
124
+ }
125
+
126
+ protected getFilePath(fileStat: FileStat): string {
127
+ return this.labelProvider.getLongName(fileStat.resource);
128
+ }
129
+
130
+ protected getLastModificationString(fileStat: FileStat): string {
131
+ return fileStat.mtime ? new Date(fileStat.mtime).toLocaleString() : '';
132
+ }
133
+
134
+ protected getCreationTimeString(fileStat: FileStat): string {
135
+ return fileStat.ctime ? new Date(fileStat.ctime).toLocaleString() : '';
136
+ }
137
+
138
+ protected getSizeString(fileStat: FileStat): string {
139
+ return fileStat.size ? nls.localizeByDefault('{0}B', fileStat.size.toString()) : '';
140
+ }
141
+
142
+ /*
143
+ * Creating TreeNodes
144
+ */
145
+
146
+ protected createCategoryNode(categoryId: string, name: string): ResourcePropertiesCategoryNode {
147
+ return {
148
+ id: categoryId,
149
+ parent: this.model.root as ResourcePropertiesRoot,
150
+ name,
151
+ children: [],
152
+ categoryId,
153
+ selected: false,
154
+ expanded: true
155
+ };
156
+ }
157
+
158
+ protected createResultLineNode(id: string, name: string, property: boolean | string | undefined, parent: ResourcePropertiesCategoryNode): ResourcePropertiesItemNode {
159
+ return {
160
+ id: `${parent.id}::${id}`,
161
+ parent,
162
+ name: name,
163
+ property: property !== undefined ? String(property) : '',
164
+ selected: false
165
+ };
166
+ }
167
+
168
+ /**
169
+ * Rendering
170
+ */
171
+
172
+ protected async refreshModelChildren(): Promise<void> {
173
+ if (ResourcePropertiesRoot.is(this.model.root)) {
174
+ this.model.root.children = Array.from(this.propertiesTree.values());
175
+ this.model.refresh();
176
+ }
177
+ }
178
+
179
+ protected override renderCaption(node: TreeNode, props: NodeProps): React.ReactNode {
180
+ if (ResourcePropertiesCategoryNode.is(node)) {
181
+ return this.renderExpandableNode(node);
182
+ } else if (ResourcePropertiesItemNode.is(node)) {
183
+ return this.renderItemNode(node);
184
+ }
185
+ return undefined;
186
+ }
187
+
188
+ protected renderExpandableNode(node: ResourcePropertiesCategoryNode): React.ReactNode {
189
+ return <React.Fragment>
190
+ <div className={`theia-resource-tree-node-icon ${this.toNodeIcon(node)}`}></div>
191
+ <div className={'theia-resource-tree-node-name theia-TreeNodeSegment theia-TreeNodeSegmentGrow'}>{this.toNodeName(node)}</div>
192
+ </React.Fragment>;
193
+ }
194
+
195
+ protected renderItemNode(node: ResourcePropertiesItemNode): React.ReactNode {
196
+ return <React.Fragment>
197
+ <div className={`theia-resource-tree-node-icon ${this.toNodeIcon(node)}`}></div>
198
+ <div className={'theia-resource-tree-node-name theia-TreeNodeSegment theia-TreeNodeSegmentGrow'}>{this.toNodeName(node)}</div>
199
+ <div className={'theia-resource-tree-node-property theia-TreeNodeSegment theia-TreeNodeSegmentGrow'}>{this.toNodeDescription(node)}</div>
200
+ </React.Fragment>;
201
+ }
202
+
203
+ protected override createNodeAttributes(node: TreeNode, props: NodeProps): React.Attributes & React.HTMLAttributes<HTMLElement> {
204
+ return {
205
+ ...super.createNodeAttributes(node, props),
206
+ title: this.getNodeTooltip(node)
207
+ };
208
+ }
209
+
210
+ protected getNodeTooltip(node: TreeNode): string | undefined {
211
+ if (ResourcePropertiesCategoryNode.is(node)) {
212
+ return this.labelProvider.getName(node);
213
+ } else if (ResourcePropertiesItemNode.is(node)) {
214
+ return `${this.labelProvider.getName(node)}: ${this.labelProvider.getLongName(node)}`;
215
+ }
216
+ return undefined;
217
+ }
218
+
219
+ }
@@ -1,55 +1,55 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 EclipseSource 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 { Navigatable } from '@theia/core/lib/browser';
18
- import { FileSelection } from '@theia/filesystem/lib/browser/file-selection';
19
- import { inject, injectable } from '@theia/core/shared/inversify';
20
- import { DefaultPropertyViewWidgetProvider } from '../property-view-widget-provider';
21
- import { ResourcePropertyViewTreeWidget } from './resource-property-view-tree-widget';
22
-
23
- /**
24
- * Provides the {@link ResourcePropertyViewTreeWidget} for
25
- * {@link FileSelection}s and selections of {@link Navigatable}s.
26
- */
27
- @injectable()
28
- export class ResourcePropertyViewWidgetProvider extends DefaultPropertyViewWidgetProvider {
29
-
30
- @inject(ResourcePropertyViewTreeWidget) protected treeWidget: ResourcePropertyViewTreeWidget;
31
-
32
- override readonly id = 'resources';
33
- override readonly label = 'ResourcePropertyViewWidgetProvider';
34
-
35
- override canHandle(selection: Object | undefined): number {
36
- return (this.isFileSelection(selection) || this.isNavigatableSelection(selection)) ? 1 : 0;
37
- }
38
-
39
- protected isFileSelection(selection: Object | undefined): boolean {
40
- return !!selection && Array.isArray(selection) && FileSelection.is(selection[0]);
41
- }
42
-
43
- protected isNavigatableSelection(selection: Object | undefined): boolean {
44
- return !!selection && Navigatable.is(selection);
45
- }
46
-
47
- override provideWidget(selection: Object | undefined): Promise<ResourcePropertyViewTreeWidget> {
48
- return Promise.resolve(this.treeWidget);
49
- }
50
-
51
- override updateContentWidget(selection: Object | undefined): void {
52
- this.getPropertyDataService(selection).then(service => this.treeWidget.updatePropertyViewContent(service, selection));
53
- }
54
-
55
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 EclipseSource 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 { Navigatable } from '@theia/core/lib/browser';
18
+ import { FileSelection } from '@theia/filesystem/lib/browser/file-selection';
19
+ import { inject, injectable } from '@theia/core/shared/inversify';
20
+ import { DefaultPropertyViewWidgetProvider } from '../property-view-widget-provider';
21
+ import { ResourcePropertyViewTreeWidget } from './resource-property-view-tree-widget';
22
+
23
+ /**
24
+ * Provides the {@link ResourcePropertyViewTreeWidget} for
25
+ * {@link FileSelection}s and selections of {@link Navigatable}s.
26
+ */
27
+ @injectable()
28
+ export class ResourcePropertyViewWidgetProvider extends DefaultPropertyViewWidgetProvider {
29
+
30
+ @inject(ResourcePropertyViewTreeWidget) protected treeWidget: ResourcePropertyViewTreeWidget;
31
+
32
+ override readonly id = 'resources';
33
+ override readonly label = 'ResourcePropertyViewWidgetProvider';
34
+
35
+ override canHandle(selection: Object | undefined): number {
36
+ return (this.isFileSelection(selection) || this.isNavigatableSelection(selection)) ? 1 : 0;
37
+ }
38
+
39
+ protected isFileSelection(selection: Object | undefined): boolean {
40
+ return !!selection && Array.isArray(selection) && FileSelection.is(selection[0]);
41
+ }
42
+
43
+ protected isNavigatableSelection(selection: Object | undefined): boolean {
44
+ return !!selection && Navigatable.is(selection);
45
+ }
46
+
47
+ override provideWidget(selection: Object | undefined): Promise<ResourcePropertyViewTreeWidget> {
48
+ return Promise.resolve(this.treeWidget);
49
+ }
50
+
51
+ override updateContentWidget(selection: Object | undefined): void {
52
+ this.getPropertyDataService(selection).then(service => this.treeWidget.updatePropertyViewContent(service, selection));
53
+ }
54
+
55
+ }
@@ -1,51 +1,51 @@
1
- /********************************************************************************
2
- * Copyright (C) 2020 EclipseSource 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
- :root {
18
- --theia-property-view-widget-padding: 5px;
19
- --theia-empty-property-view-widget-padding: 8px;
20
- --theia-resource-tree-node-icon-margin: 0 3px;
21
- --theia-resource-tree-node-icon-flex-basis: 1.5%;
22
- --theia-resource-tree-node-name-flex-basis: 30%;
23
- --theia-resource-tree-node-property-flex-basis: 70%;
24
- }
25
-
26
- .theia-property-view-widget {
27
- padding: var(--theia-border-width);
28
- }
29
-
30
- #theia-empty-property-view .theia-widget-noInfo {
31
- padding: var(--theia-empty-property-view-widget-padding);
32
- }
33
-
34
- .theia-property-view-widget .treeContainer {
35
- height: 100%;
36
- }
37
-
38
- .theia-resource-tree-node-icon {
39
- margin: var(--theia-resource-tree-node-icon-margin);
40
- flex-basis: var(--theia-resource-tree-node-icon-flex-basis);
41
- align-self: center;
42
- text-align: center;
43
- }
44
-
45
- .theia-resource-tree-node-name {
46
- flex-basis: var(--theia-resource-tree-node-name-flex-basis);
47
- }
48
-
49
- .theia-resource-tree-node-property {
50
- flex-basis: var(--theia-resource-tree-node-property-flex-basis);
51
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2020 EclipseSource 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
+ :root {
18
+ --theia-property-view-widget-padding: 5px;
19
+ --theia-empty-property-view-widget-padding: 8px;
20
+ --theia-resource-tree-node-icon-margin: 0 3px;
21
+ --theia-resource-tree-node-icon-flex-basis: 1.5%;
22
+ --theia-resource-tree-node-name-flex-basis: 30%;
23
+ --theia-resource-tree-node-property-flex-basis: 70%;
24
+ }
25
+
26
+ .theia-property-view-widget {
27
+ padding: var(--theia-border-width);
28
+ }
29
+
30
+ #theia-empty-property-view .theia-widget-noInfo {
31
+ padding: var(--theia-empty-property-view-widget-padding);
32
+ }
33
+
34
+ .theia-property-view-widget .treeContainer {
35
+ height: 100%;
36
+ }
37
+
38
+ .theia-resource-tree-node-icon {
39
+ margin: var(--theia-resource-tree-node-icon-margin);
40
+ flex-basis: var(--theia-resource-tree-node-icon-flex-basis);
41
+ align-self: center;
42
+ text-align: center;
43
+ }
44
+
45
+ .theia-resource-tree-node-name {
46
+ flex-basis: var(--theia-resource-tree-node-name-flex-basis);
47
+ }
48
+
49
+ .theia-resource-tree-node-property {
50
+ flex-basis: var(--theia-resource-tree-node-property-flex-basis);
51
+ }