@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.
- package/README.md +44 -44
- package/lib/browser/empty-property-view-widget-provider.d.ts +32 -32
- package/lib/browser/empty-property-view-widget-provider.js +83 -83
- package/lib/browser/property-data-service.d.ts +28 -28
- package/lib/browser/property-data-service.js +19 -19
- package/lib/browser/property-view-content-widget.d.ts +10 -10
- package/lib/browser/property-view-content-widget.js +17 -17
- package/lib/browser/property-view-contribution.d.ts +5 -5
- package/lib/browser/property-view-contribution.js +48 -48
- package/lib/browser/property-view-frontend-module.d.ts +4 -4
- package/lib/browser/property-view-frontend-module.js +42 -42
- package/lib/browser/property-view-service.d.ts +17 -17
- package/lib/browser/property-view-service.js +81 -81
- package/lib/browser/property-view-widget-provider.d.ts +57 -57
- package/lib/browser/property-view-widget-provider.js +84 -84
- package/lib/browser/property-view-widget.d.ts +26 -26
- package/lib/browser/property-view-widget.js +130 -130
- package/lib/browser/resource-property-view/index.d.ts +1 -1
- package/lib/browser/resource-property-view/index.js +28 -28
- package/lib/browser/resource-property-view/resource-property-data-service.d.ts +17 -17
- package/lib/browser/resource-property-view/resource-property-data-service.js +72 -72
- package/lib/browser/resource-property-view/resource-property-data-service.spec.d.ts +1 -1
- package/lib/browser/resource-property-view/resource-property-data-service.spec.js +101 -101
- package/lib/browser/resource-property-view/resource-property-view-label-provider.d.ts +10 -10
- package/lib/browser/resource-property-view/resource-property-view-label-provider.js +60 -60
- package/lib/browser/resource-property-view/resource-property-view-label-provider.spec.d.ts +1 -1
- package/lib/browser/resource-property-view/resource-property-view-label-provider.spec.js +129 -129
- package/lib/browser/resource-property-view/resource-property-view-tree-container.d.ts +2 -2
- package/lib/browser/resource-property-view/resource-property-view-tree-container.js +43 -43
- package/lib/browser/resource-property-view/resource-property-view-tree-items.d.ts +27 -27
- package/lib/browser/resource-property-view/resource-property-view-tree-items.js +41 -41
- package/lib/browser/resource-property-view/resource-property-view-tree-widget.d.ts +40 -40
- package/lib/browser/resource-property-view/resource-property-view-tree-widget.js +191 -191
- package/lib/browser/resource-property-view/resource-property-view-widget-provider.d.ts +16 -16
- package/lib/browser/resource-property-view/resource-property-view-widget-provider.js +66 -66
- package/lib/package.spec.js +25 -25
- package/package.json +5 -5
- package/src/browser/empty-property-view-widget-provider.tsx +83 -83
- package/src/browser/property-data-service.ts +48 -48
- package/src/browser/property-view-content-widget.ts +27 -27
- package/src/browser/property-view-contribution.ts +36 -36
- package/src/browser/property-view-frontend-module.ts +47 -47
- package/src/browser/property-view-service.ts +62 -62
- package/src/browser/property-view-widget-provider.ts +112 -112
- package/src/browser/property-view-widget.tsx +118 -118
- package/src/browser/resource-property-view/index.ts +17 -17
- package/src/browser/resource-property-view/resource-property-data-service.spec.ts +127 -127
- package/src/browser/resource-property-view/resource-property-data-service.ts +64 -64
- package/src/browser/resource-property-view/resource-property-view-label-provider.spec.ts +153 -153
- package/src/browser/resource-property-view/resource-property-view-label-provider.ts +49 -49
- package/src/browser/resource-property-view/resource-property-view-tree-container.ts +47 -47
- package/src/browser/resource-property-view/resource-property-view-tree-items.ts +53 -53
- package/src/browser/resource-property-view/resource-property-view-tree-widget.tsx +219 -219
- package/src/browser/resource-property-view/resource-property-view-widget-provider.ts +55 -55
- package/src/browser/style/property-view.css +51 -51
- package/src/package.spec.ts +29 -29
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 Ericsson 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 { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
|
|
18
|
-
|
|
19
|
-
let disableJSDOM = enableJSDOM();
|
|
20
|
-
|
|
21
|
-
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
22
|
-
FrontendApplicationConfigProvider.set({});
|
|
23
|
-
|
|
24
|
-
import { expect } from 'chai';
|
|
25
|
-
import { Container } from '@theia/core/shared/inversify';
|
|
26
|
-
import { ResourcePropertyDataService } from './resource-property-data-service';
|
|
27
|
-
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
28
|
-
import URI from '@theia/core/lib/common/uri';
|
|
29
|
-
import { PropertyDataService } from '../property-data-service';
|
|
30
|
-
import { FileSelection } from '@theia/filesystem/lib/browser/file-selection';
|
|
31
|
-
import { Navigatable } from '@theia/core/lib/browser/navigatable';
|
|
32
|
-
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
33
|
-
|
|
34
|
-
disableJSDOM();
|
|
35
|
-
|
|
36
|
-
let resourcePropertyDataService: ResourcePropertyDataService;
|
|
37
|
-
|
|
38
|
-
const mockFileStat: FileStat = {
|
|
39
|
-
isFile: false,
|
|
40
|
-
isDirectory: true,
|
|
41
|
-
isSymbolicLink: false,
|
|
42
|
-
isReadonly: false,
|
|
43
|
-
resource: new URI('resource'),
|
|
44
|
-
name: 'name'
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
describe('resource-property-data-service', () => {
|
|
48
|
-
|
|
49
|
-
before(() => {
|
|
50
|
-
disableJSDOM = enableJSDOM();
|
|
51
|
-
const container = new Container();
|
|
52
|
-
container.bind(ResourcePropertyDataService).toSelf().inSingletonScope();
|
|
53
|
-
container.bind(FileService).toConstantValue({
|
|
54
|
-
async resolve(uri: URI): Promise<FileStat> {
|
|
55
|
-
return mockFileStat;
|
|
56
|
-
}
|
|
57
|
-
} as FileService);
|
|
58
|
-
container.bind(PropertyDataService).to(ResourcePropertyDataService).inSingletonScope();
|
|
59
|
-
resourcePropertyDataService = container.get(ResourcePropertyDataService);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
after(() => {
|
|
63
|
-
disableJSDOM();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const navigatableSelection: Navigatable = {
|
|
67
|
-
getResourceUri(): URI | undefined {
|
|
68
|
-
return new URI('resource-uri');
|
|
69
|
-
},
|
|
70
|
-
createMoveToUri(): URI | undefined {
|
|
71
|
-
return new URI('move-uri');
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const fileSelection: FileSelection[] = [
|
|
76
|
-
{ fileStat: mockFileStat }
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
describe('#canHandle', () => {
|
|
80
|
-
|
|
81
|
-
it('should not handle an empty object selection', () => {
|
|
82
|
-
expect(resourcePropertyDataService.canHandleSelection({})).eq(0);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should not handle an undefined selection', () => {
|
|
86
|
-
expect(resourcePropertyDataService.canHandleSelection(undefined)).eq(0);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should handle a file selection', () => {
|
|
90
|
-
expect(resourcePropertyDataService.canHandleSelection(fileSelection)).to.be.greaterThan(0);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should handle a navigatable selection', () => {
|
|
94
|
-
expect(resourcePropertyDataService.canHandleSelection(navigatableSelection)).to.be.greaterThan(0);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('#providePropertyData', () => {
|
|
99
|
-
|
|
100
|
-
it('should return the file-stat of a file selection', async () => {
|
|
101
|
-
const data = await resourcePropertyDataService.providePropertyData(fileSelection);
|
|
102
|
-
expect(data).to.equal(mockFileStat);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should return the first file-stat for multiple file selections', async () => {
|
|
106
|
-
const arrayFileSelection: FileSelection[] = [
|
|
107
|
-
{ fileStat: mockFileStat },
|
|
108
|
-
{ fileStat: { ...mockFileStat, resource: new URI('secondURI') } }
|
|
109
|
-
];
|
|
110
|
-
const data = await resourcePropertyDataService.providePropertyData(arrayFileSelection);
|
|
111
|
-
expect(data).to.equal(arrayFileSelection[0].fileStat);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('should return the file-stat for a navigatable selection', async () => {
|
|
115
|
-
const data = await resourcePropertyDataService.providePropertyData(navigatableSelection);
|
|
116
|
-
expect(data).to.equal(mockFileStat);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should return undefined if the selection is undefined', async () => {
|
|
120
|
-
const data = await resourcePropertyDataService.providePropertyData(undefined);
|
|
121
|
-
expect(data).to.equal(undefined);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 Ericsson 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 { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
|
|
18
|
+
|
|
19
|
+
let disableJSDOM = enableJSDOM();
|
|
20
|
+
|
|
21
|
+
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
22
|
+
FrontendApplicationConfigProvider.set({});
|
|
23
|
+
|
|
24
|
+
import { expect } from 'chai';
|
|
25
|
+
import { Container } from '@theia/core/shared/inversify';
|
|
26
|
+
import { ResourcePropertyDataService } from './resource-property-data-service';
|
|
27
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
28
|
+
import URI from '@theia/core/lib/common/uri';
|
|
29
|
+
import { PropertyDataService } from '../property-data-service';
|
|
30
|
+
import { FileSelection } from '@theia/filesystem/lib/browser/file-selection';
|
|
31
|
+
import { Navigatable } from '@theia/core/lib/browser/navigatable';
|
|
32
|
+
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
33
|
+
|
|
34
|
+
disableJSDOM();
|
|
35
|
+
|
|
36
|
+
let resourcePropertyDataService: ResourcePropertyDataService;
|
|
37
|
+
|
|
38
|
+
const mockFileStat: FileStat = {
|
|
39
|
+
isFile: false,
|
|
40
|
+
isDirectory: true,
|
|
41
|
+
isSymbolicLink: false,
|
|
42
|
+
isReadonly: false,
|
|
43
|
+
resource: new URI('resource'),
|
|
44
|
+
name: 'name'
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
describe('resource-property-data-service', () => {
|
|
48
|
+
|
|
49
|
+
before(() => {
|
|
50
|
+
disableJSDOM = enableJSDOM();
|
|
51
|
+
const container = new Container();
|
|
52
|
+
container.bind(ResourcePropertyDataService).toSelf().inSingletonScope();
|
|
53
|
+
container.bind(FileService).toConstantValue({
|
|
54
|
+
async resolve(uri: URI): Promise<FileStat> {
|
|
55
|
+
return mockFileStat;
|
|
56
|
+
}
|
|
57
|
+
} as FileService);
|
|
58
|
+
container.bind(PropertyDataService).to(ResourcePropertyDataService).inSingletonScope();
|
|
59
|
+
resourcePropertyDataService = container.get(ResourcePropertyDataService);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
after(() => {
|
|
63
|
+
disableJSDOM();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const navigatableSelection: Navigatable = {
|
|
67
|
+
getResourceUri(): URI | undefined {
|
|
68
|
+
return new URI('resource-uri');
|
|
69
|
+
},
|
|
70
|
+
createMoveToUri(): URI | undefined {
|
|
71
|
+
return new URI('move-uri');
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const fileSelection: FileSelection[] = [
|
|
76
|
+
{ fileStat: mockFileStat }
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
describe('#canHandle', () => {
|
|
80
|
+
|
|
81
|
+
it('should not handle an empty object selection', () => {
|
|
82
|
+
expect(resourcePropertyDataService.canHandleSelection({})).eq(0);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should not handle an undefined selection', () => {
|
|
86
|
+
expect(resourcePropertyDataService.canHandleSelection(undefined)).eq(0);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should handle a file selection', () => {
|
|
90
|
+
expect(resourcePropertyDataService.canHandleSelection(fileSelection)).to.be.greaterThan(0);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should handle a navigatable selection', () => {
|
|
94
|
+
expect(resourcePropertyDataService.canHandleSelection(navigatableSelection)).to.be.greaterThan(0);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('#providePropertyData', () => {
|
|
99
|
+
|
|
100
|
+
it('should return the file-stat of a file selection', async () => {
|
|
101
|
+
const data = await resourcePropertyDataService.providePropertyData(fileSelection);
|
|
102
|
+
expect(data).to.equal(mockFileStat);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should return the first file-stat for multiple file selections', async () => {
|
|
106
|
+
const arrayFileSelection: FileSelection[] = [
|
|
107
|
+
{ fileStat: mockFileStat },
|
|
108
|
+
{ fileStat: { ...mockFileStat, resource: new URI('secondURI') } }
|
|
109
|
+
];
|
|
110
|
+
const data = await resourcePropertyDataService.providePropertyData(arrayFileSelection);
|
|
111
|
+
expect(data).to.equal(arrayFileSelection[0].fileStat);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should return the file-stat for a navigatable selection', async () => {
|
|
115
|
+
const data = await resourcePropertyDataService.providePropertyData(navigatableSelection);
|
|
116
|
+
expect(data).to.equal(mockFileStat);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should return undefined if the selection is undefined', async () => {
|
|
120
|
+
const data = await resourcePropertyDataService.providePropertyData(undefined);
|
|
121
|
+
expect(data).to.equal(undefined);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
});
|
|
127
|
+
|
|
@@ -1,64 +1,64 @@
|
|
|
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 URI from '@theia/core/lib/common/uri';
|
|
19
|
-
import { FileSelection } from '@theia/filesystem/lib/browser/file-selection';
|
|
20
|
-
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
21
|
-
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
22
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
23
|
-
import { PropertyDataService } from '../property-data-service';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* This data service provides property data for {@link FileSelection}s and selections of {@link Navigatable}s.
|
|
27
|
-
*/
|
|
28
|
-
@injectable()
|
|
29
|
-
export class ResourcePropertyDataService implements PropertyDataService {
|
|
30
|
-
|
|
31
|
-
readonly id = 'resources';
|
|
32
|
-
readonly label = 'ResourcePropertyDataService';
|
|
33
|
-
|
|
34
|
-
@inject(FileService) protected readonly fileService: FileService;
|
|
35
|
-
|
|
36
|
-
canHandleSelection(selection: Object | undefined): number {
|
|
37
|
-
return (this.isFileSelection(selection) || this.isNavigatableSelection(selection)) ? 1 : 0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
protected isFileSelection(selection: Object | undefined): boolean {
|
|
41
|
-
return !!selection && Array.isArray(selection) && FileSelection.is(selection[0]);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
protected isNavigatableSelection(selection: Object | undefined): boolean {
|
|
45
|
-
return !!selection && Navigatable.is(selection);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected async getFileStat(uri: URI): Promise<FileStat> {
|
|
49
|
-
return this.fileService.resolve(uri);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async providePropertyData(selection: Object | undefined): Promise<FileStat | undefined> {
|
|
53
|
-
if (this.isFileSelection(selection) && Array.isArray(selection)) {
|
|
54
|
-
return this.getFileStat(selection[0].fileStat.resource);
|
|
55
|
-
} else if (this.isNavigatableSelection(selection)) {
|
|
56
|
-
const navigatableUri = (selection as Navigatable).getResourceUri();
|
|
57
|
-
if (navigatableUri) {
|
|
58
|
-
return this.getFileStat(navigatableUri);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
|
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 URI from '@theia/core/lib/common/uri';
|
|
19
|
+
import { FileSelection } from '@theia/filesystem/lib/browser/file-selection';
|
|
20
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
21
|
+
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
22
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
23
|
+
import { PropertyDataService } from '../property-data-service';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This data service provides property data for {@link FileSelection}s and selections of {@link Navigatable}s.
|
|
27
|
+
*/
|
|
28
|
+
@injectable()
|
|
29
|
+
export class ResourcePropertyDataService implements PropertyDataService {
|
|
30
|
+
|
|
31
|
+
readonly id = 'resources';
|
|
32
|
+
readonly label = 'ResourcePropertyDataService';
|
|
33
|
+
|
|
34
|
+
@inject(FileService) protected readonly fileService: FileService;
|
|
35
|
+
|
|
36
|
+
canHandleSelection(selection: Object | undefined): number {
|
|
37
|
+
return (this.isFileSelection(selection) || this.isNavigatableSelection(selection)) ? 1 : 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected isFileSelection(selection: Object | undefined): boolean {
|
|
41
|
+
return !!selection && Array.isArray(selection) && FileSelection.is(selection[0]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected isNavigatableSelection(selection: Object | undefined): boolean {
|
|
45
|
+
return !!selection && Navigatable.is(selection);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected async getFileStat(uri: URI): Promise<FileStat> {
|
|
49
|
+
return this.fileService.resolve(uri);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async providePropertyData(selection: Object | undefined): Promise<FileStat | undefined> {
|
|
53
|
+
if (this.isFileSelection(selection) && Array.isArray(selection)) {
|
|
54
|
+
return this.getFileStat(selection[0].fileStat.resource);
|
|
55
|
+
} else if (this.isNavigatableSelection(selection)) {
|
|
56
|
+
const navigatableUri = (selection as Navigatable).getResourceUri();
|
|
57
|
+
if (navigatableUri) {
|
|
58
|
+
return this.getFileStat(navigatableUri);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|