@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,112 +1,112 @@
|
|
|
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 { ContributionProvider, MaybePromise, Prioritizeable } from '@theia/core';
|
|
18
|
-
import { inject, injectable, named, postConstruct } from '@theia/core/shared/inversify';
|
|
19
|
-
import { PropertyDataService } from './property-data-service';
|
|
20
|
-
import { PropertyViewContentWidget } from './property-view-content-widget';
|
|
21
|
-
|
|
22
|
-
export const PropertyViewWidgetProvider = Symbol('PropertyViewWidgetProvider');
|
|
23
|
-
/**
|
|
24
|
-
* The `PropertyViewWidgetProvider` should be implemented to provide a property view content widget for the given selection..
|
|
25
|
-
*/
|
|
26
|
-
export interface PropertyViewWidgetProvider {
|
|
27
|
-
/**
|
|
28
|
-
* A unique id for this provider.
|
|
29
|
-
*/
|
|
30
|
-
id: string;
|
|
31
|
-
/**
|
|
32
|
-
* A human-readable name for this provider.
|
|
33
|
-
*/
|
|
34
|
-
label?: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Test whether this provider can provide a widget for the given selection.
|
|
38
|
-
* A returned value indicating a priority of this provider.
|
|
39
|
-
*
|
|
40
|
-
* @param selection the global selection object
|
|
41
|
-
* @returns a nonzero number if this provider can provide; otherwise it cannot; never reject
|
|
42
|
-
*/
|
|
43
|
-
canHandle(selection: Object | undefined): MaybePromise<number>;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Provide a widget for the given selection.
|
|
47
|
-
* Never reject if `canHandle` return a positive number; otherwise should reject.
|
|
48
|
-
*
|
|
49
|
-
* @param selection the global selection object
|
|
50
|
-
* @returns a resolved property view content widget.
|
|
51
|
-
*/
|
|
52
|
-
provideWidget(selection: Object | undefined): Promise<PropertyViewContentWidget>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Update the widget with the given selection.
|
|
56
|
-
* Never reject if `canHandle` return a positive number; otherwise should reject.
|
|
57
|
-
*
|
|
58
|
-
* @param selection the global selection object
|
|
59
|
-
* @returns a resolved property view content widget.
|
|
60
|
-
*/
|
|
61
|
-
updateContentWidget(selection: Object | undefined): void;
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The `DefaultPropertyViewWidgetProvider` is the default abstract implementation of the {@link PropertyViewWidgetProvider}
|
|
67
|
-
* and should be extended to provide a property view content widget for the given selection.
|
|
68
|
-
*/
|
|
69
|
-
@injectable()
|
|
70
|
-
export abstract class DefaultPropertyViewWidgetProvider implements PropertyViewWidgetProvider {
|
|
71
|
-
|
|
72
|
-
@inject(ContributionProvider) @named(PropertyDataService)
|
|
73
|
-
protected readonly contributions: ContributionProvider<PropertyDataService>;
|
|
74
|
-
|
|
75
|
-
protected propertyDataServices: PropertyDataService[] = [];
|
|
76
|
-
|
|
77
|
-
id = 'default';
|
|
78
|
-
label = 'DefaultPropertyViewWidgetProvider';
|
|
79
|
-
|
|
80
|
-
@postConstruct()
|
|
81
|
-
init(): void {
|
|
82
|
-
this.propertyDataServices = this.propertyDataServices.concat(this.contributions.getContributions());
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
canHandle(selection: Object | undefined): MaybePromise<number> {
|
|
86
|
-
return 0;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
provideWidget(selection: Object | undefined): Promise<PropertyViewContentWidget> {
|
|
90
|
-
throw new Error('not implemented');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
updateContentWidget(selection: Object | undefined): void {
|
|
94
|
-
// no-op
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
protected async getPropertyDataService(selection: Object | undefined): Promise<PropertyDataService> {
|
|
98
|
-
const dataService = await this.prioritize(selection);
|
|
99
|
-
return dataService ?? this.propertyDataServices[0];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
protected async prioritize(selection: Object | undefined): Promise<PropertyDataService | undefined> {
|
|
103
|
-
const prioritized = await Prioritizeable.prioritizeAll(this.propertyDataServices, async (service: PropertyDataService) => {
|
|
104
|
-
try {
|
|
105
|
-
return service.canHandleSelection(selection);
|
|
106
|
-
} catch {
|
|
107
|
-
return 0;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
return prioritized.length !== 0 ? prioritized[0].value : undefined;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
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 { ContributionProvider, MaybePromise, Prioritizeable } from '@theia/core';
|
|
18
|
+
import { inject, injectable, named, postConstruct } from '@theia/core/shared/inversify';
|
|
19
|
+
import { PropertyDataService } from './property-data-service';
|
|
20
|
+
import { PropertyViewContentWidget } from './property-view-content-widget';
|
|
21
|
+
|
|
22
|
+
export const PropertyViewWidgetProvider = Symbol('PropertyViewWidgetProvider');
|
|
23
|
+
/**
|
|
24
|
+
* The `PropertyViewWidgetProvider` should be implemented to provide a property view content widget for the given selection..
|
|
25
|
+
*/
|
|
26
|
+
export interface PropertyViewWidgetProvider {
|
|
27
|
+
/**
|
|
28
|
+
* A unique id for this provider.
|
|
29
|
+
*/
|
|
30
|
+
id: string;
|
|
31
|
+
/**
|
|
32
|
+
* A human-readable name for this provider.
|
|
33
|
+
*/
|
|
34
|
+
label?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Test whether this provider can provide a widget for the given selection.
|
|
38
|
+
* A returned value indicating a priority of this provider.
|
|
39
|
+
*
|
|
40
|
+
* @param selection the global selection object
|
|
41
|
+
* @returns a nonzero number if this provider can provide; otherwise it cannot; never reject
|
|
42
|
+
*/
|
|
43
|
+
canHandle(selection: Object | undefined): MaybePromise<number>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Provide a widget for the given selection.
|
|
47
|
+
* Never reject if `canHandle` return a positive number; otherwise should reject.
|
|
48
|
+
*
|
|
49
|
+
* @param selection the global selection object
|
|
50
|
+
* @returns a resolved property view content widget.
|
|
51
|
+
*/
|
|
52
|
+
provideWidget(selection: Object | undefined): Promise<PropertyViewContentWidget>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Update the widget with the given selection.
|
|
56
|
+
* Never reject if `canHandle` return a positive number; otherwise should reject.
|
|
57
|
+
*
|
|
58
|
+
* @param selection the global selection object
|
|
59
|
+
* @returns a resolved property view content widget.
|
|
60
|
+
*/
|
|
61
|
+
updateContentWidget(selection: Object | undefined): void;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The `DefaultPropertyViewWidgetProvider` is the default abstract implementation of the {@link PropertyViewWidgetProvider}
|
|
67
|
+
* and should be extended to provide a property view content widget for the given selection.
|
|
68
|
+
*/
|
|
69
|
+
@injectable()
|
|
70
|
+
export abstract class DefaultPropertyViewWidgetProvider implements PropertyViewWidgetProvider {
|
|
71
|
+
|
|
72
|
+
@inject(ContributionProvider) @named(PropertyDataService)
|
|
73
|
+
protected readonly contributions: ContributionProvider<PropertyDataService>;
|
|
74
|
+
|
|
75
|
+
protected propertyDataServices: PropertyDataService[] = [];
|
|
76
|
+
|
|
77
|
+
id = 'default';
|
|
78
|
+
label = 'DefaultPropertyViewWidgetProvider';
|
|
79
|
+
|
|
80
|
+
@postConstruct()
|
|
81
|
+
init(): void {
|
|
82
|
+
this.propertyDataServices = this.propertyDataServices.concat(this.contributions.getContributions());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
canHandle(selection: Object | undefined): MaybePromise<number> {
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
provideWidget(selection: Object | undefined): Promise<PropertyViewContentWidget> {
|
|
90
|
+
throw new Error('not implemented');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
updateContentWidget(selection: Object | undefined): void {
|
|
94
|
+
// no-op
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
protected async getPropertyDataService(selection: Object | undefined): Promise<PropertyDataService> {
|
|
98
|
+
const dataService = await this.prioritize(selection);
|
|
99
|
+
return dataService ?? this.propertyDataServices[0];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
protected async prioritize(selection: Object | undefined): Promise<PropertyDataService | undefined> {
|
|
103
|
+
const prioritized = await Prioritizeable.prioritizeAll(this.propertyDataServices, async (service: PropertyDataService) => {
|
|
104
|
+
try {
|
|
105
|
+
return service.canHandleSelection(selection);
|
|
106
|
+
} catch {
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return prioritized.length !== 0 ? prioritized[0].value : undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -1,118 +1,118 @@
|
|
|
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 { Message } from '@theia/core/shared/@phosphor/messaging';
|
|
18
|
-
import { Disposable, SelectionService } from '@theia/core';
|
|
19
|
-
import { BaseWidget, codicon, MessageLoop, Widget } from '@theia/core/lib/browser/widgets/widget';
|
|
20
|
-
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
21
|
-
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
22
|
-
import { PropertyViewContentWidget } from './property-view-content-widget';
|
|
23
|
-
import { PropertyViewService } from './property-view-service';
|
|
24
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The main container for the selection-specific property widgets.
|
|
28
|
-
* Based on the given selection, the registered `PropertyViewWidgetProvider` provides the
|
|
29
|
-
* content widget that displays the corresponding properties.
|
|
30
|
-
*/
|
|
31
|
-
@injectable()
|
|
32
|
-
export class PropertyViewWidget extends BaseWidget {
|
|
33
|
-
|
|
34
|
-
static readonly ID = 'property-view';
|
|
35
|
-
static readonly LABEL = nls.localize('theia/property-view/properties', 'Properties');
|
|
36
|
-
|
|
37
|
-
protected contentWidget: PropertyViewContentWidget;
|
|
38
|
-
|
|
39
|
-
protected override toDisposeOnDetach = new DisposableCollection();
|
|
40
|
-
|
|
41
|
-
@inject(PropertyViewService) protected readonly propertyViewService: PropertyViewService;
|
|
42
|
-
@inject(SelectionService) protected readonly selectionService: SelectionService;
|
|
43
|
-
|
|
44
|
-
@postConstruct()
|
|
45
|
-
init(): void {
|
|
46
|
-
this.id = PropertyViewWidget.ID;
|
|
47
|
-
this.title.label = PropertyViewWidget.LABEL;
|
|
48
|
-
this.title.caption = PropertyViewWidget.LABEL;
|
|
49
|
-
this.title.iconClass = codicon('table');
|
|
50
|
-
this.title.closable = true;
|
|
51
|
-
|
|
52
|
-
this.addClass('theia-property-view-widget');
|
|
53
|
-
this.node.tabIndex = 0;
|
|
54
|
-
|
|
55
|
-
let disposed = false;
|
|
56
|
-
this.toDispose.push(Disposable.create(() => disposed = true));
|
|
57
|
-
this.toDispose.push(this.selectionService.onSelectionChanged((selection: Object | undefined) => {
|
|
58
|
-
this.propertyViewService.getProvider(selection).then(provider => {
|
|
59
|
-
provider.provideWidget(selection).then(contentWidget => {
|
|
60
|
-
if (!disposed) {
|
|
61
|
-
this.replaceContentWidget(contentWidget);
|
|
62
|
-
provider.updateContentWidget(selection);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
protected initializeContentWidget(selection: Object | undefined): void {
|
|
70
|
-
this.propertyViewService.getProvider(selection).then(provider => {
|
|
71
|
-
provider.provideWidget(selection).then(contentWidget => {
|
|
72
|
-
this.attachContentWidget(contentWidget);
|
|
73
|
-
provider.updateContentWidget(selection);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
protected replaceContentWidget(newContentWidget: PropertyViewContentWidget): void {
|
|
79
|
-
if (this.contentWidget.id !== newContentWidget.id) {
|
|
80
|
-
if (this.contentWidget) {
|
|
81
|
-
Widget.detach(this.contentWidget);
|
|
82
|
-
}
|
|
83
|
-
this.attachContentWidget(newContentWidget);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
protected attachContentWidget(newContentWidget: PropertyViewContentWidget): void {
|
|
88
|
-
this.contentWidget = newContentWidget;
|
|
89
|
-
Widget.attach(this.contentWidget, this.node);
|
|
90
|
-
this.toDisposeOnDetach = new DisposableCollection();
|
|
91
|
-
this.toDisposeOnDetach.push(Disposable.create(() => {
|
|
92
|
-
if (this.contentWidget) {
|
|
93
|
-
Widget.detach(this.contentWidget);
|
|
94
|
-
}
|
|
95
|
-
}));
|
|
96
|
-
this.update();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
protected override onAfterAttach(msg: Message): void {
|
|
100
|
-
super.onAfterAttach(msg);
|
|
101
|
-
this.initializeContentWidget(this.selectionService.selection);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
protected override onActivateRequest(msg: Message): void {
|
|
105
|
-
super.onActivateRequest(msg);
|
|
106
|
-
this.node.focus();
|
|
107
|
-
if (this.contentWidget) {
|
|
108
|
-
this.contentWidget.activate();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
protected override onResize(msg: Widget.ResizeMessage): void {
|
|
113
|
-
super.onResize(msg);
|
|
114
|
-
if (this.contentWidget) {
|
|
115
|
-
MessageLoop.sendMessage(this.contentWidget, msg);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
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 { Message } from '@theia/core/shared/@phosphor/messaging';
|
|
18
|
+
import { Disposable, SelectionService } from '@theia/core';
|
|
19
|
+
import { BaseWidget, codicon, MessageLoop, Widget } from '@theia/core/lib/browser/widgets/widget';
|
|
20
|
+
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
21
|
+
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
22
|
+
import { PropertyViewContentWidget } from './property-view-content-widget';
|
|
23
|
+
import { PropertyViewService } from './property-view-service';
|
|
24
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The main container for the selection-specific property widgets.
|
|
28
|
+
* Based on the given selection, the registered `PropertyViewWidgetProvider` provides the
|
|
29
|
+
* content widget that displays the corresponding properties.
|
|
30
|
+
*/
|
|
31
|
+
@injectable()
|
|
32
|
+
export class PropertyViewWidget extends BaseWidget {
|
|
33
|
+
|
|
34
|
+
static readonly ID = 'property-view';
|
|
35
|
+
static readonly LABEL = nls.localize('theia/property-view/properties', 'Properties');
|
|
36
|
+
|
|
37
|
+
protected contentWidget: PropertyViewContentWidget;
|
|
38
|
+
|
|
39
|
+
protected override toDisposeOnDetach = new DisposableCollection();
|
|
40
|
+
|
|
41
|
+
@inject(PropertyViewService) protected readonly propertyViewService: PropertyViewService;
|
|
42
|
+
@inject(SelectionService) protected readonly selectionService: SelectionService;
|
|
43
|
+
|
|
44
|
+
@postConstruct()
|
|
45
|
+
init(): void {
|
|
46
|
+
this.id = PropertyViewWidget.ID;
|
|
47
|
+
this.title.label = PropertyViewWidget.LABEL;
|
|
48
|
+
this.title.caption = PropertyViewWidget.LABEL;
|
|
49
|
+
this.title.iconClass = codicon('table');
|
|
50
|
+
this.title.closable = true;
|
|
51
|
+
|
|
52
|
+
this.addClass('theia-property-view-widget');
|
|
53
|
+
this.node.tabIndex = 0;
|
|
54
|
+
|
|
55
|
+
let disposed = false;
|
|
56
|
+
this.toDispose.push(Disposable.create(() => disposed = true));
|
|
57
|
+
this.toDispose.push(this.selectionService.onSelectionChanged((selection: Object | undefined) => {
|
|
58
|
+
this.propertyViewService.getProvider(selection).then(provider => {
|
|
59
|
+
provider.provideWidget(selection).then(contentWidget => {
|
|
60
|
+
if (!disposed) {
|
|
61
|
+
this.replaceContentWidget(contentWidget);
|
|
62
|
+
provider.updateContentWidget(selection);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected initializeContentWidget(selection: Object | undefined): void {
|
|
70
|
+
this.propertyViewService.getProvider(selection).then(provider => {
|
|
71
|
+
provider.provideWidget(selection).then(contentWidget => {
|
|
72
|
+
this.attachContentWidget(contentWidget);
|
|
73
|
+
provider.updateContentWidget(selection);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected replaceContentWidget(newContentWidget: PropertyViewContentWidget): void {
|
|
79
|
+
if (this.contentWidget.id !== newContentWidget.id) {
|
|
80
|
+
if (this.contentWidget) {
|
|
81
|
+
Widget.detach(this.contentWidget);
|
|
82
|
+
}
|
|
83
|
+
this.attachContentWidget(newContentWidget);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
protected attachContentWidget(newContentWidget: PropertyViewContentWidget): void {
|
|
88
|
+
this.contentWidget = newContentWidget;
|
|
89
|
+
Widget.attach(this.contentWidget, this.node);
|
|
90
|
+
this.toDisposeOnDetach = new DisposableCollection();
|
|
91
|
+
this.toDisposeOnDetach.push(Disposable.create(() => {
|
|
92
|
+
if (this.contentWidget) {
|
|
93
|
+
Widget.detach(this.contentWidget);
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
this.update();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
protected override onAfterAttach(msg: Message): void {
|
|
100
|
+
super.onAfterAttach(msg);
|
|
101
|
+
this.initializeContentWidget(this.selectionService.selection);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
protected override onActivateRequest(msg: Message): void {
|
|
105
|
+
super.onActivateRequest(msg);
|
|
106
|
+
this.node.focus();
|
|
107
|
+
if (this.contentWidget) {
|
|
108
|
+
this.contentWidget.activate();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
protected override onResize(msg: Widget.ResizeMessage): void {
|
|
113
|
+
super.onResize(msg);
|
|
114
|
+
if (this.contentWidget) {
|
|
115
|
+
MessageLoop.sendMessage(this.contentWidget, msg);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
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
|
-
export * from './resource-property-view-tree-container';
|
|
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
|
+
export * from './resource-property-view-tree-container';
|